Debian Codegraph @

testsuite/modulefiles/spread/3.0

raw
1 #%Module1.0
2
3 ##############################################################################
4 # Modules Revision 3.0
5 # Providing a flexible user environment
6 #
7 # File: spread/%M%
8 # Revision: %I%
9 # First Edition: 2017/06/20
10 # Last Mod.: %U%, %G%
11 #
12 # Authors: Xavier Delaruelle, [email protected]
13 #
14 # Description: Testuite modulefile
15 # Command:
16 # Sub-Command:
17 #
18 # Invocation: load @M@, unload @M@, switch @M@ @M@,
19 # help @M@, display @M@, test @M@, whatis @M@
20 # Result: %R{
21 # }R%
22 # Comment: %C{
23 # Test how variable and procedure definitions spread from
24 # one modulefile interpretation to another one.
25 # }C%
26 #
27 ##############################################################################
28
29
30 # test if specific or overridden pre-existing variables have spread here
31 if {[info exists spread]} {
32 puts stderr "variable spread exists"
33 }
34 if {$tcl_version eq "test"} {
35 puts stderr "variable tcl_version equals test"
36 }
37 if {[array exists spread_array]} {
38 puts stderr "array variable spread_array exists"
39 }
40 if {$tcl_platform(osVersion) eq "test"} {
41 puts stderr "variable tcl_platform(osVersion) equals test"
42 }
43 if {[llength $auto_path] <= 1} {
44 puts stderr "variable auto_path has lost elements"
45 }
46 if {[lsearch -exact $auto_path $env(TESTSUITEDIR)] > -1} {
47 puts stderr "variable auto_path contains $env(TESTSUITEDIR)"
48 }
49
50 # test if specific or overridden interpreter alias command have spread here
51 set existing_proc [lindex [info procs] 0]
52 # test if first proc defined has been altered
53 if {[info procs $existing_proc] ne $existing_proc} {
54 puts stderr "procedure $existing_proc does not exist"
55 # env variable spread across interpretation and even between interpreters
56 # overridden proc does not spread as interp is renewed when a command is overridden
57 } elseif {[info exists env(spreadcmd)] && [$existing_proc] eq "spreadcmd"} {
58 puts stderr "procedure $existing_proc has been altered"
59 }
60 if {[info procs spread_proc] eq "spread_proc"} {
61 puts stderr "procedure spread_proc exists"
62 }
63 if {[info procs ModulesHelp] eq "ModulesHelp"} {
64 puts stderr "procedure ModulesHelp exists"
65 }
66 if {[info procs ModulesTest] eq "ModulesTest"} {
67 puts stderr "procedure ModulesTest exists"
68 }
69 if {[info procs ModulesDisplay] eq "ModulesDisplay"} {
70 puts stderr "procedure ModulesDisplay exists"
71 }
72 if {[info procs module-version] eq "module-version"} {
73 puts stderr "procedure module-version exists"
74 }
75 if {[info commands set] ne "set"} {
76 puts stderr "command set does not exist"
77 }
78
79 # define specific variables or override value in pre-existing variables
80 set spread "yes"
81 set tcl_version "test"
82 array set spread_array [list "yes" 1]
83 set tcl_platform(osVersion) "test"
84 lappend auto_path $env(TESTSUITEDIR)
85 set env(spread) "yes"
86 set env(spreadcmd) "yes"
87
88 # define specific procs or override interpreter alias command
89 # override first proc defined
90 proc $existing_proc {args} {
91 return "spreadcmd"
92 }
93 proc spread_proc {text} {
94 puts stderr "spread_proc: $text"
95 }
96 proc ModulesHelp {} {
97 puts stderr "spread"
98 }
99 proc ModulesTest {} {
100 puts stderr "spread"
101 return 1
102 }
103 proc ModulesDisplay {} {
104 puts stderr "spread"
105 }
106 proc module-version {args} {
107 puts stderr "spread"
108 }
109 # define proc to override interpreter initial command
110 proc set {args} {
111 if {[lsearch -exact [list ::env(LOADEDMODULES) ::env(_LMFILES_) ::env(__MODULES_LMPREREQ) ::env(__MODULES_LMTAG) ::env(testspreadrccmd) ::env(testspreadrc) ::env(testspreadrccmdsub) ::env(testspreadrcsub) ::env(testspreadcmd) ::env(testspreadcmd) ::env(testspreadcmdsub) vrerrlist] [lindex $args 0]] == -1} {
112 puts stderr "spread"
113 }
114 }