File: 080-args.exp

package info (click to toggle)
modules 5.6.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 23,036 kB
  • sloc: exp: 79,659; sh: 6,142; tcl: 5,900; makefile: 1,493; ansic: 474; python: 265; csh: 202; perl: 47; ruby: 44; lisp: 13
file content (177 lines) | stat: -rw-r--r-- 6,628 bytes parent folder | download | duplicates (2)
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
##############################################################################
#   Modules Revision 3.0
#   Providing a flexible user environment
#
#   File:       modules.00-init/%M%
#   Revision:       %I%
#   First Edition:  2018/03/20
#   Last Mod.:      %U%, %G%
#
#   Authors:        Xavier Delaruelle, xavier.delaruelle@cea.fr
#
#   Description:    Testuite testsequence
#   Command:
#   Sub-Command:
#
#   Comment:    %C{
#           Check handling of argument strings on all shells
#       }C%
#
##############################################################################

set modfile "$env(TESTSUITEDIR)/modulefiles.2/putsvar"

set err_emptymod "$error_msgs: Invalid empty module name"
set err_emptydir "$error_msgs: Invalid empty directory name"
set err_locatemod "$error_msgs: Unable to locate a modulefile for '{foo bar}'"
set err_locatemod2 "$error_msgs: Unable to locate a modulefile for '{foo\\\\\ bar}'"
set err_locatemod3 "$error_msgs: Unable to locate a modulefile for '\$foo'"
set err_locatemod4 "$error_msgs: Unable to locate a modulefile for '\\\$foo'"
set err_locatemod5 "$error_msgs: Unable to locate a modulefile for '\\\\\\\$foo'"
set err_locatemod6 "$error_msgs: Unable to locate a modulefile for '\"\"'"
set err_locatemod7 "$error_msgs: Unable to locate a modulefile for ''''"
set usage_msg "^Modules Release \\S+ (\\S+).*"

set err_emptymod_re "(envmodule: )?$err_emptymod"
set err_emptydir_re "(envmodule: )?$err_emptydir"
set err_locatemod_re "(envmodule: )?$err_locatemod"
set err_locatemod2_re "(envmodule: )?$err_locatemod2"
set err_locatemod3_re "(envmodule: )?$err_locatemod3"
set err_locatemod4_re "(envmodule: )?$err_locatemod4"
set err_locatemod5_re "(envmodule: )?$err_locatemod5"
set err_locatemod6_re "(envmodule: )?$err_locatemod6"
set err_locatemod7_re "(envmodule: )?$err_locatemod7"

#
# The tests
#

if {$verbose} {
   send_user "\tChecking handling of argument strings\n"
}

set foo ":/path/to/dir1"
set bar "/path/to/dir3"
if {$verbose} {
    send_user "\tSetup FOO = '$foo'\n"
    send_user "\tSetup BAR = '$bar'\n"
}
set env(FOO) "$foo"
set env(BAR) "$bar"

