Skip to content

Commit

Permalink
ts: test bad options set on module use/unuse mfcmd
Browse files Browse the repository at this point in the history
  • Loading branch information
xdelaruelle committed Jan 19, 2024
1 parent 8c489dc commit e6d830c
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
11 changes: 11 additions & 0 deletions testsuite/modulefiles.4/use/1.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#%Module
if {[info exists env(TESTSUITE_USE)]} {
switch -- $env(TESTSUITE_USE) {
use_bad_opt {
module use --bad $env(TESTSUITEDIR)/modulefiles
}
unuse_bad_opt {
module unuse --bad $env(TESTSUITEDIR)/modulefiles
}
}
}
25 changes: 25 additions & 0 deletions testsuite/modules.50-cmds/015-use.exp
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,31 @@ testouterr_cmd sh "load $module2" $ans {}
unsetenv_var TESTSUITE_REFCOUNT


# bad option set on use and unuse module sub-commands
setenv_var TESTSUITE_USE use_bad_opt
setenv_var MODULEPATH $modpath.4

if {[cmpversion $tclsh_version 8.6] == -1} {
set custom_error_trace " invoked from within
\"if \{\[info exists env(TESTSUITE_USE)\]\} \{
switch -- \$env(TESTSUITE_USE) \{
use_bad_opt \{
module use --bad \$env(TESTSUITEDIR)/modu...\""
} else {
set custom_error_trace {}
}

set line_num [expr {[cmpversion $tclsh_version 8.6] == -1 ? 2 : 5}]
set tserr [msg_load use/1.0 [msg_moderr {Invalid option '--bad'} {module use --bad $env(TESTSUITEDIR)/modulefiles} $modpath.4/use/1.0 $line_num {} {} {} $custom_error_trace]]
testouterr_cmd sh {load use/1.0} ERR $tserr

set line_num [expr {[cmpversion $tclsh_version 8.6] == -1 ? 2 : 8}]
set tserr [msg_load use/1.0 [msg_moderr {Invalid option '--bad'} {module unuse --bad $env(TESTSUITEDIR)/modulefiles} $modpath.4/use/1.0 $line_num {} {} {} $custom_error_trace]]
setenv_var TESTSUITE_USE unuse_bad_opt

testouterr_cmd sh {load use/1.0} ERR $tserr


#
# Cleanup
#
Expand Down

0 comments on commit e6d830c

Please sign in to comment.