Skip to content

Commit

Permalink
ts: add new tests for sticky rules
Browse files Browse the repository at this point in the history
  • Loading branch information
xdelaruelle committed Sep 29, 2023
1 parent ed10789 commit 1e293dd
Show file tree
Hide file tree
Showing 16 changed files with 271 additions and 0 deletions.
11 changes: 11 additions & 0 deletions testsuite/modulefiles.4/.modulerc
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,14 @@ if {[info exists env(TESTSUITE_MODULEPATH_LABEL)]} {
}
}
}

if {[info exists ::env(TESTSUITE_STICKY)]} {
switch -- $::env(TESTSUITE_STICKY) {
6 - 7 {
module-alias alsticky1 sticky1/2.0
}
8 {
module-tag sticky sticky0
}
}
}
1 change: 1 addition & 0 deletions testsuite/modulefiles.4/sticky0
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#%Module
24 changes: 24 additions & 0 deletions testsuite/modulefiles.4/sticky1/.modulerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#%Module
if {[info exists ::env(TESTSUITE_STICKY)]} {
switch -- $::env(TESTSUITE_STICKY) {
1 {
module-tag sticky sticky1@1.0,2.0
}
2 - 6 {
module-tag sticky sticky1@1:2
}
3 {
module-tag sticky sticky1@0:
}
4 {
module-tag sticky [file dirname $ModulesCurrentModulefile]/1.0
}
5 {
module-alias sticky1/1.5 sticky/1.0
module-tag sticky sticky1@1:2
}
7 {
module-tag sticky sticky1
}
}
}
1 change: 1 addition & 0 deletions testsuite/modulefiles.4/sticky1/1.0
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#%Module
1 change: 1 addition & 0 deletions testsuite/modulefiles.4/sticky1/2.0
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#%Module
1 change: 1 addition & 0 deletions testsuite/modulefiles.4/sticky1/3.0
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#%Module
14 changes: 14 additions & 0 deletions testsuite/modulefiles.4/sticky2/1.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#%Module
if {[info exists ::env(TESTSUITE_STICKY)]} {
switch -- $::env(TESTSUITE_STICKY) {
8 {
prereq sticky0
}
9 - 10 - 11 {
prereq sticky4/sub/1.0 sticky4/sub/2.0
}
default {
prereq sticky1/1.0 sticky1/2.0
}
}
}
1 change: 1 addition & 0 deletions testsuite/modulefiles.4/sticky2/2.0
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#%Module
25 changes: 25 additions & 0 deletions testsuite/modulefiles.4/sticky3/1.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#%Module
if {[info exists ::env(TESTSUITE_STICKY)]} {
switch -- $::env(TESTSUITE_STICKY) {
5 {
prereq sticky2/1.0
module switch sticky1/1.5
}
6 - 7 {
prereq sticky2/1.0
module switch sticky1 alsticky1
}
8 {
prereq sticky2/1.0
module switch sticky0 sticky1
}
9 - 10 - 11 {
prereq sticky2/1.0
module switch sticky4/sub/2.0
}
default {
prereq sticky2/1.0
module switch sticky1/2.0
}
}
}
1 change: 1 addition & 0 deletions testsuite/modulefiles.4/sticky3/2.0
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#%Module
14 changes: 14 additions & 0 deletions testsuite/modulefiles.4/sticky4/.modulerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#%Module
if {[info exists ::env(TESTSUITE_STICKY)]} {
switch -- $::env(TESTSUITE_STICKY) {
9 {
module-tag sticky sticky4/sub@1.0:
}
10 {
module-tag sticky sticky4/sub
}
11 {
module-tag sticky sticky4/sub sticky4
}
}
}
1 change: 1 addition & 0 deletions testsuite/modulefiles.4/sticky4/sub/1.0
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#%Module
1 change: 1 addition & 0 deletions testsuite/modulefiles.4/sticky4/sub/2.0
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#%Module
1 change: 1 addition & 0 deletions testsuite/modulefiles.4/sticky4/sub/3.0
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#%Module
1 change: 1 addition & 0 deletions testsuite/modulefiles.4/sticky4/sub2/1.0
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#%Module
173 changes: 173 additions & 0 deletions testsuite/modules.50-cmds/462-sticky-corner.exp
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,179 @@ set tserr [msg_load foo/2.0]
testouterr_cmd_re sh {restore testsuite/home/coll-sticky-6} $ans $tserr


