aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--jim-aio.c2
-rw-r--r--jim-file.c7
-rw-r--r--tests/aio.test14
-rw-r--r--tests/exec2.test4
-rw-r--r--tests/file.test9
-rw-r--r--tests/history.test6
-rw-r--r--tests/posix.test12
7 files changed, 34 insertions, 20 deletions
diff --git a/jim-aio.c b/jim-aio.c
index b234106..06d9fa8 100644
--- a/jim-aio.c
+++ b/jim-aio.c
@@ -1016,7 +1016,7 @@ static int aio_cmd_eof(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
AioFile *af = Jim_CmdPrivData(interp);
- Jim_SetResultInt(interp, feof(af->fp));
+ Jim_SetResultInt(interp, !!feof(af->fp));
return JIM_OK;
}
diff --git a/jim-file.c b/jim-file.c
index dabda90..5967261 100644
--- a/jim-file.c
+++ b/jim-file.c
@@ -607,7 +607,12 @@ static int file_cmd_rename(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
argv[1]);
return JIM_ERR;
}
-
+#if ISWINDOWS
+ if (access(dest, F_OK) == 0) {
+ /* Windows won't rename over an existing file */
+ remove(dest);
+ }
+#endif
if (rename(source, dest) != 0) {
Jim_SetResultFormatted(interp, "error renaming \"%#s\" to \"%#s\": %s", argv[0], argv[1],
strerror(errno));
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"}