Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
e3-require
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ESS EPICS Environment
wrappers
e3-require
Commits
a566302f
Commit
a566302f
authored
2 years ago
by
Simon Rose
Browse files
Options
Downloads
Patches
Plain Diff
E3-731
: Add basic tests for expandDBD.tcl
parent
9e5c2556
No related branches found
No related tags found
1 merge request
!98
E3-731: Improve tests
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_expand_dbd.py
+60
-0
60 additions, 0 deletions
tests/test_expand_dbd.py
with
60 additions
and
0 deletions
tests/test_expand_dbd.py
0 → 100644
+
60
−
0
View file @
a566302f
import
os
import
subprocess
from
pathlib
import
Path
import
pytest
@pytest.fixture
def
expanddbdtcl
():
require_path
=
Path
(
os
.
environ
.
get
(
"
E3_REQUIRE_LOCATION
"
))
expanddbdtcl
=
require_path
/
"
tools
"
/
"
expandDBD.tcl
"
assert
expanddbdtcl
.
is_file
()
and
os
.
access
(
expanddbdtcl
,
os
.
X_OK
)
return
expanddbdtcl
def
test_missing_dbd_file
(
tmpdir
,
expanddbdtcl
):
dbd_file
=
Path
(
tmpdir
)
/
"
tmp.dbd
"
dbd_file
.
write_text
(
"
include not_a_file.dbd
"
)
result
=
subprocess
.
run
(
[
expanddbdtcl
,
dbd_file
],
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
,
encoding
=
"
utf-8
"
,
)
assert
result
.
returncode
==
1
assert
"
file not_a_file.dbd not found
"
in
result
.
stderr
def
test_include_dbd_file
(
tmpdir
,
expanddbdtcl
):
dbd_a
=
Path
(
tmpdir
)
/
"
a.dbd
"
dbd_a
.
write_text
(
"
include b.dbd
"
)
dbd_b
=
Path
(
tmpdir
)
/
"
b.dbd
"
dbd_b
.
write_text
(
"
content
"
)
result
=
subprocess
.
run
(
[
expanddbdtcl
,
"
-I
"
,
str
(
tmpdir
),
dbd_a
],
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
,
encoding
=
"
utf-8
"
,
)
assert
result
.
returncode
==
0
assert
"
content
"
==
result
.
stdout
.
strip
(
"
\n
"
)
def
test_skip_repeated_includes
(
tmpdir
,
expanddbdtcl
):
dbd_a
=
Path
(
tmpdir
)
/
"
a.dbd
"
dbd_a
.
write_text
(
"
include b.dbd
\n
include b.dbd
"
)
dbd_b
=
Path
(
tmpdir
)
/
"
b.dbd
"
dbd_b
.
touch
()
result
=
subprocess
.
run
(
[
expanddbdtcl
,
"
-I
"
,
str
(
tmpdir
),
dbd_a
],
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
,
encoding
=
"
utf-8
"
,
)
assert
result
.
returncode
==
0
assert
"
Info: skipping duplicate file b.dbd included from
"
in
result
.
stderr
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment