summaryrefslogtreecommitdiff
path: root/share/spack/qa/setup-env-test.csh
blob: 39eb8545321a7d9dde6be73941c48e352dfe298f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/csh
#
# Copyright 2013-2024 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)

#
# This tests that Spack's setup-env.csh init script works.
#
# There are limited tests here so far, as we haven't ported the unit test
# functions we have for sh/bash/zsh/fish to csh.
#

# -----------------------------------------------------------------------
# Setup test environment and do some preliminary checks
# -----------------------------------------------------------------------

# find spack but don't call it SPACK_ROOT -- we want to ensure that
# setup-env.csh sets that.
set QA_DIR = `dirname $0`
set SPACK_DIR = `cd $QA_DIR/../../.. && pwd`

# Make sure no environment is active, and SPACK_ROOT is not set
unsetenv SPACK_ENV
unsetenv SPACK_ROOT

# Source setup-env.sh before tests
source "$SPACK_DIR/share/spack/setup-env.csh"

echo -n "SPACK_ROOT is set..."
if (! $?SPACK_ROOT) then
    echo "FAIL"
    echo "Error: SPACK_ROOT not set by setup-env.csh"
    exit 1
else
    echo "SUCCESS"
endif

echo -n "SPACK_ROOT is set correctly..."
if ("$SPACK_ROOT" != "$SPACK_DIR") then
    echo "FAIL"
    echo "Error: SPACK_ROOT not set correctly by setup-env.csh"
    echo "    Expected: '$SPACK_DIR'"
    echo "    Found:    '$SPACK_ROOT'"
    exit 1
else
    echo "SUCCESS"
endif

echo -n "spack is in the path..."
set spack_script = `which \spack`
if ("$spack_script" != "$SPACK_DIR/bin/spack") then
    echo "FAIL"
    echo "Error: could not find spack after sourcing."
    echo "    Expected: '$SPACK_DIR/bin/spack'"
    echo "    Found:    '$spack_script'"
    exit 1
else
    echo "SUCCESS"
endif

echo -n "spack is aliased to something after sourcing..."
set spack_alias = `which spack`
if ("$spack_alias" !~ 'spack: aliased to '*) then
    echo "FAIL"
    echo "Error: spack not aliased after sourcing."
    echo "    Expected: 'spack: aliased to [...]'"
    echo "    Found:    '$spack_alias'"
    exit 1
else
    echo "SUCCESS"
endif

echo "SUCCESS"
exit 0