| 1 |
############################################################################## |
| 2 |
# Modules Revision 3.0 |
| 3 |
# Providing a flexible user environment |
| 4 |
# |
| 5 |
# File: modules.50-cmds/%M% |
| 6 |
# Revision: %I% |
| 7 |
# First Edition: 2020/06/05 |
| 8 |
# Last Mod.: %U%, %G% |
| 9 |
# |
| 10 |
# Authors: Xavier Delaruelle, [email protected] |
| 11 |
# |
| 12 |
# Description: Testuite testsequence |
| 13 |
# Command: |
| 14 |
# Modulefiles: module-info username |
| 15 |
# Sub-Command: * |
| 16 |
# |
| 17 |
# Comment: %C{ |
| 18 |
# Check 'module-info username' modulefile command |
| 19 |
# }C% |
| 20 |
# |
| 21 |
############################################################################## |
| 22 |
|
| 23 |
# ensure auto symbolic versions are not set for these tests |
| 24 |
setenv_var MODULES_ADVANCED_VERSION_SPEC 0 |
| 25 |
|
| 26 |
set mp $modpath.2 |
| 27 |
set mpre [regsub -all "\(\[.+?\]\)" $mp {\\\1}] |
| 28 |
|
| 29 |
# setup specific environment |
| 30 |
setenv_path_var MODULEPATH $mp |
| 31 |
|
| 32 |
|
| 33 |
# modulefile usage |
| 34 |
set ans [list] |
| 35 |
lappend ans [list set TS1 $username] |
| 36 |
lappend ans [list set TS2 1] |
| 37 |
lappend ans [list set _LMFILES_ $mp/info/username] |
| 38 |
lappend ans [list set LOADEDMODULES info/username] |
| 39 |
lappend ans [list set TS3 0] |
| 40 |
testouterr_cmd sh {load info/username} $ans {} |
| 41 |
|
| 42 |
skip_if_quick_mode |
| 43 |
|
| 44 |
set tserr "$modlin |
| 45 |
$mpre/info/username: |
| 46 |
|
| 47 |
setenv\t\tTS1 $username |
| 48 |
setenv\t\tTS2 1 |
| 49 |
setenv\t\tTS3 0 |
| 50 |
$modlin" |
| 51 |
testouterr_cmd_re sh {show info/username} OK $tserr |
| 52 |
|
| 53 |
# modulerc usage |
| 54 |
testouterr_cmd sh "is-avail info/$username" ERR {} |
| 55 |
setenv_var TESTSUITE_INFO_USER_IN_RC 1 |
| 56 |
testouterr_cmd sh "is-avail info/$username" OK {} |
| 57 |
testouterr_cmd_re sh "show info/$username" OK $tserr |
| 58 |
unsetenv_var TESTSUITE_INFO_USER_IN_RC |
| 59 |
|
| 60 |
|
| 61 |
# make `id` command unavailable |
| 62 |
setenv_var PATH {} |
| 63 |
if {$install_libtclenvmodules eq {y}} { |
| 64 |
testouterr_cmd sh {load info/username} $ans {} |
| 65 |
} else { |
| 66 |
# impact on modulefile |
| 67 |
set tserr [msg_load info/username "$error_msgs: Command 'id' cannot be found"] |
| 68 |
testouterr_cmd sh {load info/username} ERR $tserr |
| 69 |
|
| 70 |
# impact on modulerc |
| 71 |
setenv_var TESTSUITE_INFO_USER_IN_RC 1 |
| 72 |
testouterr_cmd sh "is-avail info/$username" ERR {} |
| 73 |
|
| 74 |
switch -- $tclsh_version { |
| 75 |
8.5 { |
| 76 |
set tserr [escre [msg_moderr {Command 'id' cannot be found} {module-info username" |
| 77 |
invoked from within |
| 78 |
"if {[info exists env(TESTSUITE_INFO_USER_IN_RC)]} { |
| 79 |
module-virtual info/[module-info username] ./username |
| 80 |
}} $mp/info/.modulerc 3 { }]\n$err_path'info/$username'] |
| 81 |
} |
| 82 |
default { |
| 83 |
set tserr [escre [msg_moderr {Command 'id' cannot be found} {module-info username} $mp/info/.modulerc 4 { }]\n$err_path'info/$username'] |
| 84 |
}} |
| 85 |
testouterr_cmd_re sh "show info/$username" ERR $tserr |
| 86 |
|
| 87 |
unsetenv_var TESTSUITE_INFO_USER_IN_RC |
| 88 |
} |
| 89 |
setenv_var PATH $ORIG_PATH |
| 90 |
|
| 91 |
|
| 92 |
# fake Windows platform if expected siteconfig file is installed |
| 93 |
if {[siteconfig_isStderrTty]} { |
| 94 |
# fake Windows platform with a cmd.exe tool to execute system commands |
| 95 |
setenv_var TESTSUITE_ENABLE_SITECONFIG_WINDOWS_PLATFORM 1 |
| 96 |
|
| 97 |
switch -- $tclsh_version { |
| 98 |
8.5 { |
| 99 |
set tserr [escre [msg_load info/username [msg_moderr {module-info username not supported on Windows platform} {module-info username" |
| 100 |
invoked from within |
| 101 |
"set user [module-info username]} $mp/info/username 2 {}]]] |
| 102 |
} |
| 103 |
default { |
| 104 |
set tserr [escre [msg_load info/username [msg_moderr {module-info username not supported on Windows platform} {module-info username} $mp/info/username 2 {}]]] |
| 105 |
}} |
| 106 |
testouterr_cmd_re sh {load info/username} ERR $tserr |
| 107 |
|
| 108 |
setenv_var TESTSUITE_INFO_USER_IN_RC 1 |
| 109 |
|
| 110 |
switch -- $tclsh_version { |
| 111 |
8.5 { |
| 112 |
set tserr [escre [msg_moderr {module-info username not supported on Windows platform} {module-info username" |
| 113 |
invoked from within |
| 114 |
"if {[info exists env(TESTSUITE_INFO_USER_IN_RC)]} { |
| 115 |
module-virtual info/[module-info username] ./username |
| 116 |
}} $mp/info/.modulerc 3 { }]\n$err_path'info/$username'] |
| 117 |
} |
| 118 |
default { |
| 119 |
set tserr [escre [msg_moderr {module-info username not supported on Windows platform} {module-info username} $mp/info/.modulerc 4 { }]\n$err_path'info/$username'] |
| 120 |
}} |
| 121 |
|
| 122 |
testouterr_cmd_re sh "load info/$username" ERR $tserr |
| 123 |
unsetenv_var TESTSUITE_INFO_USER_IN_RC |
| 124 |
|
| 125 |
unsetenv_var TESTSUITE_ENABLE_SITECONFIG_WINDOWS_PLATFORM |
| 126 |
} |
| 127 |
|
| 128 |
|
| 129 |
# |
| 130 |
# Cleanup |
| 131 |
# |
| 132 |
|
| 133 |
reset_test_env |