| 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 usergroups |
| 15 |
# Sub-Command: * |
| 16 |
# |
| 17 |
# Comment: %C{ |
| 18 |
# Check 'module-info usergroups' 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 |
if {$group_name_fetch_failed} { |
| 33 |
send_user "\tSkip user group tests, as group name fetch failed\n" |
| 34 |
} else { |
| 35 |
|
| 36 |
# modulefile usage |
| 37 |
set ans [list] |
| 38 |
lappend ans [list set TS1 $usergroups] |
| 39 |
lappend ans [list set TS2 1] |
| 40 |
lappend ans [list set _LMFILES_ $mp/info/usergroups] |
| 41 |
lappend ans [list set LOADEDMODULES info/usergroups] |
| 42 |
lappend ans [list set TS3 0] |
| 43 |
testouterr_cmd sh {load info/usergroups} $ans {} |
| 44 |
|
| 45 |
skip_if_quick_mode |
| 46 |
|
| 47 |
set usergroups_disp [expr {[llength $usergroups] > 1 ? [regsub -all "\(\[{}\]\)" "{$usergroups}" {\\\1}] : $usergroups}] |
| 48 |
set tserr "$modlin |
| 49 |
$mpre/info/usergroups: |
| 50 |
|
| 51 |
setenv\t\tTS1 $usergroups_disp |
| 52 |
setenv\t\tTS2 1 |
| 53 |
setenv\t\tTS3 0 |
| 54 |
$modlin" |
| 55 |
testouterr_cmd_re sh {show info/usergroups} OK $tserr |
| 56 |
|
| 57 |
# modulerc usage |
| 58 |
testouterr_cmd sh "is-avail info/$userfgroup" ERR {} |
| 59 |
setenv_var TESTSUITE_INFO_GROUP_IN_RC 1 |
| 60 |
testouterr_cmd sh "is-avail info/$userfgroup" OK {} |
| 61 |
testouterr_cmd_re sh "show info/$userfgroup" OK $tserr |
| 62 |
unsetenv_var TESTSUITE_INFO_GROUP_IN_RC |
| 63 |
|
| 64 |
|
| 65 |
# make `id` command unavailable |
| 66 |
setenv_var PATH {} |
| 67 |
if {$install_libtclenvmodules eq {y}} { |
| 68 |
testouterr_cmd sh {load info/usergroups} $ans {} |
| 69 |
} else { |
| 70 |
# impact on modulefile |
| 71 |
set tserr [msg_load info/usergroups "$error_msgs: Command 'id' cannot be found"] |
| 72 |
testouterr_cmd sh {load info/usergroups} ERR $tserr |
| 73 |
|
| 74 |
# impact on modulerc |
| 75 |
setenv_var TESTSUITE_INFO_GROUP_IN_RC 1 |
| 76 |
testouterr_cmd sh "is-avail info/$userfgroup" ERR {} |
| 77 |
|
| 78 |
switch -- $tclsh_version { |
| 79 |
8.5 { |
| 80 |
set tserr [escre [msg_moderr {Command 'id' cannot be found} {module-info usergroups" |
| 81 |
invoked from within |
| 82 |
"if {[info exists env(TESTSUITE_INFO_GROUP_IN_RC)]} { |
| 83 |
foreach grp [module-info usergroups] { |
| 84 |
module-virtual info/$grp ./usergroups |
| 85 |
} |
| 86 |
}} $mp/info/.modulerc 6 { }]\n$err_path'info/$userfgroup'] |
| 87 |
} |
| 88 |
default { |
| 89 |
set tserr [escre [msg_moderr {Command 'id' cannot be found} {module-info usergroups} $mp/info/.modulerc 7 { }]\n$err_path'info/$userfgroup'] |
| 90 |
}} |
| 91 |
testouterr_cmd_re sh "show info/$userfgroup" ERR $tserr |
| 92 |
|
| 93 |
unsetenv_var TESTSUITE_INFO_GROUP_IN_RC |
| 94 |
} |
| 95 |
setenv_var PATH $ORIG_PATH |
| 96 |
|
| 97 |
|
| 98 |
# fake Windows platform if expected siteconfig file is installed |
| 99 |
if {[siteconfig_isStderrTty]} { |
| 100 |
# fake Windows platform with a cmd.exe tool to execute system commands |
| 101 |
setenv_var TESTSUITE_ENABLE_SITECONFIG_WINDOWS_PLATFORM 1 |
| 102 |
|
| 103 |
switch -- $tclsh_version { |
| 104 |
8.5 { |
| 105 |
set tserr [escre [msg_load info/usergroups [msg_moderr {module-info usergroups not supported on Windows platform} {module-info usergroups" |
| 106 |
invoked from within |
| 107 |
"lsort [module-info usergroups]" |
| 108 |
invoked from within |
| 109 |
"set grplist [lsort [module-info usergroups]]} $mp/info/usergroups 2 {}]]] |
| 110 |
} |
| 111 |
default { |
| 112 |
set tserr [escre [msg_load info/usergroups [msg_moderr {module-info usergroups not supported on Windows platform} {module-info usergroups} $mp/info/usergroups 2 {}]]] |
| 113 |
}} |
| 114 |
testouterr_cmd_re sh {load info/usergroups} ERR $tserr |
| 115 |
|
| 116 |
setenv_var TESTSUITE_INFO_GROUP_IN_RC 1 |
| 117 |
switch -- $tclsh_version { |
| 118 |
8.5 { |
| 119 |
set tserr [escre [msg_moderr {module-info usergroups not supported on Windows platform} {module-info usergroups" |
| 120 |
invoked from within |
| 121 |
"if {[info exists env(TESTSUITE_INFO_GROUP_IN_RC)]} { |
| 122 |
foreach grp [module-info usergroups] { |
| 123 |
module-virtual info/$grp ./usergroups |
| 124 |
} |
| 125 |
}} $mp/info/.modulerc 6 { }]\n$err_path'info/$userfgroup'] |
| 126 |
} |
| 127 |
default { |
| 128 |
set tserr [escre [msg_moderr {module-info usergroups not supported on Windows platform} {module-info usergroups} $mp/info/.modulerc 7 { }]\n$err_path'info/$userfgroup'] |
| 129 |
}} |
| 130 |
testouterr_cmd_re sh "load info/$userfgroup" ERR $tserr |
| 131 |
unsetenv_var TESTSUITE_INFO_GROUP_IN_RC |
| 132 |
|
| 133 |
unsetenv_var TESTSUITE_ENABLE_SITECONFIG_WINDOWS_PLATFORM |
| 134 |
} |
| 135 |
|
| 136 |
} |
| 137 |
|
| 138 |
|
| 139 |
# |
| 140 |
# Cleanup |
| 141 |
# |
| 142 |
|
| 143 |
reset_test_env |