Debian Codegraph @

testsuite/install.00-init/091-source-sh.exp

raw
1 ##############################################################################
2 # Modules Revision 3.0
3 # Providing a flexible user environment
4 #
5 # File: modules.00-init/%M%
6 # Revision: %I%
7 # First Edition: 2022/02/21
8 # Last Mod.: %U%, %G%
9 #
10 # Authors: Xavier Delaruelle, [email protected]
11 #
12 # Description: Testuite testsequence
13 # Command:
14 # Sub-Command:
15 #
16 # Comment: %C{
17 # Check source-sh modulefile command against external software
18 # }C%
19 #
20 ##############################################################################
21
22 # test source-sh against Spack setup-env scripts if found installed for test
23 if {[file exists spack/share/spack/setup-env.sh]} {
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
39 if {{bash} in $shell_list} {
40 set tsout "function\nenvironment-modules"
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
42 }
43
44 if {{ksh} in $shell_list} {
45 set tserr "_spack_pathadd()\nenvironment-modules"
46 # need to manually specify SPACK_ROOT prior script evaluation for ksh
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
48 }
49
50 if {{zsh} in $shell_list} {
51 set tsout "_spack_pathadd\nenvironment-modules"
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
53 }
54
55 if {{tcsh} in $shell_list} {
56 # not working on tcsh as variables used in spack alias are local variable, not environment variable
57 set tserr "_spack_share_dir: Undefined variable."
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
59 }
60
61 if {{fish} in $shell_list} {
62 set tsout "environment-modules"
63 # module command seems superseded by spack definition on fish: cannot test unload
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
65 }
66
67 rename testall_cmd_spack {}
68
69 } else {
70 send_user "\tSkipping source-sh tests over Spack scripts\n"
71 }
72
73 # test source-sh against Conda setup-env scripts if found installed for test
74 if {[file exists miniconda3/etc/profile.d/conda.sh]} {
75
76 if {{bash} in $shell_list} {
77 set tsout "function\n# conda environments:\n#\nbase \\* \\S*/miniconda3\n"
78 testall_cmd_re bash "module use \"$testsuite_modpath.3\"\; module load source-sh/conda\; type -t __conda_activate && conda env list\; module unload source-sh\; test -n \"\$PATH\"" $tsout {} 0
79 }
80
81 if {{ksh} in $shell_list} {
82 # not working on ksh as 'local' command is used
83 set tsout "__conda_activate\\\(\\\)"
84 set tserr ".*local: .*"
85 testall_cmd_re ksh "module use \"$testsuite_modpath.3\"\; module load source-sh/conda\; typeset +f __conda_activate && conda env list\; module unload source-sh\; test -n \"\$PATH\"" $tsout $tserr 127
86 }
87
88 if {{zsh} in $shell_list} {
89 set tsout "__conda_activate\n# conda environments:\n#\nbase \\* \\S*/miniconda3\n"
90 testall_cmd_re zsh "module use \"$testsuite_modpath.3\"\; module load source-sh/conda\; typeset +f __conda_activate && conda env list\; module unload source-sh\; test -n \"\$PATH\"" $tsout {} 0
91 }
92
93 if {{tcsh} in $shell_list} {
94 set tsout "# conda environments:\n#\nbase \\* \\S*/miniconda3\n"
95 testall_cmd_re tcsh "module use \"$testsuite_modpath.3\"\; module load source-sh/conda\; conda env list\; module unload source-sh\; test -n \"\$PATH\"" $tsout {} 0
96 }
97
98 if {{fish} in $shell_list} {
99 set tsout "# conda environments:\n#\nbase \\* \\S*/miniconda3\n"
100 testall_cmd_re fish "module use \"$testsuite_modpath.3\"\; module load source-sh/conda\; functions -q __fish_conda_env_commands\; and conda env list\; module unload source-sh\; test -n \"\$PATH\"" $tsout {} 0
101 }
102
103 } else {
104 send_user "\tSkipping source-sh tests over Conda scripts\n"
105 }
106
107
108 # test source-sh against OpenFOAM setup-env scripts if found installed for test
109 if {[file exists OpenFOAM-dev/etc/bashrc]} {
110
111 if {{bash} in $shell_list} {
112 set tsout function
113 set tserr OpenFOAM-dev
114 testall_cmd bash "module use \"$testsuite_modpath.3\"\; module load source-sh/openfoam\; type -t _foamDictionary_ && foamVersion\; module unload source-sh\; test -n \"\$PATH\"" $tsout $tserr 0
115 }
116
117 # sh script does not correctly detect installation path with ksh shell
118
119 if {{zsh} in $shell_list} {
120 set tsout _foamParams
121 set tserr OpenFOAM-dev
122 testall_cmd zsh "module use \"$testsuite_modpath.3\"\; module load source-sh/openfoam\; typeset +f _foamParams && foamVersion\; module unload source-sh\; test -n \"\$PATH\"" $tsout $tserr 0
123 }
124
125 if {{tcsh} in $shell_list} {
126 set tsout OpenFOAM-dev
127 testall_cmd tcsh "module use \"$testsuite_modpath.3\"\; module load source-sh/openfoam\; foamVersion\; module unload source-sh\; test -n \"\$PATH\"" $tsout {} 0
128 }
129
130 # no setup-env script provided for fish shell
131
132 } else {
133 send_user "\tSkipping source-sh tests over OpenFOAM scripts\n"
134 }
135
136
137 #
138 # Clean up variables used in this test case
139 #
140
141 reset_test_env
142
143 # vim:set tabstop=3 shiftwidth=3 expandtab autoindent: