Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
base
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository 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
FSL
base
Commits
a2265ea3
Commit
a2265ea3
authored
3 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
TEST: unit test for creating *_gui wrapper scripts
parent
730c3124
No related branches found
No related tags found
1 merge request
!20
Rf/gui wrappers
Pipeline
#10287
passed
3 years ago
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_create_remove_wrapper.py
+57
-0
57 additions, 0 deletions
tests/test_create_remove_wrapper.py
with
57 additions
and
0 deletions
tests/test_create_remove_wrapper.py
+
57
−
0
View file @
a2265ea3
...
...
@@ -11,6 +11,7 @@ import sys
import
os.path
as
op
import
subprocess
as
sp
import
textwrap
as
tw
import
itertools
as
it
import
os
import
shlex
import
shutil
...
...
@@ -64,6 +65,22 @@ def touch(path):
f
.
write
(
'
.
'
)
def
get_called_command
(
filename
):
"""
Returns the command that is being called by the given wrapper script.
"""
with
open
(
filename
,
'
rt
'
)
as
f
:
line
=
f
.
readlines
()[
1
]
tokens
=
line
.
split
()
cmd
=
op
.
basename
(
tokens
[
0
])
if
cmd
in
(
'
python
'
,
'
pythonw
'
):
cmd
=
tokens
[
2
]
return
cmd
def
test_env_vars_not_set
():
"""
Test that wrapper scripts are not created if the
FSL_CREATE_WRAPPER_SCRIPTS, FSLDIR, or PREFIX environment variables
...
...
@@ -219,6 +236,46 @@ def test_create_remove_wrappers():
assert
not
op
.
exists
(
op
.
join
(
wrapperdir
,
'
test_script2
'
))
def
test_create_gui_wrappers
():
"""
Tests creation of wrappers for FSL GUI commands, which are called
"
<Command>_gui
"
on macOS, and
"
<Command>
"
on linux, where
"
<command>
"
(note the case) may also exist. Post-link scripts should only pass the
"
<Command>_gui
"
variant.
"""
# Test outcome differs for different platforms.
# Keys are passed to createFSLWrapper, values are
# wrappers that should be created
if
sys
.
platform
==
'
darwin
'
:
scripts
=
{
'
script
'
:
'
script
'
,
'
Script_gui
'
:
'
Script_gui
'
}
# linux
else
:
scripts
=
{
'
script
'
:
'
script
'
,
'
Script_gui
'
:
'
Script
'
}
with
temp_fsldir
()
as
(
fsldir
,
wrapperdir
):
for
target
in
scripts
.
values
():
touch
(
op
.
join
(
fsldir
,
'
bin
'
,
target
))
for
wrappers
in
it
.
permutations
(
scripts
.
keys
()):
args
=
'
'
.
join
(
wrappers
)
run
(
f
'
{
CREATE_WRAPPER
}
{
args
}
'
)
for
arg
in
wrappers
:
target
=
scripts
[
arg
]
wrapper
=
op
.
join
(
wrapperdir
,
target
)
assert
op
.
exists
(
wrapper
)
assert
get_called_command
(
wrapper
)
==
scripts
[
arg
]
run
(
f
'
{
REMOVE_WRAPPER
}
{
args
}
'
)
for
arg
in
wrappers
:
target
=
scripts
[
arg
]
wrapper
=
op
.
join
(
wrapperdir
,
target
)
assert
not
op
.
exists
(
wrapper
)
if
__name__
==
'
__main__
'
:
# base dir can be speecified on command line
if
len
(
sys
.
argv
)
>
1
:
...
...
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