From d1dfef4884d442f7c3a8a0f5e6a5b0e1aed2a19d Mon Sep 17 00:00:00 2001
From: "jan.nijtmans" <nijtmans@users.sourceforge.net>
Date: Thu, 19 Nov 2020 09:39:20 +0000
Subject: Handle github actions test failures. Backported from 8.6

---
 tests/fCmd.test   |  7 ++++++-
 tests/format.test | 17 ++++++++---------
 tests/interp.test | 12 ++++++------
 tests/main.test   |  2 +-
 4 files changed, 21 insertions(+), 17 deletions(-)

diff --git a/tests/fCmd.test b/tests/fCmd.test
index 9b6c21e..0fabc90 100644
--- a/tests/fCmd.test
+++ b/tests/fCmd.test
@@ -76,6 +76,7 @@ testConstraint darwin9 [expr {
     && [package vsatisfies 1.$::tcl_platform(osVersion) 1.9]
 }]
 testConstraint notDarwin9 [expr {![testConstraint darwin9]}]
+testConstraint notContinuousIntegration [expr {![info exists ::env(CI)]}]
 
 testConstraint fileSharing 0
 testConstraint notFileSharing 1
@@ -2578,7 +2579,11 @@ test fCmd-30.2 {file readable on 'NTUSER.DAT'} -constraints {win} -body {
           && [file exists $env(USERPROFILE)/NTUSER.DAT]
           && [file readable $env(USERPROFILE)/NTUSER.DAT]}
 } -result {1}
