| 1 |
#%Module1.0 |
| 2 |
|
| 3 |
############################################################################## |
| 4 |
# Modules Revision 3.0 |
| 5 |
# Providing a flexible user environment |
| 6 |
# |
| 7 |
# File: spreadrc/%M% |
| 8 |
# Revision: %I% |
| 9 |
# First Edition: 2017/06/23 |
| 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 |
# avail @M@, list |
| 21 |
# Result: %R{ |
| 22 |
# }R% |
| 23 |
# Comment: %C{ |
| 24 |
# Test how variable and procedure definitions spread from |
| 25 |
# one modulerc or modulefile interpretation to another one |
| 26 |
# when these interpretations are cascaded. |
| 27 |
# }C% |
| 28 |
# |
| 29 |
############################################################################## |
| 30 |
|
| 31 |
|
| 32 |
# test if specific or overriden pre-existing variables have spread here |
| 33 |
# coming from modulerc or sibbling modulefiles |
| 34 |
if {[info exists spreadrc]} { |
| 35 |
puts stderr "variable spreadrc exists" |
| 36 |
} |
| 37 |
if {[info exists spreadmod]} { |
| 38 |
puts stderr "variable spreadmod exists" |
| 39 |
} |
| 40 |
if {$tcl_version eq "test"} { |
| 41 |
puts stderr "variable tcl_version equals test" |
| 42 |
} |
| 43 |
if {[array exists spreadrc_array]} { |
| 44 |
puts stderr "array variable spreadrc_array exists" |
| 45 |
} |
| 46 |
if {[array exists spreadmod_array]} { |
| 47 |
puts stderr "array variable spreadmod_array exists" |
| 48 |
} |
| 49 |
if {$tcl_platform(osVersion) eq "test"} { |
| 50 |
puts stderr "variable tcl_platform(osVersion) equals test" |
| 51 |
} |
| 52 |
if {[llength $auto_path] <= 1} { |
| 53 |
puts stderr "variable auto_path has lost elements" |
| 54 |
} |
| 55 |
if {[lsearch -exact $auto_path $env(TESTSUITEDIR)] > -1} { |
| 56 |
puts stderr "variable auto_path contains $env(TESTSUITEDIR)" |
| 57 |
} |
| 58 |
|
| 59 |
# test if specific or overriden interpreter alias command have spread here |
| 60 |
# coming from modulerc or sibbling modulefiles |
| 61 |
set existing_proc [lindex [info procs] 0] |
| 62 |
# test if first proc defined has been altered |
| 63 |
if {[info procs $existing_proc] ne $existing_proc} { |
| 64 |
puts stderr "procedure $existing_proc does not exist" |
| 65 |
# env variable spread across interpretation and even between interpreters |
| 66 |
} else { |
| 67 |
if {[info exists env(spreadmodcasccmd)] && [$existing_proc] eq "spreadmodcasccmd"} { |
| 68 |
puts stderr "procedure $existing_proc has been altered" |
| 69 |
} |
| 70 |
# overriden proc does not spread as interp is renewed when a command is overriden |
| 71 |
if {[info exists env(spreadrccasc)] && [$existing_proc] eq "spreadrccasc"} { |
| 72 |
puts stderr "procedure $existing_proc has been altered" |
| 73 |
} |
| 74 |
} |
| 75 |
if {[info procs spreadrc_proc] eq "spreadrc_proc"} { |
| 76 |
puts stderr "procedure spreadrc_proc exists" |
| 77 |
} |
| 78 |
if {[info procs spreadmod_proc] eq "spreadmod_proc"} { |
| 79 |
puts stderr "procedure spreadmod_proc exists" |
| 80 |
} |
| 81 |
if {[info procs ModulesHelp] eq "ModulesHelp"} { |
| 82 |
puts stderr "procedure ModulesHelp exists" |
| 83 |
} |
| 84 |
if {[info procs ModulesTest] eq "ModulesTest"} { |
| 85 |
puts stderr "procedure ModulesTest exists" |
| 86 |
} |
| 87 |
if {[info procs ModulesDisplay] eq "ModulesDisplay"} { |
| 88 |
puts stderr "procedure ModulesDisplay exists" |
| 89 |
} |
| 90 |
if {[info procs module-version] eq "module-version"} { |
| 91 |
puts stderr "procedure module-version exists" |
| 92 |
} |
| 93 |
if {[info commands set] ne "set"} { |
| 94 |
puts stderr "command set does not exist" |
| 95 |
} |
| 96 |
|
| 97 |
|
| 98 |
# define specific variables or override value in pre-existing variables |
| 99 |
set spreadrc "yes" |
| 100 |
set tcl_version "test" |
| 101 |
array set spreadrc_array [list "yes" 1] |
| 102 |
set tcl_platform(osVersion) "test" |
| 103 |
lappend auto_path $env(TESTSUITEDIR) |
| 104 |
set env(spreadrccasc) "yes" |
| 105 |
|
| 106 |
# define specific procs or override interpreter alias command |
| 107 |
# override first proc defined |
| 108 |
proc $existing_proc {args} { |
| 109 |
return "spreadrccasc" |
| 110 |
} |
| 111 |
proc spreadrc_proc {text} { |
| 112 |
puts stderr "spreadrc_proc: $text" |
| 113 |
} |
| 114 |
proc ModulesHelp {} { |
| 115 |
puts stderr "spreadrc" |
| 116 |
} |
| 117 |
proc ModulesTest {} { |
| 118 |
puts stderr "spreadrc" |
| 119 |
return 1 |
| 120 |
} |
| 121 |
proc ModulesDisplay {} { |
| 122 |
puts stderr "spreadrc" |
| 123 |
} |
| 124 |
proc module-version {args} { |
| 125 |
puts stderr "spreadrc" |
| 126 |
} |
| 127 |
# define proc to override interpreter initial command |
| 128 |
proc set {args} { |
| 129 |
if {[lsearch -exact [list ::env(LOADEDMODULES) ::env(_LMFILES_) ::env(__MODULES_LMPREREQ) ::env(__MODULES_LMTAG) ::env(testspreadrccmd) ::env(testspreadrc) ::env(testspreadrccmdsub) ::env(testspreadrcsub) vrerrlist] [lindex $args 0]] == -1} { |
| 130 |
puts stderr "spreadrc" |
| 131 |
} |
| 132 |
} |