summaryrefslogtreecommitdiff
path: root/share/spack/qa/setup-env-test.sh
diff options
context:
space:
mode:
authorHarmen Stoppels <harmenstoppels@gmail.com>2021-10-28 20:39:25 +0200
committerGitHub <noreply@github.com>2021-10-28 11:39:25 -0700
commit6d030ba1372f7fc1de3f3d8d87a47f203ef036f8 (patch)
tree26ae4483acb57bd1cd04ad08ec4471445e27b875 /share/spack/qa/setup-env-test.sh
parent87e456d59cf43700c8ed257d957794d2c083082a (diff)
downloadspack-6d030ba1372f7fc1de3f3d8d87a47f203ef036f8.tar.gz
spack-6d030ba1372f7fc1de3f3d8d87a47f203ef036f8.tar.bz2
spack-6d030ba1372f7fc1de3f3d8d87a47f203ef036f8.tar.xz
spack-6d030ba1372f7fc1de3f3d8d87a47f203ef036f8.zip
Deactivate previous env before activating new one (#25409)
* Deactivate previous env before activating new one Currently on develop you can run `spack env activate` multiple times to switch between environments, but they leave traces, even though Spack only supports one active environment at a time. Currently: ```console $ spack env create a $ spack env create b $ spack env activate -p a [a] $ spack env activate -p b [b] [a] $ spack env activate -p b [a] [b] [a] $ spack env activate -p a [a] [b] [c] $ echo $MANPATH | tr ":" "\n" /path/to/environments/a/.spack-env/view/share/man /path/to/environments/a/.spack-env/view/man /path/to/environments/b/.spack-env/view/share/man /path/to/environments/b/.spack-env/view/man ``` This PR fixes that: ```console $ spack env activate -p a [a] $ spack env activate -p b [b] $ spack env activate -p a [a] $ echo $MANPATH | tr ":" "\n" /path/to/environments/a/.spack-env/view/share/man /path/to/environments/a/.spack-env/view/man ```
Diffstat (limited to 'share/spack/qa/setup-env-test.sh')
-rwxr-xr-xshare/spack/qa/setup-env-test.sh12
1 files changed, 9 insertions, 3 deletions
diff --git a/share/spack/qa/setup-env-test.sh b/share/spack/qa/setup-env-test.sh
index 88e30aefeb..bddf7ca1af 100755
--- a/share/spack/qa/setup-env-test.sh
+++ b/share/spack/qa/setup-env-test.sh
@@ -70,13 +70,13 @@ b_module=$(spack -m module tcl find b)
# Create a test environment for testing environment commands
echo "Creating a mock environment"
spack env create spack_test_env
-test_env_location=$(spack location -e spack_test_env)
+spack env create spack_test_2_env
# Ensure that we uninstall b on exit
cleanup() {
echo "Removing test environment before exiting."
spack env deactivate 2>&1 > /dev/null
- spack env rm -y spack_test_env
+ spack env rm -y spack_test_env spack_test_2_env
title "Cleanup"
echo "Removing test packages before exiting."
@@ -178,4 +178,10 @@ 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
+is_not_set SPACK_ENV
+
+echo "Testing spack env activate repeatedly"
+spack env activate spack_test_env
+spack env activate spack_test_2_env
+contains "spack_test_2_env" sh -c 'echo $PATH'
+does_not_contain "spack_test_env" sh -c 'echo $PATH'