for {set i 0} {$i < 2} {incr i} {

# do the tests twice, second time with a quarantine setup
# to check quarantine mechanism does not alter argument handling
if {$i == 1} {
   # skip tests with quarantine enabled if space character found in install path
   if {[string first { } $install_libexecdir] != -1} {
      send_user "\tSkip quarantine mechanism test as installation path is not compliant with it\n"
      break
   }
   if {$verbose} {
       send_user "\tSetup MODULES_RUN_QUARANTINE = 'FOO'\n"
   }
   set env(MODULES_RUN_QUARANTINE) "FOO"
}

foreach shell $shell_list {
   testall_cmd "$shell" "module use \"\"" "" $err_emptydir 1
   testall_cmd "$shell" "module load ''" "" $err_emptymod 1
   testall_cmd "$shell" "module load \\\"\\\"" "" $err_locatemod6 1
   testall_cmd "$shell" "module load \\'\\'" "" $err_locatemod7 1
   testall_cmd "$shell" "module load \"foo bar\"" "" $err_locatemod 1
   testall_cmd "$shell" "module load foo\\ bar" "" $err_locatemod 1
   testall_cmd "$shell" "module load \\\$foo" "" $err_locatemod3 1
   testall_cmd_re "$shell" "module" "" $usage_msg 0
   testall_cmd_re "$shell" "module " "" $usage_msg 0
   testall_cmd_re "$shell" "module \"\"" "" $usage_msg 0
   testall_cmd_re "$shell" "module \"\" \"\"" "" $usage_msg 0
   testall_cmd "$shell" "module append-path -d \" \" FOO /path/to/dir2;module source $modfile" "" "$foo /path/to/dir2" 0
   testall_cmd "$shell" "module append-path -d ' ' FOO /path/to/dir2;module source $modfile" "" "$foo /path/to/dir2" 0
   testall_cmd "$shell" "module append-path FOO \"\$BAR\";module source $modfile" "" "$foo:$bar" 0
   testall_cmd "$shell" "module append-path FOO \\\$foo;module source $modfile" "" "$foo:\$foo" 0
   testall_cmd "$shell" "module append-path --duplicates FOO \"\";module source $modfile" "" "$foo:" 0
   testall_cmd "$shell" "module remove-path FOO \"\";module source $modfile" "" "/path/to/dir1" 0
}

# ensure colored output is disabled for CMake tests
setenv_var CLICOLOR 0
foreach shell $othlang_list {
   switch -- $shell {
      r {
         set postmsg "\nError: \nExecution halted"
      }
      cmake {
         set postmsg "\nCMake Error at testsuite/bin/install_test_cmake:115 \\\(message\\\):\n\n"
      }
      default {
         set postmsg {}
      }
   }

   testall_cmd_re "$shell" "use," "" $err_emptydir_re$postmsg 1
   testall_cmd_re "$shell" "load," "" $err_emptymod_re$postmsg 1
   # langs swallow " differently
   switch -- $shell {
      {perl} - {ruby} - {r} {
         testall_cmd_re "$shell" "load,\"\"" "" $err_emptymod_re$postmsg 1
      }
      default {
         testall_cmd_re "$shell" "load,\"\"" "" $err_locatemod6_re$postmsg 1
      }
   }
   testall_cmd_re "$shell" "load,''" "" $err_locatemod7_re$postmsg 1
   testall_cmd_re "$shell" "load,foo bar" "" $err_locatemod_re$postmsg 1
   testall_cmd_re "$shell" "load,foo\\ bar" "" $err_locatemod2_re$postmsg 1
   # langs swallow \$ differently
   switch -- $shell {
      {tcl} - {python} - {cmake} - {pwsh} {
         testall_cmd_re "$shell" "load,\\\$foo" "" $err_locatemod5_re$postmsg 1
      }
      default {
         testall_cmd_re "$shell" "load,\\\$foo" "" $err_locatemod4_re$postmsg 1
      }
   }
   testall_cmd_re "$shell" "NOARG" "" $usage_msg 0
   if {$install_ml eq {y}} {
      testall_cmd_re "$shell" "ml:NOARG" "" "($no_loaded|$cur_loaded.*)" 0 1
   }
   testall_cmd_re "$shell" "" "" $usage_msg 0
   testall_cmd_re "$shell" "," "" $usage_msg 0

   switch -- $shell {
      cmake {
         set premsg "(CMake Warning .*\n)?"
      }
      default {
         set premsg {}
      }
   }
   testall_cmd_re "$shell" "append-path,-d, ,FOO,/path/to/dir2:source,$modfile" "" "$premsg$foo /path/to/dir2" 0
   # langs swallow \$ differently
   switch -- $shell {
      tcl - pwsh {
         testall_cmd_re "$shell" "append-path,FOO,\\\$foo:source,$modfile" "" "$foo:\\\\\\\$foo" 0
      }
      python {
         testall_cmd_re "$shell" "append-path,FOO,\\\$foo:source,$modfile" "" "(<string>:3: SyntaxWarning: invalid escape sequence '\\\\\\$'\\n)?$foo:\\\\\\\$foo" 0
      }
      default {
         testall_cmd_re "$shell" "append-path,FOO,\\\$foo:source,$modfile" "" "$foo:\\\$foo" 0
      }
   }
   testall_cmd_re "$shell" "append-path,--duplicates,FOO,:source,$modfile" "" "$foo:" 0
   testall_cmd_re "$shell" "remove-path,FOO,:source,$modfile" "" "/path/to/dir1" 0
}
unsetenv_var CLICOLOR

}

#
#  Clean up variables used in this test case
#

reset_test_env

# vim:set tabstop=3 shiftwidth=3 expandtab autoindent: