Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
FSL
conda
installer
Commits
db5536ea
Commit
db5536ea
authored
Aug 12, 2021
by
Paul McCarthy
🚵
Browse files
TEST: Adjust installer test to simulate "conda install" call
parent
06f0abf0
Changes
1
Show whitespace changes
Inline
Side-by-side
test/test_installer.py
View file @
db5536ea
...
@@ -35,11 +35,15 @@ mkdir -p $prefix/etc/
...
@@ -35,11 +35,15 @@ mkdir -p $prefix/etc/
prefix=$(cd $prefix && pwd)
prefix=$(cd $prefix && pwd)
# called like conda env update -n base -f <envfile>
# called like
# and like conda clean -y --all
# - conda install -y -n base fslbase=1234.0
# - conda env update -n base -f <envfile>
# - conda clean -y --all
echo "#!/usr/bin/env bash" >> $3/bin/conda
echo "#!/usr/bin/env bash" >> $3/bin/conda
echo 'if [ "$1" = "clean" ]; then ' >> $3/bin/conda
echo 'if [ "$1" = "clean" ]; then ' >> $3/bin/conda
echo " touch $prefix/cleaned" >> $3/bin/conda
echo " touch $prefix/cleaned" >> $3/bin/conda
echo 'elif [ "$1" = "install" ]; then ' >> $3/bin/conda
echo ' echo "$5"' "> $prefix/installed" >> $3/bin/conda
echo "else" >> $3/bin/conda
echo "else" >> $3/bin/conda
echo " cp "'$6'" $prefix/" >> $3/bin/conda
echo " cp "'$6'" $prefix/" >> $3/bin/conda
echo "fi" >> $3/bin/conda
echo "fi" >> $3/bin/conda
...
@@ -82,6 +86,14 @@ mock_manifest = """
...
@@ -82,6 +86,14 @@ mock_manifest = """
# Format vars: version platform url conda_sha256 env610_sha256 env620_sha256
# Format vars: version platform url conda_sha256 env610_sha256 env620_sha256
mock_env_yml_template
=
"""
{version}
packages:
- fsl-base 1234.0
"""
.
strip
()
@
contextlib
.
contextmanager
@
contextlib
.
contextmanager
def
installer_server
(
cwd
=
None
):
def
installer_server
(
cwd
=
None
):
if
cwd
is
None
:
if
cwd
is
None
:
...
@@ -89,9 +101,12 @@ def installer_server(cwd=None):
...
@@ -89,9 +101,12 @@ def installer_server(cwd=None):
cwd
=
op
.
abspath
(
cwd
)
cwd
=
op
.
abspath
(
cwd
)
with
indir
(
cwd
),
server
(
cwd
)
as
srv
:
with
indir
(
cwd
),
server
(
cwd
)
as
srv
:
with
open
(
'miniconda.sh'
,
'wt'
)
as
f
:
f
.
write
(
mock_miniconda_sh
)
with
open
(
'miniconda.sh'
,
'wt'
)
as
f
:
with
open
(
'env-6.1.0.yml'
,
'wt'
)
as
f
:
f
.
write
(
'6.1.0'
)
f
.
write
(
mock_miniconda_sh
)
with
open
(
'env-6.2.0.yml'
,
'wt'
)
as
f
:
f
.
write
(
'6.2.0'
)
with
open
(
'env-6.1.0.yml'
,
'wt'
)
as
f
:
f
.
write
(
mock_env_yml_template
.
format
(
version
=
'6.1.0'
))
with
open
(
'env-6.2.0.yml'
,
'wt'
)
as
f
:
f
.
write
(
mock_env_yml_template
.
format
(
version
=
'6.2.0'
))
conda_sha256
=
inst
.
sha256
(
'miniconda.sh'
)
conda_sha256
=
inst
.
sha256
(
'miniconda.sh'
)
env610_sha256
=
inst
.
sha256
(
'env-6.1.0.yml'
)
env610_sha256
=
inst
.
sha256
(
'env-6.1.0.yml'
)
...
@@ -119,13 +134,21 @@ def check_install(homedir, destdir, version):
...
@@ -119,13 +134,21 @@ def check_install(homedir, destdir, version):
profile
=
inst
.
configure_shell
.
shell_profiles
.
get
(
shell
,
None
)
profile
=
inst
.
configure_shell
.
shell_profiles
.
get
(
shell
,
None
)
with
indir
(
destdir
):
with
indir
(
destdir
):
with
open
(
op
.
join
(
etc
,
'fslversion'
),
'rt'
)
as
f
:
assert
f
.
read
().
strip
()
==
version
# added by our mock conda env creeate call
# added by our mock conda env creeate call
with
open
(
op
.
join
(
destdir
,
'env-{}.yml'
.
format
(
version
)),
'rt'
)
as
f
:
with
open
(
op
.
join
(
destdir
,
'env-{}.yml'
.
format
(
version
)),
'rt'
)
as
f
:
assert
f
.
read
().
strip
()
==
version
exp
=
mock_env_yml_template
.
format
(
version
=
version
)
assert
f
.
read
().
strip
()
==
exp
# added by our mock conda install call
with
open
(
op
.
join
(
destdir
,
'installed'
),
'rt'
)
as
f
:
assert
f
.
read
().
strip
()
==
'fsl-base=1234.0'
# added by our mock conda clean call
assert
op
.
exists
(
op
.
join
(
destdir
,
'cleaned'
))
# added by the fslinstaller
with
open
(
op
.
join
(
etc
,
'fslversion'
),
'rt'
)
as
f
:
assert
f
.
read
().
strip
()
==
version
assert
op
.
exists
(
op
.
join
(
etc
,
'fslinstaller.py'
))
assert
op
.
exists
(
op
.
join
(
etc
,
'fslinstaller.py'
))
assert
op
.
exists
(
op
.
join
(
etc
,
'env-{}.yml'
.
format
(
version
)))
assert
op
.
exists
(
op
.
join
(
etc
,
'env-{}.yml'
.
format
(
version
)))
assert
op
.
exists
(
op
.
join
(
homedir
,
'Documents'
,
'MATLAB'
))
assert
op
.
exists
(
op
.
join
(
homedir
,
'Documents'
,
'MATLAB'
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment