From e6d830c7245d90608adea5472d0a34256fb815f0 Mon Sep 17 00:00:00 2001 From: Xavier Delaruelle Date: Sun, 14 Jan 2024 10:35:09 +0100 Subject: [PATCH] ts: test bad options set on module use/unuse mfcmd --- testsuite/modulefiles.4/use/1.0 | 11 +++++++++++ testsuite/modules.50-cmds/015-use.exp | 25 +++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 testsuite/modulefiles.4/use/1.0 diff --git a/testsuite/modulefiles.4/use/1.0 b/testsuite/modulefiles.4/use/1.0 new file mode 100644 index 000000000..4c9dbf3d5 --- /dev/null +++ b/testsuite/modulefiles.4/use/1.0 @@ -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 + } + } +} diff --git a/testsuite/modules.50-cmds/015-use.exp b/testsuite/modules.50-cmds/015-use.exp index 034e7edf2..c350cc1a0 100644 --- a/testsuite/modules.50-cmds/015-use.exp +++ b/testsuite/modules.50-cmds/015-use.exp @@ -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 #