Debian Codegraph @

testsuite/modules.50-cmds/035-unsetenv-undo.exp

raw
1 ##############################################################################
2 # Modules Revision 3.0
3 # Providing a flexible user environment
4 #
5 # File: modules.50-cmds/%M%
6 # Revision: %I%
7 # First Edition: 1995/12/06
8 # Last Mod.: %U%, %G%
9 #
10 # Authors: Jens Hamisch, [email protected]
11 #
12 # Description: Testuite testsequence
13 # Command: unload
14 # Modulefiles: unsetenv/1.0
15 # Sub-Command:
16 #
17 # Comment: %C{
18 # Tests the reverse 'unsetenv' module subcommand for all
19 # allowed shell types.
20 # }C%
21 #
22 # Trouble: %T{
23 # Removal of a 'unsetenv' command *SHOULD* result in
24 # the once removed variable being restored.
25 #
26 # To be discussed:
27 #
28 # - We cannot determine, if the variable really
29 # *HAS BEEN* removed or if it has never been
30 # set up before.
31 #
32 # - We cannot determine, what the former value of
33 # he variable was.
34 #
35 # Should there be a 'default value' in the module
36 # file? This would let us do the following:
37 #
38 # if { [info exists env(tmpvar) ] } {
39 # set saveme $env(tmpvar)
40 # } else {
41 # set saveme ""
42 # }
43 # setenv env(tmpvar) $env(SHELLVARIABLE)
44 # unsetenv SHELLVARIABLE $saveme
45 # }T%
46 #
47 ##############################################################################
48
49 skip_if_quick_mode
50
51 #
52 # Variables. This test forces a module unload command. It will result in the
53 # environment variables "_LMFILES_", "LOADEDMODULES" and "testsuite" to
54 # be set up
55 #
56
57 set module "unsetenv/1.0"
58 set modulefile "$modpath/$module"
59
60 #
61 # Set up the environment for reversal ...
62 #
63
64 if { [info exists env(testsuite)] } {
65 unset env(testsuite)
66 }
67 setenv_loaded_module $module $modulefile
68
69 #
70 # For the different shells ...
71 #
72
73 lappend ans [list unset _LMFILES_]
74 lappend ans [list unset LOADEDMODULES]
75
76 #
77 # The tests
78 #
79
80 test_cmd "ALL" "unload $module" $ans
81
82 #
83 # bad specification test
84 #
85
86 set mp $modpath.3
87 setenv_path_var MODULEPATH $mp
88 setenv_loaded_module unsetenv/2.0 $mp/unsetenv/2.0
89
90 setenv_var TESTSUITE_UNSETENV bad1
91 unsetenv_var TS1
92
93 set ln [expr {[cmpversion $tclsh_version 8.5] < 1 ? {2} : {5}}]
94 set tserr [escre [msg_unload unsetenv/2.0 [msg_moderr {wrong # args: should be "unsetenv ?--noop-on-unload? ?--unset-on-unload? var ?val?"} {unsetenv TS1 foo bar<EXM>} $mp/unsetenv/2.0 $ln]]]
95 testouterr_cmd_re sh {unload unsetenv/2.0} ERR $tserr
96
97 setenv_var TS1 foo
98 testouterr_cmd_re sh {unload unsetenv/2.0} ERR $tserr
99
100 unsetenv_var TS1
101 unsetenv_var TESTSUITE_UNSETENV
102 unsetenv_loaded_module
103
104
105 #
106 # Cleanup
107 #
108
109 reset_test_env