From 9366d8f76430fac4c64be6dd99e44a13ed4c2fb9 Mon Sep 17 00:00:00 2001 From: Steve Bennett Date: Mon, 4 May 2020 22:19:53 +1000 Subject: tests: Fixes to recent tests for windows Mostly just avoiding running certain tests, but also: - rename() won't overwrite an existing file on Windows - ensure that eof returns 0 or 1 - in aio.test, create and read the file in binary mode Signed-off-by: Steve Bennett --- tests/aio.test | 14 +++++++++----- tests/exec2.test | 4 ++-- tests/file.test | 9 ++++++--- tests/history.test | 6 ++++-- tests/posix.test | 12 ++++++------ 5 files changed, 27 insertions(+), 18 deletions(-) (limited to 'tests') diff --git a/tests/aio.test b/tests/aio.test index d3f5931..501b9a6 100644 --- a/tests/aio.test +++ b/tests/aio.test @@ -1,9 +1,13 @@ source [file dirname [info script]]/testing.tcl needs constraint jim +testCmdConstraints socket -makeFile {test-data} testdata.in -set f [open testdata.in] +# Create and open in binary mode for compatibility between Windows and Unix +set f [open testdata.in wb] +$f puts test-data +$f close +set f [open testdata.in rb] defer { $f close @@ -102,15 +106,15 @@ test aio-6.3 {eof} { $f eof } {1} -test aio-7.1 {close args} -body { +test aio-7.1 {close args} -constraints socket -body { $f close badopt } -returnCodes error -result {bad option "badopt": must be -nodelete, r, or w} -test aio-7.2 {close w on non-socket} -body { +test aio-7.2 {close w on non-socket} -constraints socket -body { $f close w } -returnCodes error -result {Socket operation on non-socket} -test aio-7.3 {close -nodelete on non-socket} -body { +test aio-7.3 {close -nodelete on non-socket} -constraints socket -body { $f close -nodelete } -returnCodes error -result {not supported} diff --git a/tests/exec2.test b/tests/exec2.test index 253d251..b96555c 100644 --- a/tests/exec2.test +++ b/tests/exec2.test @@ -156,10 +156,10 @@ test exec2-5.5 {wait for all children} -body { } # reap zombies, there should not be any wait - sleep 0.3 + after 300 # reap zombies, 2-3 should be finished now wait - sleep 0.4 + after 400 # reap zombies, all processes should be finished now wait } -result {} diff --git a/tests/file.test b/tests/file.test index 73eb481..f0a0d44 100644 --- a/tests/file.test +++ b/tests/file.test @@ -5,6 +5,7 @@ catch {file link} msg testConstraint filelink [string match "wrong # args:*" $msg] catch {file lstat} msg testConstraint filelstat [string match "wrong # args:*" $msg] +testConstraint unix [expr {$tcl_platform(platform) eq "unix"}] test join-1.1 "One name" { file join abc @@ -360,10 +361,12 @@ test mtime-1.3 {file mtime} -body { test mtime-1.4 {file mtime} { set mtime [file mtime [info script]] file stat [info script] s - expr {$mtime - $s(mtime)} -} {0} + if {$mtime != $s(mtime)} { + error "mtime was $mtime but s(mtime) was $s(mtime)" + } +} {} -test mtime-1.5 {file mtime} -body { +test mtime-1.5 {file mtime} -constraints unix -body { set name tmp.[pid] makeFile testing $name set t [file mtime [info script]] diff --git a/tests/history.test b/tests/history.test index 178a107..2f4a3cb 100644 --- a/tests/history.test +++ b/tests/history.test @@ -36,8 +36,10 @@ test history-1.6 {history completion} { history completion {} } {} -file delete $name +catch { + file delete $name +} -# Can't really tests history add, show, setcompletion +# Can't really test history add, show, setcompletion testreport diff --git a/tests/posix.test b/tests/posix.test index 74423cb..f34ced7 100644 --- a/tests/posix.test +++ b/tests/posix.test @@ -3,11 +3,11 @@ source [file dirname [info script]]/testing.tcl needs constraint jim testCmdConstraints os.getids os.gethostname os.uptime os.fork -test posix-1.1 {os.getids usage} -body { +test posix-1.1 {os.getids usage} -constraints os.getids -body { os.getids blah } -returnCodes error -result {wrong # args: should be "os.getids"} -test posix-1.2 {os.getids} -body { +test posix-1.2 {os.getids} -constraints os.getids -body { set uid [exec id -u] set d [os.getids] if {$d(uid) != $uid} { @@ -16,21 +16,21 @@ test posix-1.2 {os.getids} -body { } -result {} -test posix-1.4 {os.uptime} -body { +test posix-1.4 {os.uptime} -constraints os.uptime -body { string is integer -strict [os.uptime] } -result {1} -test posix-1.5 {os.gethostname usage} -body { +test posix-1.5 {os.gethostname usage} -constraints os.gethostname -body { os.gethostname blah } -returnCodes error -result {wrong # args: should be "os.gethostname"} -test posix-1.6 {os.gethostname} -body { +test posix-1.6 {os.gethostname} -constraints os.gethostname -body { if {[exec hostname] ne [os.gethostname]} { error "os.gethostname did not match system hostname" } } -result {} -test posix-1.7 {os.fork usage} -body { +test posix-1.7 {os.fork usage} -constraints os.fork -body { os.fork extra args } -returnCodes error -result {wrong # args: should be "os.fork"} -- cgit v1.1