|
22 | 22 | # test source-sh against Spack setup-env scripts if found installed for test |
23 | 23 | if {[file exists spack/share/spack/setup-env.sh]} { |
24 | 24 |
|
| 25 | +# Spack reports on stderr the warnings raised when loading its package |
| 26 | +# repository (like a SyntaxWarning from a package file on recent Python |
| 27 | +# versions), which is not what is tested here: drop these lines |
| 28 | +proc testall_cmd_spack {test_shell cmd answer anserr exitval} { |
| 29 | + _test_sub $test_shell $cmd |
| 30 | + set ::comp_error [regsub -all -line {^==> Warning: .*(\n|$)}\ |
| 31 | + $::comp_error {}] |
| 32 | + if {[_test_out $test_shell $cmd $answer fail]\ |
| 33 | + && [_test_err $test_shell $cmd $anserr fail]\ |
| 34 | + && [_test_exit $test_shell $cmd $exitval fail]} { |
| 35 | + _test_ok $test_shell $cmd |
| 36 | + } |
| 37 | +} |
| 38 | + |
25 | 39 | if {{bash} in $shell_list} { |
26 | 40 | set tsout "function\nenvironment-modules" |
27 | | - testall_cmd bash "module use \"$testsuite_modpath.3\"\; module load source-sh/spack\; type -t _spack_pathadd && spack list environment-modules\; module unload source-sh\; test -n \"\$PATH\"" $tsout {} 0 |
| 41 | + testall_cmd_spack bash "module use \"$testsuite_modpath.3\"\; module load source-sh/spack\; type -t _spack_pathadd && spack list environment-modules\; module unload source-sh\; test -n \"\$PATH\"" $tsout {} 0 |
28 | 42 | } |
29 | 43 |
|
30 | 44 | if {{ksh} in $shell_list} { |
31 | 45 | set tserr "_spack_pathadd()\nenvironment-modules" |
32 | 46 | # need to manually specify SPACK_ROOT prior script evaluation for ksh |
33 | | - testall_cmd ksh "module use \"$testsuite_modpath.3\"\; export SPACK_ROOT=spack\; module load source-sh/spack\; typeset +f _spack_pathadd && spack list environment-modules\; module unload source-sh\; test -n \"\$PATH\"" $tserr {} 0 |
| 47 | + testall_cmd_spack ksh "module use \"$testsuite_modpath.3\"\; export SPACK_ROOT=spack\; module load source-sh/spack\; typeset +f _spack_pathadd && spack list environment-modules\; module unload source-sh\; test -n \"\$PATH\"" $tserr {} 0 |
34 | 48 | } |
35 | 49 |
|
36 | 50 | if {{zsh} in $shell_list} { |
37 | 51 | set tsout "_spack_pathadd\nenvironment-modules" |
38 | | - testall_cmd zsh "module use \"$testsuite_modpath.3\"\; module load source-sh/spack\; typeset +f _spack_pathadd && spack list environment-modules\; module unload source-sh\; test -n \"\$PATH\"" $tsout {} 0 |
| 52 | + testall_cmd_spack zsh "module use \"$testsuite_modpath.3\"\; module load source-sh/spack\; typeset +f _spack_pathadd && spack list environment-modules\; module unload source-sh\; test -n \"\$PATH\"" $tsout {} 0 |
39 | 53 | } |
40 | 54 |
|
41 | 55 | if {{tcsh} in $shell_list} { |
42 | 56 | # not working on tcsh as variables used in spack alias are local variable, not environment variable |
43 | 57 | set tserr "_spack_share_dir: Undefined variable." |
44 | | - testall_cmd tcsh "module use \"$testsuite_modpath.3\"\; module load source-sh/spack\; spack list environment-modules\; module unload source-sh\; test -n \"\$PATH\"" {} $tserr 1 |
| 58 | + testall_cmd_spack tcsh "module use \"$testsuite_modpath.3\"\; module load source-sh/spack\; spack list environment-modules\; module unload source-sh\; test -n \"\$PATH\"" {} $tserr 1 |
45 | 59 | } |
46 | 60 |
|
47 | 61 | if {{fish} in $shell_list} { |
48 | 62 | set tsout "environment-modules" |
49 | 63 | # module command seems superseded by spack definition on fish: cannot test unload |
50 | | - testall_cmd fish "module use \"$testsuite_modpath.3\"\; module load source-sh/spack\; functions -q spack_pathadd\; and spack list environment-modules" $tsout {} 0 |
| 64 | + testall_cmd_spack fish "module use \"$testsuite_modpath.3\"\; module load source-sh/spack\; functions -q spack_pathadd\; and spack list environment-modules" $tsout {} 0 |
51 | 65 | } |
52 | 66 |
|
| 67 | +rename testall_cmd_spack {} |
| 68 | + |
53 | 69 | } else { |
54 | 70 | send_user "\tSkipping source-sh tests over Spack scripts\n" |
55 | 71 | } |
|
0 commit comments