-test fCmd-30.3 {file readable on 'pagefile.sys'} -constraints {win} -body {
+# At least one CI environment (GitHub Actions) is set up with the page file in
+# an unusual location; skip the test if that is so.
+test fCmd-30.3 {file readable on 'pagefile.sys'} -constraints {
+    win notContinuousIntegration
+} -body {
     set r {}
     if {[info exists env(SystemDrive)]} {
         set path $env(SystemDrive)/pagefile.sys
diff --git a/tests/format.test b/tests/format.test
index 442580e..f7191a6 100644
--- a/tests/format.test
+++ b/tests/format.test
@@ -21,8 +21,12 @@ testConstraint longIs64bit [expr {int(0x8000000000000000) < 0}]
 testConstraint wideIs64bit \
 	[expr {(wide(0x80000000) > 0) && (wide(0x8000000000000000) < 0)}]
 testConstraint wideBiggerThanInt [expr {wide(0x80000000) != int(0x80000000)}]
-testConstraint knownMsvcBug [expr {![info exists ::env(TRAVIS_OS_NAME)] || ![string match windows $::env(TRAVIS_OS_NAME)]}]
-
+# MSVC uses a broken libc that gets sprintf("%g") wrong. This is a pain
+# particularly in Continuous Integration, and there isn't anything much we can
+# do about it.
+testConstraint notWinCI [expr {
+    ($::tcl_platform(platform) ne "windows") || ![info exists ::env(CI)]}]
+
 test format-1.1 {integer formatting} {
     format "%*d %d %d %d" 6 34 16923 -12 -1
 } {    34 16923 -12 -1}
@@ -252,13 +256,13 @@ test format-6.1 {floating-point zeroes} {eformat} {
 test format-6.2 {floating-point zeroes} {eformat} {
     format "%.4e %.4f %.4g" 0.0 0.0 0.0 0.0
 } {0.0000e+00 0.0000 0}
-test format-6.3 {floating-point zeroes} {eformat knownMsvcBug} {
+test format-6.3 {floating-point zeroes} {eformat notWinCI} {
     format "%#.4e %#.4f %#.4g" 0.0 0.0 0.0 0.0
 } {0.0000e+00 0.0000 0.000}
 test format-6.4 {floating-point zeroes} {eformat} {
     format "%.0e %.0f %.0g" 0.0 0.0 0.0 0.0
 } {0e+00 0 0}
-test format-6.5 {floating-point zeroes} {eformat knownMsvcBug} {
+test format-6.5 {floating-point zeroes} {eformat notWinCI} {
     format "%#.0e %#.0f %#.0g" 0.0 0.0 0.0 0.0
 } {0.e+00 0. 0.}
 test format-6.6 {floating-point zeroes} {
@@ -532,14 +536,11 @@ test format-18.1 {do not demote existing numeric values} {
     # Ensure $a and $b are separate objects
     set b 0xaaaa
     append b aaaa
-
     set result [expr {$a == $b}]
     format %08lx $b
     lappend result [expr {$a == $b}]
-
     set b 0xaaaa
     append b aaaa
-
     lappend result [expr {$a == $b}]
     format %08x $b
     lappend result [expr {$a == $b}]
@@ -557,11 +558,9 @@ test format-19.1 {
     set x 0x8fedc654
     list [expr { ~ $x }] [format %08x [expr { ~$x }]]
 } -match regexp -result {-2414724693 f*701239ab}
-
 test format-19.2 {Bug 1867855} {
     format %llx 0
 } 0
-
 test format-19.3 {Bug 2830354} {
     string length [format %340f 0]
 } 340
diff --git a/tests/interp.test b/tests/interp.test
index b5632e1..8159c16 100644
--- a/tests/interp.test
+++ b/tests/interp.test
@@ -3189,7 +3189,7 @@ test interp-34.7 {limits with callbacks: deleting the handler interp} -setup {
 # Bug 1085023
 test interp-34.8 {time limits trigger in vwaits} -body {
     set i [interp create]
-    interp limit $i time -seconds [expr {[clock seconds]+1}] -granularity 1
+    interp limit $i time -seconds [expr {[clock seconds] + 1}] -granularity 1
     $i eval {
 	set x {}
 	vwait x
@@ -3237,8 +3237,8 @@ test interp-34.11 {time limit extension in callbacks} -setup {
 } -body {
     set i [interp create]
     set t0 [clock seconds]
-    $i limit time -seconds [expr {$t0+1}] -granularity 1 \
-	-command "cb1 $i [expr {$t0+2}]"
+    $i limit time -seconds [expr {$t0 + 1}] -granularity 1 \
+	-command "cb1 $i [expr {$t0 + 2}]"
     set ::result {}
     lappend ::result [catch {
 	$i eval {
@@ -3265,8 +3265,8 @@ test interp-34.12 {time limit extension in callbacks} -setup {
 } -body {
     set i [interp create]
     set t0 [clock seconds]
-    set ::times "[expr {$t0+2}] [expr {$t0+100}]"
-    $i limit time -seconds [expr {$t0+1}] -granularity 1 -command "cb1 $i"
+    set ::times "[expr {$t0 + 2}] [expr {$t0 + 100}]"
+    $i limit time -seconds [expr {$t0 + 1}] -granularity 1 -command "cb1 $i"
     set ::result {}
     lappend ::result [catch {
 	$i eval {
@@ -3485,7 +3485,7 @@ test interp-36.7 {SlaveBgerror sets error handler of slave [1999035]} -setup {
     slave eval {
 	variable done {}
 	after 0 error foo
-	after 10 [list ::set [namespace which -variable done] {}]
+	after 20 [list ::set [namespace which -variable done] {}]
 	vwait [namespace which -variable done]
     }
     set result
diff --git a/tests/main.test b/tests/main.test
index 2ea3119..beafca9 100644
--- a/tests/main.test
+++ b/tests/main.test
@@ -101,7 +101,7 @@ namespace eval ::tcl::test::main {
 	Tcl_Main: encoding of script name: system encoding loss
 	Note the shortcoming explained in Tcl Feature Request 491789
     } -constraints {
-	stdio
+	stdio tempNotWin
     } -setup {
 	makeFile {puts [list $argv0 $argv $tcl_interactive]} \u00c0
 	catch {set f [open "|[list [interpreter] \u00c0]" r]}
-- 
cgit v0.12