Debian Codegraph @

testsuite/modules.70-maint/090-source.exp

raw
1 ##############################################################################
2 # Modules Revision 3.0
3 # Providing a flexible user environment
4 #
5 # File: modules.70-maint/%M%
6 # Revision: %I%
7 # First Edition: 2017/04/17
8 # Last Mod.: %U%, %G%
9 #
10 # Authors: Xavier Delaruelle, [email protected]
11 #
12 # Description: Testuite testsequence
13 # Command: source
14 # Modulefiles: rctosource, rcnomagic, nonexistent
15 # Sub-Command:
16 #
17 # Comment: %C{
18 # Tests the module command 'source'
19 # }C%
20 #
21 ##############################################################################
22
23 #
24 # Test variables
25 #
26
27 set module_1 "$env(TESTSUITEDIR)/home/rctosource"
28 set module_2 "$env(TESTSUITEDIR)/home/rcnomagic"
29 set module_3 "$env(TESTSUITEDIR)/home/nonexistent"
30 set module_4 "$env(TESTSUITEDIR)/modulefiles/bad2/body"
31
32 lappend ans [list set testsuite yes]
33 set err_csh "$error_msgs: File $module_3 does not exist"
34
35 lappend ans2 [list set testsuite yes]
36 lappend ans2 [list ERR]
37 set err_csh2 [msg_moderr "$msg_invcmdname \"bad-command\"" {bad-command} $module_4 29 { }]
38
39 #
40 # test sourcing rc file with regular module-specific magic cookie
41 #
42 testouterr_cmd "csh" "source $module_1" $ans ""
43
44 skip_if_quick_mode
45
46 #
47 # test with relative file path
48 #
49 testouterr_cmd sh {source testsuite/home/rctosource} $ans {}
50
51 #
52 # test sourcing rc file with no module-specific magic cookie
53 #
54 testouterr_cmd "csh" "source $module_2" ERR $err_magic'$module_2'\n$err_contact
55
56 #
57 # test with nonexistent file
58 #
59 testouterr_cmd "csh" "source $module_3" "ERR" "$err_csh"
60
61 #
62 # test with broken file
63 # env is set until reaching Tcl breaking point
64 testouterr_cmd "csh" "source $module_4" $ans2 "$err_csh2"
65
66
67 # test file path precedence over available modulefile
68 # skip this test in the following situation:
69 # - when coverage is enabled, as the cwd error will be caught by coverage tool
70 # rather than getAbsolutePath procedure. The next test (pwd supersede) enable
71 # coverage check of getAbsolutePath
72 # - when running on Tcl 8.5 where test outputs are saved in files located in
73 # current working directory
74 if {![info exists env(COVERAGE)] && [cmpversion $tclsh_version 8.6] > -1} {
75 setenv_path_var MODULEPATH $modpath.2
76 cd $env(TESTSUITEDIR)/modulefiles.memcache
77 # change MODULECMD for the test to make it an absolute path name
78 set MODULECMD $env(TESTSUITEDIR)/../$MODULECMD
79
80 set ans [list]
81 lappend ans [list set ts ok]
82 testouterr_cmd sh {source foo/1} $ans {}
83
84 # move back to testsuite working directory
85 cd $ORIG_CWD
86 set MODULECMD $ORIG_MODULECMD
87 }
88
89 # test existing modulefile
90 setenv_path_var MODULEPATH $modpath.memcache
91 set ans [list]
92 lappend ans [list set ts ok]
93 testouterr_cmd sh {source foo/1} $ans {}
94
95 # test unexisting modulefile
96 testouterr_cmd sh {source foo/unk} ERR $err_path'foo/unk'
97
98 # source filepath then modulefile
99 set ans [list]
100 lappend ans [list set testsuite yes]
101 lappend ans [list set ts ok]
102 testouterr_cmd sh "source $module_1 foo/1" $ans {}
103
104 # source nonexistent filepath then modulefile
105 set tserr "$error_msgs: File $module_3 does not exist"
106 testouterr_cmd sh "source $module_3 foo/1" ERR $tserr
107
108 # test boolean variant specified on command-line
109 setenv_var MODULES_ADVANCED_VERSION_SPEC 1
110 setenv_path_var MODULEPATH $modpath.3
111 setenv_var TESTSUITE_VARIANT bool8
112 set ans [list]
113 lappend ans [list set TS1 foo=1]
114 lappend ans [list set TS2 true]
115 lappend ans [list set TS0 foo]
116 testouterr_cmd sh {source variant/1.0 +foo} $ans {}
117 set ans [list]
118 lappend ans [list set TS1 foo=0]
119 lappend ans [list set TS2 false]
120 lappend ans [list set TS0 foo]
121 testouterr_cmd sh {source variant/1.0 -foo} $ans {}
122
123 # test other variant specification
124 setenv_var TESTSUITE_VARIANT 2
125 set ans [list]
126 lappend ans [list set TS1 FOO=val2]
127 lappend ans [list set TS0 FOO]
128 testouterr_cmd sh {source variant @1.0 FOO=val2} $ans {}
129 unsetenv_var TESTSUITE_VARIANT
130 unsetenv_var MODULES_ADVANCED_VERSION_SPEC
131
132
133 #
134 # Cleanup
135 #
136
137 reset_test_env