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 if {{bash} in $shell_list} {
26 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
28 }
29
30 if {{ksh} in $shell_list} {
31 set tserr "_spack_pathadd()\nenvironment-modules"
32 # 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
34 }
35
36 if {{zsh} in $shell_list} {
37 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
39 }
40
41 if {{tcsh} in $shell_list} {
42 # not working on tcsh as variables used in spack alias are local variable, not environment variable
43 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
45 }
46
47 if {{fish} in $shell_list} {
48 set tsout "environment-modules"
49 # 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
51 }
52
53 } else {
54 send_user "\tSkipping source-sh tests over Spack scripts\n"
55 }
56
57 # test source-sh against Conda setup-env scripts if found installed for test
58 if {[file exists miniconda3/etc/profile.d/conda.sh]} {
59
60 if {{bash} in $shell_list} {
61 set tsout "function\n# conda environments:\n#\nbase \\* \\S*/miniconda3\n"
62 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
63 }
64
65 if {{ksh} in $shell_list} {
66 # not working on ksh as 'local' command is used
67 set tsout "__conda_activate\\\(\\\)"
68 set tserr ".*local: .*"
69 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
70 }
71
72 if {{zsh} in $shell_list} {
73 set tsout "__conda_activate\n# conda environments:\n#\nbase \\* \\S*/miniconda3\n"
74 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
75 }
76
77 if {{tcsh} in $shell_list} {
78 set tsout "# conda environments:\n#\nbase \\* \\S*/miniconda3\n"
79 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
80 }
81
82 if {{fish} in $shell_list} {
83 set tsout "# conda environments:\n#\nbase \\* \\S*/miniconda3\n"
84 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
85 }
86
87 } else {
88 send_user "\tSkipping source-sh tests over Conda scripts\n"
89 }
90
91
92 # test source-sh against OpenFOAM setup-env scripts if found installed for test
93 if {[file exists OpenFOAM-dev/etc/bashrc]} {
94
95 if {{bash} in $shell_list} {
96 set tsout function
97 set tserr OpenFOAM-dev
98 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
99 }
100
101 # sh script does not correctly detect installation path with ksh shell
102
103 if {{zsh} in $shell_list} {
104 set tsout _foamParams
105 set tserr OpenFOAM-dev
106 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
107 }
108
109 if {{tcsh} in $shell_list} {
110 set tsout OpenFOAM-dev
111 testall_cmd tcsh "module use \"$testsuite_modpath.3\"\; module load source-sh/openfoam\; foamVersion\; module unload source-sh\; test -n \"\$PATH\"" $tsout {} 0
112 }
113
114 # no setup-env script provided for fish shell
115
116 } else {
117 send_user "\tSkipping source-sh tests over OpenFOAM scripts\n"
118 }
119
120
121 #
122 # Clean up variables used in this test case
123 #
124
125 reset_test_env
126
127 # vim:set tabstop=3 shiftwidth=3 expandtab autoindent: