diff --git a/cc.sh b/cc.sh index b888427..5aa71f1 100755 --- a/cc.sh +++ b/cc.sh @@ -34,17 +34,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 @@ -232,12 +221,15 @@ case "$*" in ;; esac -# 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 +_msg="Error: the compiler wrapper must be invoked from Spack" +: "${SPACK_COMPILER_WRAPPER_PATH:?$_msg}" +: "${SPACK_DEBUG_LOG_DIR:?$_msg}" +: "${SPACK_DEBUG_LOG_ID:?$_msg}" +: "${SPACK_SHORT_SPEC:?$_msg}" +: "${SPACK_SYSTEM_DIRS:?$_msg}" +: "${SPACK_MANAGED_DIRS:?$_msg}" +unset _msg # 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 8127170..7bf2e12 100755 --- a/test/run.sh +++ b/test/run.sh @@ -396,8 +396,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 }