#
# is sticky reloading tests over loading module
#

set mp $modpath.4
set mpre $modpathre.4
setenv_path_var MODULEPATH $mp

setenv_var MODULES_ADVANCED_VERSION_SPEC 1

unsetenv_loaded_module
unsetenv_var __MODULES_LMTAG

setenv_var TESTSUITE_STICKY 1

set ans [list]
lappend ans [list set LOADEDMODULES sticky1/1.0:sticky2/1.0:sticky3/1.0]
lappend ans [list set _LMFILES_ $mp/sticky1/1.0:$mp/sticky2/1.0:$mp/sticky3/1.0]
lappend ans [list set __MODULES_LMPREREQ sticky2/1.0&sticky1/1.0|sticky1/2.0:sticky3/1.0&sticky2/1.0]
lappend ans [list set __MODULES_LMTAG sticky1/1.0&sticky&auto-loaded:sticky2/1.0&auto-loaded]
lappend ans [list ERR]
set tserr [msg_top_load sticky3/1.0 {} {sticky1/1.0 sticky2/1.0} {} $err_stickyunload]
testouterr_cmd_re sh {load --auto sticky3/1.0} $ans $tserr

setenv_var TESTSUITE_STICKY 2
testouterr_cmd_re sh {load --auto sticky3/1.0} $ans $tserr
setenv_var TESTSUITE_STICKY 3
testouterr_cmd_re sh {load --auto sticky3/1.0} $ans $tserr
setenv_var TESTSUITE_STICKY 4
testouterr_cmd_re sh {load --auto sticky3/1.0} $ans $tserr

setenv_var TESTSUITE_STICKY 5
testouterr_cmd_re sh {load --auto sticky3/1.0} $ans $tserr
setenv_var TESTSUITE_STICKY 6
testouterr_cmd_re sh {load --auto sticky3/1.0} $ans $tserr

setenv_var TESTSUITE_STICKY 7
set ans [list]
lappend ans [list set LOADEDMODULES sticky1/1.0:sticky2/1.0:sticky3/1.0]
lappend ans [list set _LMFILES_ $mp/sticky1/1.0:$mp/sticky2/1.0:$mp/sticky3/1.0]
lappend ans [list set __MODULES_LMSTICKYRULE sticky1/1.0&sticky|sticky1]
lappend ans [list set __MODULES_LMPREREQ sticky2/1.0&sticky1/1.0|sticky1/2.0:sticky3/1.0&sticky2/1.0]
lappend ans [list set __MODULES_LMTAG sticky1/1.0&sticky&auto-loaded:sticky2/1.0&auto-loaded]
lappend ans [list ERR]
#FIXME module switch may resolve switched-on module prior testing stickiness is preserved
testouterr_cmd_re sh {load --auto sticky3/1.0} $ans $tserr

setenv_var TESTSUITE_STICKY 8
set ans [list]
lappend ans [list set __MODULES_LMPREREQ sticky2/1.0&sticky0]
lappend ans [list set _LMFILES_ $mp/sticky0:$mp/sticky2/1.0]
lappend ans [list set LOADEDMODULES sticky0:sticky2/1.0]
lappend ans [list set __MODULES_LMTAG sticky0&sticky&auto-loaded]
set tserr [msg_top_load sticky2/1.0 {} {sticky0} {}]
testouterr_cmd_re sh {load --auto sticky2/1.0} $ans $tserr
set tserr [msg_load sticky3/1.0 $err_stickyunload [err_conun sticky0]]
testouterr_cmd_re sh {load --auto sticky3/1.0} ERR $tserr

