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/18 10# Last Mod.: %U%, %G% 11# 12# Authors: Xavier Delaruelle, xavier.delaruelle@cea.fr 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# }C% 27# 28############################################################################## 29 30 31# test if specific or overriden pre-existing variables have spread here 32# coming from modulerc or sibbling modulefiles 33if {[info exists spreadrc]} { 34 puts stderr "variable spreadrc exists" 35} 36if {[info exists spreadmod]} { 37 puts stderr "variable spreadmod exists" 38} 39if {$tcl_version eq "test"} { 40 puts stderr "variable tcl_version equals test" 41} 42if {[array exists spreadrc_array]} { 43 puts stderr "array variable spreadrc_array exists" 44} 45if {[array exists spreadmod_array]} { 46 puts stderr "array variable spreadmod_array exists" 47} 48if {$tcl_platform(osVersion) eq "test"} { 49 puts stderr "variable tcl_platform(osVersion) equals test" 50} 51if {[llength $auto_path] <= 1} { 52 puts stderr "variable auto_path has lost elements" 53} 54if {[lsearch -exact $auto_path $env(TESTSUITEDIR)] > -1} { 55 puts stderr "variable auto_path contains $env(TESTSUITEDIR)" 56} 57 58# test if specific or overriden interpreter alias command have spread here 59# coming from modulerc or sibbling modulefiles 60set existing_proc [lindex [info procs] 0] 61# test if first proc defined has been altered 62if {[info procs $existing_proc] ne $existing_proc} { 63 puts stderr "procedure $existing_proc does not exist" 64# env variable spread across interpretation and even between interpreters 65} else { 66 if {[info exists env(spreadmod)] && [$existing_proc] eq "spreadmod"} { 67 puts stderr "procedure $existing_proc has been altered" 68 } 69 if {[info exists env(spreadrc)] && [$existing_proc] ne "spreadrc"} { 70 puts stderr "procedure $existing_proc has not been altered" 71 } 72} 73if {[info procs spreadrc_proc] eq "spreadrc_proc"} { 74 puts stderr "procedure spreadrc_proc exists" 75} 76if {[info procs spreadmod_proc] eq "spreadmod_proc"} { 77 puts stderr "procedure spreadmod_proc exists" 78} 79if {[info procs ModulesHelp] eq "ModulesHelp"} { 80 puts stderr "procedure ModulesHelp exists" 81} 82if {[info procs ModulesTest] eq "ModulesTest"} { 83 puts stderr "procedure ModulesTest exists" 84} 85if {[info procs ModulesDisplay] eq "ModulesDisplay"} { 86 puts stderr "procedure ModulesDisplay exists" 87} 88if {[info procs module-version] eq "module-version"} { 89 puts stderr "procedure module-version exists" 90} 91 92 93# define specific variables or override value in pre-existing variables 94set spreadrc "yes" 95set tcl_version "test" 96array set spreadrc_array [list "yes" 1] 97set tcl_platform(osVersion) "test" 98lappend auto_path $env(TESTSUITEDIR) 99set env(spreadrc) "yes" 100 101# define specific procs or override interpreter alias command 102# override first proc defined 103proc $existing_proc {args} { 104 return "spreadrc" 105} 106proc spreadrc_proc {text} { 107 puts stderr "spreadrc_proc: $text" 108} 109proc ModulesHelp {} { 110 puts stderr "spreadrc" 111} 112proc ModulesTest {} { 113 puts stderr "spreadrc" 114 return 1 115} 116proc ModulesDisplay {} { 117 puts stderr "spreadrc" 118} 119proc module-version {args} { 120 puts stderr "spreadrc" 121} 122 123