Debian Codegraph @

testsuite/install.00-init/090-sh-to-mod.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: 2020/04/25
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 modulefiles generated by 'sh-to-mod' sub-command
18 # }C%
19 #
20 ##############################################################################
21
22 set shtomod_supported_shells [list sh bash ksh zsh dash ksh93 fish csh tcsh]
23 set shtomod_supported_fshells [list sh bash ksh zsh fish csh tcsh]
24 set testscriptsh testsuite/example/sh-to-mod.sh
25 set testscriptcsh testsuite/example/sh-to-mod.csh
26 set testscriptfish testsuite/example/sh-to-mod.fish
27 set testscriptshargs "v\\\'l val\\\"e val\\\\\\\"e \"\""
28 set testscriptshargs_csh "v\'\"\\\'\"\'l val\\\"e val\\\\\\\"e \"\""
29
30 # what are the installed shells
31 set shtomod_avail_shells [list]
32 foreach sh $shtomod_supported_shells {
33 set shbin [lindex [auto_execok $sh] 0]
34 if {$shbin ne {}} {
35 # mksh flavor of ksh is not supported
36 # sh from FreeBSD is not supported too
37 if {($sh ne {ksh} || !$ksh_is_mksh) && ($sh ne {sh} || $os_name ne {freebsd})} {
38 lappend shtomod_avail_shells $sh
39 }
40 if {[lsearch -exact $shtomod_supported_fshells $sh] != -1} {
41 lappend shtomod_avail_fshells $sh
42 }
43 }
44 }
45
46 set testshenvcmds "echo \"\$FOOCB:\$FOOEM:\$FOOSP:\$FOOWC:\$FOOARG1:\$FOOARG2:\$FOOARG3:\$FOOARG4\"\;"
47 append testshenvcmds "alfoo\; alcb\; alsp\;"
48 append testshenvcmds "funcnl\; funccb\; funcsp\; funcwc\;"
49
50 set testshenvcmds_dash "echo \"\$FOOCB:\$FOOEM:\$FOOSP:\$FOOWC:\$FOOARG1:\$FOOARG2:\$FOOARG3:\$FOOARG4\"\;"
51 append testshenvcmds_dash "alfoo\; alcb\; alsp\;"
52
53 # also update testenvcmds in testsuite/bin/install_test_csh script
54 set testshenvcmds_csh "echo \$\{FOOCB\}:\$\{FOOEM\}:\$\{FOOSP\}:\$\{FOOWC\}:\$\{FOOARG1\}:\$\{FOOARG2\}:\$\{FOOARG3\}:\$\{FOOARG4\}\;"
55 set testshenvcmds_csh "alfoo\; alcb\; alsp\;"
56
57 if {$verbose} {
58 send_user "\tChecking modulefiles generated by 'sh-to-mod' sub-command\n"
59 }
60
61 set tsout "va{ue::value :va*ue:v'l:val\"e:val\\\"e:\n"
62 append tsout "Release\nf{o\nf\"o\nb\\\"r\nf'o\n"
63 append tsout "foo\nbar\nf{o\nf\"o\nb\\\"r\nf'o\nsource-sh"
64
65 # no argument passed to script nor function defined with dash
66 set tsout_dash "va{ue::value :va*ue::::\n"
67 append tsout_dash "Release\nf{o\nf\"o\nb\\\"r\nf'o"
68
69 # no function defined with csh
70 set tsout_csh "va{ue::value :va*ue:v'l:val\"e:val\\\"e:\n"
71 append tsout_csh "Release\nf{o\nf\"o\nb\\\"r\nf'o"
72
73 foreach sh $shtomod_avail_shells {
74 # test modulefile definition also cope with other shells
75 foreach fsh $shtomod_avail_fshells {
76 if {$fsh eq {fish} || $sh eq {fish}} {
77 # no shell mix for fish, as a function or alias defined for a sh shell will not work on fish
78 if {$fsh eq {fish} && $sh eq {fish}} {
79 if {!$fish_version_ge31} {
80 send_user "\tSkipping sh-to-mod test from fish shell as output redirection of an evaluated test command does not work on Fish <3.1\n"
81 } else {
82 testall_cmd $fsh "module sh-to-mod $sh $testscriptfish $testscriptshargs 2>shtomod\; module load ./shtomod\; $testshenvcmds" $tsout {} 0
83 }
84 }
85 } elseif {$fsh eq {csh} || $fsh eq {tcsh} || $sh eq {csh} || $sh eq {tcsh}} {
86 # no shell mix for csh, as a function or alias defined for a sh/fish shell will not work on csh
87 # disable test if wa277 is enabled as in this case csh module alias has no protection against special chars in output
88 if {($fsh eq {csh} || $fsh eq {tcsh}) && ($sh eq {csh} || $sh eq {tcsh}) && $install_wa277 eq {n}} {
89 set tserr [expr {$os_name in {darwin freebsd} ? {} : {tr: warning: an unescaped backslash at end of string is not portable}}]
90 testall_cmd $fsh "module sh-to-mod $sh $testscriptcsh $testscriptshargs_csh >& shtomod\; module load ./shtomod\; $testshenvcmds_csh" $tsout_csh $tserr 0
91 }
92 } elseif {$sh eq {dash} || ($sh eq {sh} && $sh_kind eq {dash})} {
93 testall_cmd $fsh "module sh-to-mod $sh $testscriptsh $testscriptshargs 2>shtomod\; module load ./shtomod\; $testshenvcmds_dash" $tsout_dash {} 0
94 } else {
95 testall_cmd $fsh "module sh-to-mod $sh $testscriptsh $testscriptshargs 2>shtomod\; module load ./shtomod\; $testshenvcmds" $tsout {} 0
96 }
97 file delete shtomod
98 }
99 }
100
101
102 #
103 # Clean up variables used in this test case
104 #
105
106 reset_test_env
107
108 # vim:set tabstop=3 shiftwidth=3 expandtab autoindent: