##############################################################################
#   Modules Revision 3.0
#   Providing a flexible user environment
#
#   File:       modules.50-cmds/%M%
#   Revision:       %I%
#   First Edition:  2017/05/22
#   Last Mod.:      %U%, %G%
#
#   Authors:        Xavier Delaruelle, xavier.delaruelle@cea.fr
#
#   Description:    Testuite testsequence
#   Command:		load, display, help, test
#   Modulefiles:    info/others
#   Sub-Command:
#
#   Comment:    %C{
#           Tests the 'module-info' module subcommand with bad or
#           deprecated keywords.
#       }C%
#
##############################################################################

#
#  Variables. This test forces a module load command. It will result in the
#    environment variables "_LMFILES_", "LOADEDMODULES" and "testsuite" to
#    be set up
#

set module "info/others"
set modulefile "$modpath/$module"
set modulefilere "$modpathre/$module"

#
#  For sh shell only (no need to check every shells)
#

set trace_msg "trace: "
set tracepat_msg "tracepat: "


#
#  The tests
#

# test loading
set custom {module-info bad}
if {[cmpversion $tclsh_version 8.6] == -1} {
    append custom "\"
    invoked from within
\"if \{ \[module-info mode load\] \} \{
    puts stderr \"trace: \[module-info trace\]\"
    puts stderr \"tracepat: \[module-info tracepat\]\"
    puts stderr \"\[mod..."
    set linenum 47
} else {
    set linenum 50
}
if {[cmpversion $tclsh_version 8.5] == -1} {
    set custom "<EXM>$custom"
    set bad_msg [msg_moderr {module-info bad not supported} $custom $modulefile $linenum]
    testouterr_cmd_re "sh" "load $module" "ERR" $trace_msg\n$tracepat_msg\n\n[escre [msg_load $module $bad_msg]]
} else {
    set bad_msg [msg_moderr {module-info bad not supported} $custom $modulefile $linenum]
    testouterr_cmd "sh" "load $module" "ERR" $trace_msg\n$tracepat_msg\n\n[msg_load $module $bad_msg]
}

# test displaying
if {[cmpversion $tclsh_version 8.5] == -1} {
    set bad_msg "$moderr_msgs: module-info bad not supported\n.*module-info bad.*"
} else {
    set bad_msg [escre [msg_moderr {module-info bad not supported} {module-info bad} $modulefile 4 {  } ModulesDisplay]]
}
testouterr_cmd_re "sh" "display $module" "ERR" "$modlin\n$modulefilere:\n\n$trace_msg\n$tracepat_msg\n$bad_msg\n$modlin"

# test help
if {[cmpversion $tclsh_version 8.5] == -1} {
    set bad_msg "$moderr_msgs: module-info bad not supported\n.*module-info bad.*"
} else {
    set bad_msg [escre [msg_moderr {module-info bad not supported} {module-info bad} $modulefile 4 {  } ModulesHelp]]
}
testouterr_cmd_re "sh" "help $module" "ERR" "$modlin\nModule Specific Help for $modulefilere:\n\n$trace_msg\n$tracepat_msg\n$bad_msg\n$modlin"

# test test
if {[cmpversion $tclsh_version 8.5] == -1} {
    set bad_msg "$moderr_msgs: module-info bad not supported\n.*module-info bad.*"
} else {
    set bad_msg [escre [msg_moderr {module-info bad not supported} {module-info bad} $modulefile 4 {  } ModulesTest]]
}
testouterr_cmd_re "sh" "test $module" "ERR" "$modlin\nModule Specific Test for $modulefilere:\n\n$trace_msg\n$tracepat_msg\n$bad_msg\n$modlin"


#
#  Cleanup
#

reset_test_env
