File: 090-source.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 (137 lines) | stat: -rw-r--r-- 3,941 bytes parent folder | download
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
##############################################################################
#   Modules Revision 3.0
#   Providing a flexible user environment
#
#   File:		modules.70-maint/%M%
#   Revision:		%I%
#   First Edition:	2017/04/17
#   Last Mod.:		%U%, %G%
#
#   Authors:		Xavier Delaruelle, xavier.delaruelle@cea.fr
#
#   Description:	Testuite testsequence
#   Command:		source
#   Modulefiles:	rctosource, rcnomagic, nonexistent
#   Sub-Command:
#
#   Comment:	%C{
#			Tests the module command 'source'
#		}C%
#
##############################################################################

#
#  Test variables
#

set module_1 "$env(TESTSUITEDIR)/home/rctosource"
set module_2 "$env(TESTSUITEDIR)/home/rcnomagic"
set module_3 "$env(TESTSUITEDIR)/home/nonexistent"
set module_4 "$env(TESTSUITEDIR)/modulefiles/bad2/body"

lappend ans [list set testsuite yes]
set err_csh "$error_msgs: File $module_3 does not exist"

lappend ans2 [list set testsuite yes]
lappend ans2 [list ERR]
set err_csh2 [msg_moderr "$msg_invcmdname \"bad-command\"" {bad-command} $module_4 29 {  }]

#
#  test sourcing rc file with regular module-specific magic cookie
#
testouterr_cmd "csh" "source $module_1" $ans ""

skip_if_quick_mode

#
# test with relative file path
#
testouterr_cmd sh {source testsuite/home/rctosource} $ans {}

#
#  test sourcing rc file with no module-specific magic cookie
#
testouterr_cmd "csh" "source $module_2" ERR $err_magic'$module_2'\n$err_contact

#
# test with nonexistent file
#
testouterr_cmd "csh" "source $module_3" "ERR" "$err_csh"

#
# test with broken file
# env is set until reaching Tcl breaking point
testouterr_cmd "csh" "source $module_4" $ans2 "$err_csh2"


# test file path precedence over available modulefile
# skip this test in the following situation:
# - when coverage is enabled, as the cwd error will be caught by coverage tool
#   rather than getAbsolutePath procedure. The next test (pwd supersede) enable
#   coverage check of getAbsolutePath
# - when running on Tcl 8.5 where test outputs are saved in files located in
#   current working directory
if {![info exists env(COVERAGE)] && [cmpversion $tclsh_version 8.6] > -1} {
    setenv_path_var MODULEPATH $modpath.2
    cd $env(TESTSUITEDIR)/modulefiles.memcache
    # change MODULECMD for the test to make it an absolute path name
    set MODULECMD $env(TESTSUITEDIR)/../$MODULECMD

    set ans [list]
    lappend ans [list set ts ok]
    testouterr_cmd sh {source foo/1} $ans {}

    # move back to testsuite working directory
    cd $ORIG_CWD
    set MODULECMD $ORIG_MODULECMD
}

# test existing modulefile
setenv_path_var MODULEPATH $modpath.memcache
set ans [list]
lappend ans [list set ts ok]
testouterr_cmd sh {source foo/1} $ans {}

# test unexisting modulefile
testouterr_cmd sh {source foo/unk} ERR $err_path'foo/unk'

# source filepath then modulefile
set ans [list]
lappend ans [list set testsuite yes]
lappend ans [list set ts ok]
testouterr_cmd sh "source $module_1 foo/1" $ans {}

# source nonexistent filepath then modulefile
set tserr "$error_msgs: File $module_3 does not exist"
testouterr_cmd sh "source $module_3 foo/1" ERR $tserr

# test boolean variant specified on command-line
setenv_var MODULES_ADVANCED_VERSION_SPEC 1
setenv_path_var MODULEPATH $modpath.3
setenv_var TESTSUITE_VARIANT bool8
set ans [list]
lappend ans [list set TS1 foo=1]
lappend ans [list set TS2 true]
lappend ans [list set TS0 foo]
testouterr_cmd sh {source variant/1.0 +foo} $ans {}
set ans [list]
lappend ans [list set TS1 foo=0]
lappend ans [list set TS2 false]
lappend ans [list set TS0 foo]
testouterr_cmd sh {source variant/1.0 -foo} $ans {}

# test other variant specification
setenv_var TESTSUITE_VARIANT 2
set ans [list]
lappend ans [list set TS1 FOO=val2]
lappend ans [list set TS0 FOO]
testouterr_cmd sh {source variant @1.0 FOO=val2} $ans {}
unsetenv_var TESTSUITE_VARIANT
unsetenv_var MODULES_ADVANCED_VERSION_SPEC


#
#  Cleanup
#

reset_test_env