Debian Codegraph @

testsuite/modules.70-maint/085-test.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/30
8 # Last Mod.: %U%, %G%
9 #
10 # Authors: Xavier Delaruelle, [email protected]
11 #
12 # Description: Testuite testsequence
13 # Command: test
14 # Modulefiles: test, bad
15 # Sub-Command:
16 #
17 # Comment: %C{
18 # Tests the module command 'test'
19 # }C%
20 #
21 ##############################################################################
22
23 # skip tests if implicit_default option could not be overridden
24 if {[is_config_locked implicit_default]} {
25 send_user "\tskipping tests as implicit_default could not be overridden\n"
26 } else {
27
28 # ensure avail tests have implicit default enabled
29 setenv_var MODULES_IMPLICIT_DEFAULT 1
30
31 set module "test/1.2"
32 set modulefile "$modpathre/$module"
33 set modulefile_full "$modpath/$module"
34 set modulefile_reld "$reldmodpath/$module"
35 set modulefile_reldd "$relddmodpath/$module"
36 set module2 "test/1.0"
37 set modulefile2 "$modpathre/$module2"
38 set module3 "test/2.0"
39 set modulefile3 "$modpathre/$module3"
40 set module4 "bad"
41 set modulefile4 "$modpathre/$module4"
42 set modulefile4nore "$modpath/$module4"
43 set module5 "bad2"
44 set modulefile5 "$modpathre/$module5"
45 set modulefile5nore "$modpath/$module5"
46 set modulefile5_full "$modpath/$module5/proc"
47 set modulefile5_reld "$reldmodpath/$module5/proc"
48 set modulefile5_reldd "$relddmodpath/$module5/proc"
49
50 set lin_test "Module Specific Test for "
51 set missing_test "$warn_msgs: Unable to find ModulesTest in "
52 set fail_test "Test result: FAIL"
53 set ok_test "Test result: PASS"
54
55 set custom { (procedure "ModulesTest" line 2)
56 invoked from within
57 "ModulesTest"}
58 set mod5_interr [escre [msg_moderr "$msg_invcmdname \"bad-command\"" bad-command $modulefile5nore/proc {} { } {} {} $custom]]
59 set mod4_interr "[escre [msg_moderr "$msg_invcmdname \"bad-command\"" bad-command $modulefile4nore/.modulerc 28 { }]]
60 $modlin
61 $lin_test$modulefile4/before:
62
63 [escre [msg_moderr "$msg_invcmdname \"bad-command\"" bad-command $modulefile4nore/before 26 { }]]
64 $modlin"
65
66 set module6 "NonExistent"
67 set mod6_err "$err_path'$module6'"
68
69 #
70 # The tests
71 #
72
73 # missing procedure
74 testouterr_cmd_re "sh" "test $module" "OK" "$modlin\n$lin_test$modulefile:\n\n$missing_test$modulefile.\n$modlin"
75
76 skip_if_quick_mode
77
78 # test with module passed as full path
79 testouterr_cmd_re "sh" "test $modulefile_full" "OK" "$modlin\n$lin_test$modulefile:\n\n$missing_test$modulefile.\n$modlin"
80 testouterr_cmd_re "sh" "test $modulefile_reld" "OK" "$modlin\n$lin_test$modulefile:\n\n$missing_test$modulefile.\n$modlin"
81 testouterr_cmd_re "sh" "test $modulefile_reldd" "OK" "$modlin\n$lin_test$modulefile:\n\n$missing_test$modulefile.\n$modlin"
82
83 # missing return value
84 testouterr_cmd_re "sh" "test $module2" "ERR" "$modlin\n$lin_test$modulefile2:\n\nTest_err\n$fail_test\n$modlin"
85
86 # test returns false
87 testouterr_cmd_re "sh" "test $module3" "ERR" "$modlin\n$lin_test$modulefile3:\n\nTest_err\n$fail_test\n$modlin"
88
89 # Set up the environment for test to return true
90 set env(TEST) 1
91
92 # test returns true
93 testouterr_cmd_re "sh" "test $module3" "OK" "$modlin\n$lin_test$modulefile3:\n\nTest_err\n$ok_test\n$modlin"
94
95 # Clean up the just changed environment
96 unset env(TEST)
97
98 # test with erroneous modulefile
99 testouterr_cmd_re "sh" "test $module4" "ERR" "$mod4_interr"
100
101 # test with erroneous ModulesTest proc in modulefile
102 testouterr_cmd_re "sh" "test $module5" "ERR" "$modlin\n$lin_test$modulefile5/proc:\n\n$mod5_interr\n$modlin"
103 # test with module passed as full path
104 testouterr_cmd_re "sh" "test $modulefile5_full" "ERR" "$modlin\n$lin_test$modulefile5/proc:\n\n$mod5_interr\n$modlin"
105 testouterr_cmd_re "sh" "test $modulefile5_reld" "ERR" "$modlin\n$lin_test$modulefile5/proc:\n\n$mod5_interr\n$modlin"
106 testouterr_cmd_re "sh" "test $modulefile5_reldd" "ERR" "$modlin\n$lin_test$modulefile5/proc:\n\n$mod5_interr\n$modlin"
107
108 # test on unexistant modulefile
109 testouterr_cmd "sh" "test $module6" "ERR" "$mod6_err"
110
111 # check error when implicit default is disabled
112 setenv_var MODULES_IMPLICIT_DEFAULT 0
113 testouterr_cmd sh "test $module5" ERR "$err_nodefault'$module5'"
114 setenv_var MODULES_IMPLICIT_DEFAULT 1
115
116 #
117 # Cleanup
118 #
119
120 reset_test_env
121
122 }