setenv_var TESTSUITE_STICKY 9
set ans [list]
lappend ans [list set __MODULES_LMPREREQ sticky2/1.0&sticky4/sub/1.0|sticky4/sub/2.0]
lappend ans [list set _LMFILES_ $mp/sticky4/sub/1.0:$mp/sticky2/1.0]
lappend ans [list set LOADEDMODULES sticky4/sub/1.0:sticky2/1.0]
lappend ans [list set __MODULES_LMTAG sticky4/sub/1.0&sticky&auto-loaded]
set tserr [msg_top_load sticky2/1.0 {} {sticky4/sub/1.0} {}]
testouterr_cmd_re sh {load --auto sticky2/1.0} $ans $tserr

set ans [list]
lappend ans [list set LOADEDMODULES sticky4/sub/1.0:sticky2/1.0:sticky3/1.0]
lappend ans [list set _LMFILES_ $mp/sticky4/sub/1.0:$mp/sticky2/1.0:$mp/sticky3/1.0]
lappend ans [list set __MODULES_LMPREREQ sticky2/1.0&sticky4/sub/1.0|sticky4/sub/2.0:sticky3/1.0&sticky2/1.0]
lappend ans [list set __MODULES_LMTAG sticky4/sub/1.0&sticky&auto-loaded:sticky2/1.0&auto-loaded]
lappend ans [list ERR]
set tserr [msg_top_load sticky3/1.0 {} {sticky4/sub/1.0 sticky2/1.0} {} $err_stickyunload]
testouterr_cmd_re sh {load --auto sticky3/1.0} $ans $tserr

setenv_var TESTSUITE_STICKY 10
set ans [list]
lappend ans [list set __MODULES_LMPREREQ sticky2/1.0&sticky4/sub/1.0|sticky4/sub/2.0]
lappend ans [list set __MODULES_LMSTICKYRULE sticky4/sub/1.0&sticky|sticky4/sub]
lappend ans [list set _LMFILES_ $mp/sticky4/sub/1.0:$mp/sticky2/1.0]
lappend ans [list set LOADEDMODULES sticky4/sub/1.0:sticky2/1.0]
lappend ans [list set __MODULES_LMTAG sticky4/sub/1.0&sticky&auto-loaded]
set tserr [msg_top_load sticky2/1.0 {} {sticky4/sub/1.0} {}]
testouterr_cmd_re sh {load --auto sticky2/1.0} $ans $tserr

set ans [list]
lappend ans [list set __MODULES_LMPREREQ sticky2/1.0&sticky4/sub/1.0|sticky4/sub/2.0:sticky3/1.0&sticky2/1.0&sticky4/sub/2.0]
lappend ans [list set __MODULES_LMSTICKYRULE sticky4/sub/2.0&sticky|sticky4/sub]
lappend ans [list set _LMFILES_ $mp/sticky4/sub/2.0:$mp/sticky2/1.0:$mp/sticky3/1.0]
lappend ans [list set LOADEDMODULES sticky4/sub/2.0:sticky2/1.0:sticky3/1.0]
lappend ans [list set __MODULES_LMTAG sticky4/sub/2.0&sticky&auto-loaded:sticky2/1.0&auto-loaded]
set tserr [msg_top_load sticky3/1.0 {sticky4/sub/1.0} {} {sticky2/1.0} {Loading requirement: sticky4/sub/1.0 sticky2/1.0 sticky4/sub/2.0}]
testouterr_cmd_re sh {load --auto sticky3/1.0} $ans $tserr


#
# inconsistent environment
#

setenv_var TESTSUITE_STICKY 10

# sticky rule set but not tag
setenv_loaded_module [list sticky4/sub/1.0] [list $mp/sticky4/sub/1.0]
setenv_var __MODULES_LMSTICKYRULE sticky4/sub/1.0&sticky|sticky4/sub
unsetenv_var __MODULES_LMTAG
set ans [list]
lappend ans [list unset __MODULES_LMSTICKYRULE]
lappend ans [list unset _LMFILES_]
lappend ans [list unset LOADEDMODULES]
testouterr_cmd_re sh {unload --auto sticky4} $ans {}

