Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mpsd-software-manager
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
MPSD Computational Science
mpsd-software-manager
Commits
c6e26258
Commit
c6e26258
authored
1 year ago
by
Ashwin Kumar Karnad
Browse files
Options
Downloads
Patches
Plain Diff
test prepare_environment
parent
fe0d2dd2
No related branches found
Branches containing commit
No related tags found
2 merge requests
!19
Move linux-debian11 into main
,
!1
Resolve "First draft for user interface for top level install command"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests.py
+12
-34
12 additions, 34 deletions
tests.py
with
12 additions
and
34 deletions
tests.py
+
12
−
34
View file @
c6e26258
...
...
@@ -24,58 +24,36 @@ def test_os_chdir(tmp_path):
assert
os
.
getcwd
()
==
initial_cwd
def
test_prepare_env
(
tmp_path
):
def
test_prepare_env
ironment
(
tmp_path
):
# simulate running ./install-software-environment.py --release dev-23a --target-directory /tmp/test_prepare_env
# prepare_env is run when cmd is not specified, we can test cmd='prepare' and cmd=None to check both cases
script_dir
=
tmp_path
/
"
test_prepare_env
"
spack_environments
=
"
spack-environments
"
mpsd_release_to_test
=
"
dev-23a
"
release_base_dir
=
script_dir
/
mpsd_release_to_test
# check that the test directory does not exist
assert
not
(
tmp_path
/
"
test_prepare_env
"
)
.
exists
()
assert
not
script_dir
.
exists
()
run
=
mod
.
builder
(
release
=
"
dev-23a
"
,
cmd
=
"
prepare
"
,
target_dir
=
str
(
tmp_path
/
"
test_prepare_env
"
),
skip_build_cache
=
False
,
)
run
.
run
()
mod
.
prepare_environment
(
mpsd_release
=
mpsd_release_to_test
,
script_dir
=
str
(
script_dir
))
# wait for 20 seconds for the git clone to finish
# time.sleep(20)
# check if the directory now is created
assert
(
tmp_path
/
"
test_prepare_env
"
)
.
exists
()
assert
release_base_dir
.
exists
()
# check for spack-environments directory
assert
os
.
listdir
(
str
(
tmp_path
/
"
test_prepare_env
"
))
==
[
"
spack-environments
"
]
# check if the git branch is correctl checked out
assert
spack_environments
in
os
.
listdir
(
str
(
release_base_dir
))
# check if the git branch is correctl
y
checked out
assert
(
subprocess
.
run
(
f
"
cd
{
str
(
tmp_path
/
'
test_prepare_env
/spack
-
environments
'
)
}
&& git branch
"
,
f
"
cd
{
str
(
release_base_dir
/
spack
_
environments
)
}
&& git branch
"
,
shell
=
True
,
capture_output
=
True
,
)
.
stdout
.
decode
(
"
utf-8
"
)
.
split
(
"
\n
"
)[
0
]
==
"
*
dev-23a
"
==
f
"
*
{
mpsd_release_to_test
}
"
)
# make sure running the command again raises ValueError
with
pytest
.
raises
(
ValueError
):
run
=
mod
.
builder
(
release
=
"
dev-23a
"
,
cmd
=
None
,
target_dir
=
str
(
tmp_path
/
"
test_prepare_env
"
),
skip_build_cache
=
False
,
)
run
.
run
()
# check that ValueError is not raised if skip_dir_check is True
run
=
mod
.
builder
(
release
=
"
dev-23a
"
,
cmd
=
None
,
target_dir
=
str
(
tmp_path
/
"
test_prepare_env
"
),
skip_build_cache
=
False
,
)
run
.
skip_dir_check
=
True
run
.
run
()
# clean up the temporary directory
shutil
.
rmtree
(
str
(
tmp_path
/
"
test_prepare_env
"
))
def
test_setup_log_cmd
(
tmp_path
):
...
...
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