diff --git a/cc.sh b/cc.sh index 4156eed..059ab87 100755 --- a/cc.sh +++ b/cc.sh @@ -32,17 +32,6 @@ unset IFS # NOTE: Depending on your editor this may look empty, but it is not. readonly lsep='' -# This is an array of environment variables that need to be set before -# the script runs. They are set by routines in spack.build_environment -# as part of the package installation process. -readonly params="\ -SPACK_COMPILER_WRAPPER_PATH -SPACK_DEBUG_LOG_DIR -SPACK_DEBUG_LOG_ID -SPACK_SHORT_SPEC -SPACK_SYSTEM_DIRS -SPACK_MANAGED_DIRS" - # Optional parameters that aren't required to be set # Boolean (true/false/custom) if we want to add debug flags @@ -212,12 +201,13 @@ if eval "[ \"\${*#*${lsep}}\" != \"\$*\" ]"; then die "Compiler command line contains our separator ('${lsep}'). Cannot parse." fi -# ensure required variables are set -for param in $params; do - if eval "test -z \"\${${param}:-}\""; then - die "Spack compiler must be run from Spack! Input '$param' is missing." - fi -done +# Ensure required variables are set +: "${SPACK_COMPILER_WRAPPER_PATH:?Error: the compiler wrapper must be invoked from Spack}" +: "${SPACK_DEBUG_LOG_DIR:?Error: the compiler wrapper must be invoked from Spack}" +: "${SPACK_DEBUG_LOG_ID:?Error: the compiler wrapper must be invoked from Spack}" +: "${SPACK_SHORT_SPEC:?Error: the compiler wrapper must be invoked from Spack}" +: "${SPACK_SYSTEM_DIRS:?Error: the compiler wrapper must be invoked from Spack}" +: "${SPACK_MANAGED_DIRS:?Error: the compiler wrapper must be invoked from Spack}" # eval this because SPACK_MANAGED_DIRS and SPACK_SYSTEM_DIRS are inputs we don't wanna loop over. # moving the eval inside the function would eval it every call. diff --git a/test/run.sh b/test/run.sh index a59b0a9..af58b3e 100644 --- a/test/run.sh +++ b/test/run.sh @@ -358,8 +358,8 @@ test_no_wrapper_environment() { fail "cc with no env unexpectedly exited 0" fi case "$_out" in - *"Spack compiler must be run from Spack"*) ;; - *) fail "expected 'Spack compiler must be run from Spack' in: $_out" ;; + *"compiler wrapper must be invoked from Spack"*) ;; + *) fail "expected 'compiler wrapper must be invoked from Spack' in: $_out" ;; esac }