# sticky rule inconsistent
setenv_loaded_module [list sticky4/sub/1.0] [list $mp/sticky4/sub/1.0]
setenv_var __MODULES_LMSTICKYRULE sticky4/sub/1.0&sticky
setenv_var __MODULES_LMTAG sticky4/sub/1.0&sticky
set tserr [msg_switch {sticky4/sub/1.0 <S>} sticky4/sub/2.0 $err_stickyunload]
testouterr_cmd_re sh {switch sticky4/sub/2.0} ERR $tserr

setenv_var __MODULES_LMSTICKYRULE sticky4/sub/1.0
testouterr_cmd_re sh {switch sticky4/sub/2.0} ERR $tserr

setenv_var __MODULES_LMSTICKYRULE sticky4/sub/1.0&foo
testouterr_cmd_re sh {switch sticky4/sub/2.0} ERR $tserr

setenv_var __MODULES_LMSTICKYRULE sticky4/sub/1.0&
testouterr_cmd_re sh {switch sticky4/sub/2.0} ERR $tserr

setenv_var __MODULES_LMSTICKYRULE sticky4/sub/1.0&foo|sticky4/sub
testouterr_cmd_re sh {switch sticky4/sub/2.0} ERR $tserr

setenv_var __MODULES_LMSTICKYRULE sticky4/sub/1.0&sticky|
testouterr_cmd_re sh {switch sticky4/sub/2.0} ERR $tserr

unsetenv_loaded_module
unsetenv_var __MODULES_LMSTICKYRULE
unsetenv_var __MODULES_LMTAG


#
# several generic definition
#

setenv_var TESTSUITE_STICKY 11

set ans [list]
lappend ans [list set __MODULES_LMPREREQ sticky2/1.0&sticky4/sub/1.0|sticky4/sub/2.0]
lappend ans [list set __MODULES_LMSTICKYRULE sticky4/sub/1.0&sticky|sticky4/sub|sticky4]
lappend ans [list set _LMFILES_ $mp/sticky4/sub/1.0:$mp/sticky2/1.0]
lappend ans [list set LOADEDMODULES sticky4/sub/1.0:sticky2/1.0]
lappend ans [list set __MODULES_LMTAG sticky4/sub/1.0&sticky&auto-loaded]
set tserr [msg_top_load sticky2/1.0 {} {sticky4/sub/1.0} {}]
testouterr_cmd_re sh {load --auto sticky2/1.0} $ans $tserr

setenv_loaded_module [list sticky4/sub/1.0] [list $mp/sticky4/sub/1.0]
setenv_var __MODULES_LMSTICKYRULE sticky4/sub/1.0&sticky|sticky4/sub|sticky4
setenv_var __MODULES_LMTAG sticky4/sub/1.0&sticky

set tserr [msg_switch {sticky4/sub/1.0 <S>} sticky4/sub2/1.0 $err_stickyunload]
testouterr_cmd_re sh {switch sticky4/sub2/1.0} ERR $tserr

set ans [list]
lappend ans [list set __MODULES_LMSTICKYRULE sticky4/sub/2.0&sticky|sticky4/sub|sticky4]
lappend ans [list set _LMFILES_ $mp/sticky4/sub/2.0]
lappend ans [list set LOADEDMODULES sticky4/sub/2.0]
lappend ans [list set __MODULES_LMTAG sticky4/sub/2.0&sticky]
testouterr_cmd_re sh {switch sticky4/sub/2.0} $ans {}

unsetenv_loaded_module
unsetenv_var __MODULES_LMSTICKYRULE
unsetenv_var __MODULES_LMTAG


#
# Cleanup
#
Expand Down

0 comments on commit 1e293dd

Please sign in to comment.