Skip to content

Commit 39e8e94

Browse files
committed
ts: format OS name to ease comparisons
1 parent 2c06df5 commit 39e8e94

File tree

15 files changed

+38
-35
lines changed

15 files changed

+38
-35
lines changed

testsuite/install.00-init/005-init_ts.exp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,11 @@ if {$sh_kind eq {sh} && ![catch {exec /bin/sh -c {echo $BASH_VERSION}} errMsg] &
5353
}
5454
send_user "\tsh_kind is '$sh_kind'\n"
5555

56+
# extract and format os name
57+
set os_name [string tolower [lindex [split $tcl_platform(os) _] 0]]
58+
5659
# determine if sh-shell is a strict sh implementation
57-
if {$sh_kind eq "dash" || ($tcl_platform(os) ne "Linux"\
58-
&& $tcl_platform(os) ne "Darwin"\
59-
&& ![string match "CYGWIN*" $tcl_platform(os)]\
60-
&& ![string match "MINGW*" $tcl_platform(os)]\
61-
&& ![string match "MSYS_NT*" $tcl_platform(os)])} {
60+
if {$sh_kind eq "dash" || $os_name ni {linux darwin cygwin mingw msys}} {
6261
set sh_strict 1
6362
} else {
6463
set sh_strict 0
@@ -74,7 +73,7 @@ if {$bashbin ne {}} {
7473
}
7574

7675
# check SIP is enabled or not on OS X
77-
if {$tcl_platform(os) eq "Darwin"} {
76+
if {$os_name eq "darwin"} {
7877
catch {
7978
regexp {System Integrity Protection status: enabled.} [exec csrutil status] csrutil_enabled
8079
} errMsg
@@ -131,7 +130,7 @@ foreach shell [list sh bash basheu ksh zsh csh tcsh fish tcl perl python ruby cm
131130
}
132131
pwsh {
133132
# Don't test pwsh in cygwin or msys (pwsh.exe won't work properly)
134-
if {![regexp "(CYGWIN|MINGW|MSYS_NT).*" $tcl_platform(os)]} {
133+
if {$os_name ni {cygwin mingw msys}} {
135134
set shellbin [find_bin pwsh]
136135
} else {
137136
set shellbin ""

testsuite/install.00-init/040-subshell.exp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ set zsh_nf "command not found: module"
2626
set zsh_nf_ml "command not found: ml"
2727
set tcsh_nf "module: Command not found."
2828
set tcsh_nf_ml "ml: Command not found."
29-
if {$tcl_platform(os) eq "SunOS"} {
29+
if {$os_name eq "sunos"} {
3030
set csh_nf "module: Command not found"
3131
set csh_nf_ml "ml: Command not found"
3232
} else {
@@ -35,10 +35,10 @@ if {$tcl_platform(os) eq "SunOS"} {
3535
}
3636
set fish_nf "fish: Unknown command:? '?module"
3737
set fish_nf_ml "fish: Unknown command:? '?ml"
38-
if {$tcl_platform(os) eq "SunOS"} {
38+
if {$os_name eq "sunos"} {
3939
set sh_nf "module: not found \\\[No such file or directory\\\]"
4040
set sh_nf_ml "ml: not found \\\[No such file or directory\\\]"
41-
} elseif {$tcl_platform(os) eq "FreeBSD"} {
41+
} elseif {$os_name eq "freebsd"} {
4242
set sh_nf "eval: module: not found"
4343
set sh_nf_ml "eval: ml: not found"
4444
} else {

testsuite/install.00-init/050-crossshell.exp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
set bad_cmd "$error_msgs: Invalid command 'foo'"
2424

2525
set bash_nf "(.*: )?module: command not found"
26-
if {$tcl_platform(os) eq "SunOS"} {
26+
if {$os_name eq "sunos"} {
2727
set cmd_nf "module: not found \\\[No such file or directory\\\]"
28-
} elseif {$tcl_platform(os) eq "FreeBSD"} {
28+
} elseif {$os_name eq "freebsd"} {
2929
set cmd_nf "eval: module: not found"
3030
} elseif {$sh_kind eq "dash"} {
3131
set cmd_nf "(.*: )?module: not found"
@@ -36,7 +36,7 @@ if {$tcl_platform(os) eq "SunOS"} {
3636
set ksh_nf "(.*: )?module: (inaccessible or )?not found( \\\[No such file or directory\\\])?"
3737
set zsh_nf "(\\\(eval\\\):1: )?command not found: module"
3838
set tcsh_nf "module: Command not found."
39-
if {$tcl_platform(os) eq "SunOS"} {
39+
if {$os_name eq "sunos"} {
4040
set csh_nf "module: Command not found"
4141
} else {
4242
set csh_nf $tcsh_nf
@@ -75,7 +75,7 @@ foreach subshell $shell_list {
7575
}
7676
ksh {
7777
# sh is a ksh on Solaris
78-
if {$tcl_platform(os) eq "SunOS"} {
78+
if {$os_name eq "sunos"} {
7979
testall_cmd_re "$shell" "module --version" "" "^Modules Release \\S+ (\\S+)" 0
8080
} else {
8181
testall_cmd_re "$shell" "module --version" "" "$cmd_nf" 127
@@ -129,7 +129,7 @@ foreach subshell $shell_list {
129129
}
130130
ksh {
131131
# sh is a ksh on Solaris
132-
if {$tcl_platform(os) eq "SunOS"} {
132+
if {$os_name eq "sunos"} {
133133
testall_cmd_re "$shell" "module --version" "" "^Modules Release \\S+ (\\S+)" 0
134134
} else {
135135
testall_cmd_re "$shell" "module --version" "" "$cmd_nf" 127

testsuite/install.00-init/090-sh-to-mod.exp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ foreach sh $shtomod_supported_shells {
3434
if {$shbin ne {}} {
3535
# mksh flavor of ksh is not supported
3636
# sh from FreeBSD is not supported too
37-
if {($sh ne {ksh} || !$ksh_is_mksh) && ($sh ne {sh} || $tcl_platform(os) ne {FreeBSD})} {
37+
if {($sh ne {ksh} || !$ksh_is_mksh) && ($sh ne {sh} || $os_name ne {freebsd})} {
3838
lappend shtomod_avail_shells $sh
3939
}
4040
if {[lsearch -exact $shtomod_supported_fshells $sh] != -1} {
@@ -86,7 +86,7 @@ foreach sh $shtomod_avail_shells {
8686
# no shell mix for csh, as a function or alias defined for a sh/fish shell will not work on csh
8787
# disable test if wa277 is enabled as in this case csh module alias has no protection against special chars in output
8888
if {($fsh eq {csh} || $fsh eq {tcsh}) && ($sh eq {csh} || $sh eq {tcsh}) && $install_wa277 eq {n}} {
89-
set tserr [expr {$tcl_platform(os) eq {Darwin} || $tcl_platform(os) eq {FreeBSD} ? {} : {tr: warning: an unescaped backslash at end of string is not portable}}]
89+
set tserr [expr {$os_name in {darwin freebsd} ? {} : {tr: warning: an unescaped backslash at end of string is not portable}}]
9090
testall_cmd $fsh "module sh-to-mod $sh $testscriptcsh $testscriptshargs_csh >& shtomod\; module load ./shtomod\; $testshenvcmds_csh" $tsout_csh $tserr 0
9191
}
9292
} elseif {$sh eq {dash} || ($sh eq {sh} && $sh_kind eq {dash})} {

testsuite/modules.00-init/005-init_ts.exp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,15 @@ if {[file type /bin/sh] eq {link}} {
3636
set sh_kind sh
3737
}
3838

39+
# extract and format os name
40+
set os_name [string tolower [lindex [split $tcl_platform(os) _] 0]]
41+
3942
# get current terminal width
4043
proc getTtyCols {} {
4144
set nbcols {}
4245

43-
switch -- $::tcl_platform(os) {
44-
{SunOS} {
46+
switch -- $::os_name {
47+
{sunos} {
4548
catch {regexp {columns = (\d+);} [exec stty] match nbcols} errMsg
4649
}
4750
default {
@@ -85,7 +88,7 @@ proc find_bin {name} {
8588
}
8689

8790
# check SIP is enabled or not on OS X
88-
if {$tcl_platform(os) eq "Darwin"} {
91+
if {$os_name eq "darwin"} {
8992
catch {
9093
regexp {System Integrity Protection status: enabled.} [exec csrutil status] csrutil_enabled
9194
} errMsg
@@ -294,7 +297,8 @@ proc cmpversion {str1 str2} {
294297

295298
# report current system information
296299
send_user "\tMachine hardware name is '$tcl_platform(machine)'\n"
297-
send_user "\tOS name is '$tcl_platform(os)'\n"
300+
send_user "\tOS code name is '$tcl_platform(os)'\n"
301+
send_user "\tOS cleaned name is '$os_name'\n"
298302
send_user "\tOS version is '$tcl_platform(osVersion)'\n"
299303
send_user "\tPlatform name is '$tcl_platform(platform)'\n"
300304

testsuite/modules.00-init/150-access-init.exp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ if {[info exists tclextlib_file]} {
7171
file rename $tclextlib_file $tclextlib_file.orig
7272
file copy lib/envmodules.c $tclextlib_file
7373
set tclextlib_file_abs_re [regsub -all "\(\[.+?\]\)" [file normalize $tclextlib_file] {\\\1}]
74-
if {$tcl_platform(os) eq {Darwin}} {
74+
if {$os_name eq {darwin}} {
7575
set tserr "$error_msgs: dlopen\\\($tclextlib_file_abs_re,.*"
7676
} else {
7777
set tserr "$error_msgs: couldn't load file \"$tclextlib_file_abs_re\":.*"

testsuite/modules.00-init/170-cwd.exp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ skip_if_quick_mode
2929
# - when running on Cygwin/MinGW/MSYS which are unaffected by cwd removal
3030
# - when running on Tcl 8.5 where test outputs are saved in files located in
3131
# current working directory
32-
if {![info exists env(COVERAGE)] && ![regexp {^(CYGWIN|MINGW|MSYS_NT).*}\
33-
$tcl_platform(os)] && [cmpversion $tclsh_version 8.6] > -1} {
32+
if {![info exists env(COVERAGE)] && $os_name ni {cygwin mingw msys}\
33+
&& [cmpversion $tclsh_version 8.6] > -1} {
3434

3535
# change MODULECMD for the test to make it an absolute path name
3636
set MODULECMD $env(TESTSUITEDIR)/../$MODULECMD

testsuite/modules.20-locate/043-virtual.exp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ set modavail_8 ""
8989
set modwhatis_8 ""
9090
set modpaths_8 [list]
9191
# a directory can be opened on FreeBSD <= 12.1, so another err message is obtained
92-
if {$tcl_platform(os) eq "FreeBSD" && [cmpversion [lindex [split $tcl_platform(osVersion) -] 0] 12.1] < 1} {
92+
if {$os_name eq "freebsd" && [cmpversion [lindex [split $tcl_platform(osVersion) -] 0] 12.1] < 1} {
9393
set moderr_8 "$err_magic'$modulefile_8'\n$err_contact"
9494
set modunerr_8 [msg_unload $module_8 "$err_magicns'$modulefile_8'\n$err_contactns"]
9595
} else {
@@ -104,7 +104,7 @@ set modulefilere_9 [regsub -all "\(\[.+?\]\)" $modulefile_9 {\\\1}]
104104
set modavail_9 ""
105105
set modwhatis_9 ""
106106
set modpaths_9 [list]
107-
if {$tcl_platform(os) eq "FreeBSD" && [cmpversion [lindex [split $tcl_platform(osVersion) -] 0] 12.1] < 1} {
107+
if {$os_name eq "freebsd" && [cmpversion [lindex [split $tcl_platform(osVersion) -] 0] 12.1] < 1} {
108108
set moderr_9 "$err_magic'$modulefile_9'\n$err_contact"
109109
set modunerr_9 [msg_unload $module_9 "$err_magicns'$modulefile_9'\n$err_contactns"]
110110
} else {

testsuite/modules.20-locate/100-wspace.exp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,7 @@ set mp "$modpath wspac "
640640
set mpre "$modpathre wspac "
641641
# create modulepath finishing by space on the file (it crashes git checkout on Windows if saved in repo)
642642
# MSYS environment does not support anymore such test
643-
if {!$is_symlink_supported || [string match MSYS_NT* $tcl_platform(os)] || [catch {file link -symbolic $mp modulefiles.2}]} {
643+
if {!$is_symlink_supported || $os_name eq {msys} || [catch {file link -symbolic $mp modulefiles.2}]} {
644644
send_user "\tskipping tests over '$mp' modulepath as symbolic links are not supported on filesystem\n"
645645
} else {
646646

testsuite/modules.30-cache/040-cache-use.exp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ file delete $mp2
284284

285285
# test over a modulepath containing a space character
286286
# skip test on MSYS platform or if symlink creation is not supported
287-
if {$is_symlink_supported && ![regexp {^MSYS_NT.*} $tcl_platform(os)]} {
287+
if {$is_symlink_supported && $os_name ne {msys}} {
288288
set mpws "$env(HOME)/mp ws"
289289
set mpwscache $mpws/.modulecache
290290
file link -symbolic $mpws $mp1

0 commit comments

Comments
 (0)