summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2022-03-18 13:04:39 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2022-03-18 13:04:39 (GMT)
commitd8c018f1a22a3dd5e68107869456c01488a13823 (patch)
tree22c14f7fe334900423f4510679eb8d33995a5ae9
parent21c68a2e1d7a0c5a9b78091d5dffd972a01dede8 (diff)
downloadtcl-d8c018f1a22a3dd5e68107869456c01488a13823.zip
tcl-d8c018f1a22a3dd5e68107869456c01488a13823.tar.gz
tcl-d8c018f1a22a3dd5e68107869456c01488a13823.tar.bz2
Add proper cleanup to testcases
-rw-r--r--tests/chanio.test30
-rw-r--r--tests/http.test1
-rw-r--r--tests/io.test30
3 files changed, 41 insertions, 20 deletions
diff --git a/tests/chanio.test b/tests/chanio.test
index 578dc9f..38f3d90 100644
--- a/tests/chanio.test
+++ b/tests/chanio.test
@@ -249,7 +249,7 @@ test chan-io-3.3 {WriteChars: compatibility with WriteBytes: flush on line} -bod
} -cleanup {
chan close $f
} -result "\r\n12"
-test chan-io-3.4 {WriteChars: loop over stage buffer} deprecated {
+test chan-io-3.4 {WriteChars: loop over stage buffer} -constraints deprecated -body {
# stage buffer maps to more than can be queued at once.
set f [open $path(test1) w]
chan configure $f -encoding jis0208 -buffersize 16
@@ -257,8 +257,10 @@ test chan-io-3.4 {WriteChars: loop over stage buffer} deprecated {
set x [list [contents $path(test1)]]
chan close $f
lappend x [contents $path(test1)]
-} [list "!)!)!)!)!)!)!)!)" "!)!)!)!)!)!)!)!)!)!)!)!)!)!)!)"]
-test chan-io-3.5 {WriteChars: saved != 0} deprecated {
+} -cleanup {
+ catch {chan close $f}
+} -result [list "!)!)!)!)!)!)!)!)" "!)!)!)!)!)!)!)!)!)!)!)!)!)!)!)"]
+test chan-io-3.5 {WriteChars: saved != 0} -constraints deprecated -body {
# Bytes produced by UtfToExternal from end of last channel buffer had to
# be moved to beginning of next channel buffer to preserve requested
# buffersize.
@@ -268,8 +270,10 @@ test chan-io-3.5 {WriteChars: saved != 0} deprecated {
set x [list [contents $path(test1)]]
chan close $f
lappend x [contents $path(test1)]
-} [list "!)!)!)!)!)!)!)!)!" "!)!)!)!)!)!)!)!)!)!)!)!)!)!)!)"]
-test chan-io-3.6 {WriteChars: (stageRead + dstWrote == 0)} {
+} -cleanup {
+ catch {chan close $f}
+} -result [list "!)!)!)!)!)!)!)!)!" "!)!)!)!)!)!)!)!)!)!)!)!)!)!)!)"]
+test chan-io-3.6 {WriteChars: (stageRead + dstWrote == 0)} -body {
# One incomplete UTF-8 character at end of staging buffer. Backup in src
# to the beginning of that UTF-8 character and try again.
#
@@ -284,8 +288,10 @@ test chan-io-3.6 {WriteChars: (stageRead + dstWrote == 0)} {
set x [list [contents $path(test1)]]
chan close $f
lappend x [contents $path(test1)]
-} [list "12345678901234\x82\x60" "12345678901234\x82\x60\x82\x61"]
-test chan-io-3.7 {WriteChars: (bufPtr->nextAdded > bufPtr->length)} deprecated {
+} -cleanup {
+ catch {chan close $f}
+} -result [list "12345678901234\x82\x60" "12345678901234\x82\x60\x82\x61"]
+test chan-io-3.7 {WriteChars: (bufPtr->nextAdded > bufPtr->length)} -constraints deprecated -body {
# When translating UTF-8 to external, the produced bytes went past end of
# the channel buffer. This is done on purpose - we then truncate the bytes
# at the end of the partial character to preserve the requested blocksize
@@ -297,8 +303,10 @@ test chan-io-3.7 {WriteChars: (bufPtr->nextAdded > bufPtr->length)} deprecated {
set x [list [contents $path(test1)]]
chan close $f
lappend x [contents $path(test1)]
-} [list "!)!)!)!)!)!)!)!)!" "!)!)!)!)!)!)!)!)!)!)!)!)!)!)!)"]
-test chan-io-3.8 {WriteChars: reset sawLF after each buffer} {
+} -cleanup {
+ catch {chan close $f}
+} -result [list "!)!)!)!)!)!)!)!)!" "!)!)!)!)!)!)!)!)!)!)!)!)!)!)!)"]
+test chan-io-3.8 {WriteChars: reset sawLF after each buffer} -body {
set f [open $path(test1) w]
chan configure $f -encoding ascii -buffering line -translation lf \
-buffersize 16
@@ -306,7 +314,9 @@ test chan-io-3.8 {WriteChars: reset sawLF after each buffer} {
set x [list [contents $path(test1)]]
chan close $f
lappend x [contents $path(test1)]
-} [list "abcdefg\nhijklmno" "abcdefg\nhijklmnopqrstuvwxyz"]
+} -cleanup {
+ catch {chan close $f}
+} -result [list "abcdefg\nhijklmno" "abcdefg\nhijklmnopqrstuvwxyz"]
test chan-io-4.1 {TranslateOutputEOL: lf} {
# search for \n
diff --git a/tests/http.test b/tests/http.test
index 93998fe..a34b168 100644
--- a/tests/http.test
+++ b/tests/http.test
@@ -15,6 +15,7 @@ if {"::tcltest" ni [namespace children]} {
package require tcltest 2.5
namespace import -force ::tcltest::*
}
+package require tcltests
if {[catch {package require http 2} version]} {
if {[info exists http2]} {
diff --git a/tests/io.test b/tests/io.test
index 821b11e..e22fa8a 100644
--- a/tests/io.test
+++ b/tests/io.test
@@ -268,7 +268,7 @@ test io-3.3 {WriteChars: compatibility with WriteBytes: flush on line} {
close $f
set x
} "\r\n12"
-test io-3.4 {WriteChars: loop over stage buffer} deprecated {
+test io-3.4 {WriteChars: loop over stage buffer} -constraints deprecated -body {
# stage buffer maps to more than can be queued at once.
set f [open $path(test1) w]
@@ -277,8 +277,10 @@ test io-3.4 {WriteChars: loop over stage buffer} deprecated {
set x [list [contents $path(test1)]]
close $f
lappend x [contents $path(test1)]
-} [list "!)!)!)!)!)!)!)!)" "!)!)!)!)!)!)!)!)!)!)!)!)!)!)!)"]
-test io-3.5 {WriteChars: saved != 0} deprecated {
+} -cleanup {
+ catch {close $f}
+} -result [list "!)!)!)!)!)!)!)!)" "!)!)!)!)!)!)!)!)!)!)!)!)!)!)!)"]
+test io-3.5 {WriteChars: saved != 0} -constraints deprecated -body {
# Bytes produced by UtfToExternal from end of last channel buffer
# had to be moved to beginning of next channel buffer to preserve
# requested buffersize.
@@ -289,7 +291,9 @@ test io-3.5 {WriteChars: saved != 0} deprecated {
set x [list [contents $path(test1)]]
close $f
lappend x [contents $path(test1)]
-} [list "!)!)!)!)!)!)!)!)!" "!)!)!)!)!)!)!)!)!)!)!)!)!)!)!)"]
+} -cleanup {
+ catch {close $f}
+} -result [list "!)!)!)!)!)!)!)!)!" "!)!)!)!)!)!)!)!)!)!)!)!)!)!)!)"]
test io-3.6 {WriteChars: (stageRead + dstWrote == 0)} {
# One incomplete UTF-8 character at end of staging buffer. Backup
# in src to the beginning of that UTF-8 character and try again.
@@ -307,7 +311,7 @@ test io-3.6 {WriteChars: (stageRead + dstWrote == 0)} {
close $f
lappend x [contents $path(test1)]
} [list "12345678901234\x82\x60" "12345678901234\x82\x60\x82\x61"]
-test io-3.7 {WriteChars: (bufPtr->nextAdded > bufPtr->length)} deprecated {
+test io-3.7 {WriteChars: (bufPtr->nextAdded > bufPtr->length)} -constraints deprecated -body {
# When translating UTF-8 to external, the produced bytes went past end
# of the channel buffer. This is done purpose -- we then truncate the
# bytes at the end of the partial character to preserve the requested
@@ -320,7 +324,9 @@ test io-3.7 {WriteChars: (bufPtr->nextAdded > bufPtr->length)} deprecated {
set x [list [contents $path(test1)]]
close $f
lappend x [contents $path(test1)]
-} [list "!)!)!)!)!)!)!)!)!" "!)!)!)!)!)!)!)!)!)!)!)!)!)!)!)"]
+} -cleanup {
+ catch {close $f}
+} -result [list "!)!)!)!)!)!)!)!)!" "!)!)!)!)!)!)!)!)!)!)!)!)!)!)!)"]
test io-3.8 {WriteChars: reset sawLF after each buffer} {
set f [open $path(test1) w]
fconfigure $f -encoding ascii -buffering line -translation lf \
@@ -1532,7 +1538,7 @@ test io-12.8 {ReadChars: multibyte chars split} {
close $f
scan [string index $in end] %c
} 160
-test io-12.9 {ReadChars: multibyte chars split} deprecated {
+test io-12.9 {ReadChars: multibyte chars split} -constraints deprecated -body {
set f [open $path(test1) w]
fconfigure $f -translation binary
puts -nonewline $f [string repeat a 9]\xC2
@@ -1542,8 +1548,10 @@ test io-12.9 {ReadChars: multibyte chars split} deprecated {
set in [read $f]
close $f
scan [string index $in end] %c
-} 194
-test io-12.10 {ReadChars: multibyte chars split} deprecated {
+} -cleanup {
+ catch {close $f}
+} -result 194
+test io-12.10 {ReadChars: multibyte chars split} -constraints deprecated -body {
set f [open $path(test1) w]
fconfigure $f -translation binary
puts -nonewline $f [string repeat a 9]\xC2
@@ -1553,7 +1561,9 @@ test io-12.10 {ReadChars: multibyte chars split} deprecated {
set in [read $f]
close $f
scan [string index $in end] %c
-} 194
+} -cleanup {
+ catch {close $f}
+} -result 194
test io-13.1 {TranslateInputEOL: cr mode} {} {
set f [open $path(test1) w]