diff options
author | Harmen Stoppels <harmenstoppels@gmail.com> | 2021-10-11 12:56:03 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-11 06:56:03 -0400 |
commit | c0c9ab113e0078c53e60df6cb7cb064e6f92c45b (patch) | |
tree | b10e103772fef1571d63756cbe4a7d93784f314b /share | |
parent | f28b08bf026169d94e4e1bee9874b55888762515 (diff) | |
download | spack-c0c9ab113e0078c53e60df6cb7cb064e6f92c45b.tar.gz spack-c0c9ab113e0078c53e60df6cb7cb064e6f92c45b.tar.bz2 spack-c0c9ab113e0078c53e60df6cb7cb064e6f92c45b.tar.xz spack-c0c9ab113e0078c53e60df6cb7cb064e6f92c45b.zip |
Add `spack env activate --temp` (#25388)
Creates an environment in a temporary directory and activates it, which
is useful for a quick ephemeral environment:
```
$ spack env activate -p --temp
[spack-1a203lyg] $ spack add zlib
==> Adding zlib to environment /tmp/spack-1a203lyg
==> Updating view at /tmp/spack-1a203lyg/.spack-env/view
```
Diffstat (limited to 'share')
-rwxr-xr-x | share/spack/qa/setup-env-test.fish | 8 | ||||
-rwxr-xr-x | share/spack/qa/setup-env-test.sh | 8 | ||||
-rwxr-xr-x | share/spack/spack-completion.bash | 2 |
3 files changed, 15 insertions, 3 deletions
diff --git a/share/spack/qa/setup-env-test.fish b/share/spack/qa/setup-env-test.fish index 585b45bb9c..5cd257aa86 100755 --- a/share/spack/qa/setup-env-test.fish +++ b/share/spack/qa/setup-env-test.fish @@ -333,7 +333,7 @@ spt_contains " spack env list " spack env list --help title 'Testing `spack env activate`' spt_contains "No such environment:" spack env activate no_such_environment -spt_contains "usage: spack env activate " spack env activate +spt_contains "env activate requires an environment " spack env activate spt_contains "usage: spack env activate " spack env activate -h spt_contains "usage: spack env activate " spack env activate --help @@ -360,6 +360,12 @@ echo "Testing 'despacktivate'" despacktivate is_not_set SPACK_ENV +echo "Testing 'spack env activate --temp'" +spack env activate --temp +is_set SPACK_ENV +spack env deactivate +is_not_set SPACK_ENV + # # NOTE: `--prompt` on fish does nothing => currently not implemented. # diff --git a/share/spack/qa/setup-env-test.sh b/share/spack/qa/setup-env-test.sh index bf3bfe63f3..88e30aefeb 100755 --- a/share/spack/qa/setup-env-test.sh +++ b/share/spack/qa/setup-env-test.sh @@ -137,7 +137,7 @@ contains " spack env list " spack env list --help title 'Testing `spack env activate`' contains "No such environment:" spack env activate no_such_environment -contains "usage: spack env activate " spack env activate +contains "env activate requires an environment " spack env activate contains "usage: spack env activate " spack env activate -h contains "usage: spack env activate " spack env activate --help @@ -173,3 +173,9 @@ echo "Testing 'despacktivate'" despacktivate is_not_set SPACK_ENV is_not_set SPACK_OLD_PS1 + +echo "Testing 'spack env activate --temp'" +spack env activate --temp +is_set SPACK_ENV +spack env deactivate +is_not_set SPACK_ENV
\ No newline at end of file diff --git a/share/spack/spack-completion.bash b/share/spack/spack-completion.bash index 33553d374f..c64495e1d6 100755 --- a/share/spack/spack-completion.bash +++ b/share/spack/spack-completion.bash @@ -911,7 +911,7 @@ _spack_env() { _spack_env_activate() { if $list_options then - SPACK_COMPREPLY="-h --help --sh --csh --fish -v --with-view -V --without-view -d --dir -p --prompt" + SPACK_COMPREPLY="-h --help --sh --csh --fish -v --with-view -V --without-view -p --prompt --temp -d --dir" else _environments fi |