summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorapnadkarni <apnmbx-wits@yahoo.com>2023-04-05 04:47:52 (GMT)
committerapnadkarni <apnmbx-wits@yahoo.com>2023-04-05 04:47:52 (GMT)
commit543bde3f267b817f06c56f74d3480c691866ecb1 (patch)
treee542ef53f829700969740db4e9d1f5b3e9a4a845 /tests
parentd9bef75f08c6f69d631963242bdd1b887f8cb093 (diff)
parent096c6ef84ff367ccee30eb44d9833fe3f61c45cc (diff)
downloadtcl-543bde3f267b817f06c56f74d3480c691866ecb1.zip
tcl-543bde3f267b817f06c56f74d3480c691866ecb1.tar.gz
tcl-543bde3f267b817f06c56f74d3480c691866ecb1.tar.bz2
Merge 9.0
Diffstat (limited to 'tests')
-rw-r--r--tests/chanio.test23
-rw-r--r--tests/io.test82
2 files changed, 80 insertions, 25 deletions
diff --git a/tests/chanio.test b/tests/chanio.test
index 09e71ca..c3caa1c 100644
--- a/tests/chanio.test
+++ b/tests/chanio.test
@@ -6868,7 +6868,7 @@ test chan-io-52.9 {TclCopyChannel & encodings} {fcopy} {
[file size $path(utf8-fcopy.txt)] \
[file size $path(utf8-rp.txt)]
} {3 5 5}
-test chan-io-52.10 {TclCopyChannel & encodings} {fcopy} {
+test chan-io-52.10 {TclCopyChannel & encodings} {fcopy notWinCI} {
# encoding to binary (=> implies that the internal utf-8 is written)
set in [open $path(kyrillic.txt) r]
set out [open $path(utf8-fcopy.txt) w]
@@ -6886,18 +6886,23 @@ test chan-io-52.11 {TclCopyChannel & encodings} -setup {
puts $f АА
close $f
} -constraints {fcopy} -body {
- # binary to encoding => the input has to be in utf-8 to make sense to the
- # encoder
set in [open $path(utf8-fcopy.txt) r]
set out [open $path(kyrillic.txt) w]
# -translation binary is also -encoding binary
chan configure $in -translation binary
- chan configure $out -encoding koi8-r -translation lf
- chan copy $in $out
- chan close $in
- chan close $out
- file size $path(kyrillic.txt)
-} -result 3
+ chan configure $out -encoding koi8-r -translation lf -profile strict
+ catch {chan copy $in $out} cres copts
+ return $cres
+} -cleanup {
+ if {$in in [chan names]} {
+ close $in
+ }
+ if {$out in [chan names]} {
+ close $out
+ }
+ catch {unset cres}
+} -match glob -result {error writing "*": invalid or incomplete\
+ multibyte or wide character}
test chan-io-53.1 {CopyData} -setup {
file delete $path(test1)
diff --git a/tests/io.test b/tests/io.test
index 96e5ea6..5fd255c 100644
--- a/tests/io.test
+++ b/tests/io.test
@@ -7500,7 +7500,7 @@ test io-52.9 {TclCopyChannel & encodings} {fcopy} {
[file size $path(utf8-fcopy.txt)] \
[file size $path(utf8-rp.txt)]
} {3 5 5}
-test io-52.10 {TclCopyChannel & encodings} {fcopy} {
+test io-52.10 {TclCopyChannel & encodings} {fcopy notWinCI} {
# encoding to binary (=> implies that the
# internal utf-8 is written)
@@ -7519,26 +7519,27 @@ test io-52.10 {TclCopyChannel & encodings} {fcopy} {
} 5
test io-52.11 {TclCopyChannel & encodings} -setup {
set out [open $path(utf8-fcopy.txt) w]
- fconfigure $out -encoding utf-8 -translation lf
- puts $out "АА"
+ fconfigure $out -encoding utf-8 -translation lf -profile strict
+ puts $out АА
close $out
} -constraints {fcopy} -body {
- # binary to encoding => the input has to be
- # in utf-8 to make sense to the encoder
-
set in [open $path(utf8-fcopy.txt) r]
set out [open $path(kyrillic.txt) w]
-
# -translation binary is also -encoding binary
fconfigure $in -translation binary
- fconfigure $out -encoding koi8-r -translation lf
-
- fcopy $in $out
- close $in
- close $out
-
- file size $path(kyrillic.txt)
-} -result 3
+ fconfigure $out -encoding koi8-r -translation lf -profile strict
+ catch {fcopy $in $out} cres copts
+ return $cres
+} -cleanup {
+ if {$in in [chan names]} {
+ close $in
+ }
+ if {$out in [chan names]} {
+ close $out
+ }
+ catch {unset cres}
+} -match glob -result {error writing "*": invalid or incomplete\
+ multibyte or wide character}
test io-52.12 {coverage of -translation auto} {
file delete $path(test1) $path(test2)
@@ -7780,6 +7781,29 @@ test io-52.23 {TclCopyChannel & encodings} -setup {
unset ::s0
} -match glob -result {0 {error writing "file*": invalid or incomplete multibyte or wide character}}
+test io-52.24 {fcopy -size should always be characters} -setup {
+ set out [open utf8-fcopy-52.24.txt w]
+ fconfigure $out -encoding utf-8 -translation lf
+ puts $out "Á"
+ close $out
+} -constraints {fcopy} -body {
+ set in [open utf8-fcopy-52.24.txt r]
+ set out [open utf8-fcopy-52.24.out.txt w+]
+
+ fconfigure $in -encoding utf-8 -profile tcl8
+ fconfigure $out -encoding utf-8 -profile tcl8
+ fcopy $in $out -size 1
+ seek $out 0
+ # a result of \xc3 means that only the first byte of the utf-8 encoding of
+ # Á made it into to the output file.
+ read $out
+} -cleanup {
+ close $in
+ close $out
+ catch {file delete utf8-fcopy-52.24.txt}
+ catch {file delete utf8-fcopy-52.24.out.txt}
+} -result Á
+
test io-53.1 {CopyData} {fcopy} {
file delete $path(test1)
@@ -8276,7 +8300,7 @@ test io-53.11 {Bug 2895565} -setup {
removeFile out
removeFile in
} -result {40 bytes copied}
-test io-53.12 {CopyData: foreground short reads, aka bug 3096275} {stdio unix fcopy} {
+test io-53.12.0 {CopyData: foreground short reads, aka bug 3096275} {stdio unix fcopy} {
file delete $path(pipe)
set f1 [open $path(pipe) w]
puts -nonewline $f1 {
@@ -8295,6 +8319,32 @@ test io-53.12 {CopyData: foreground short reads, aka bug 3096275} {stdio unix fc
close $f1
list $::done $ch
} {ok A}
+test io-53.12.1 {
+ Issue 9ca87e6286262a62.
+ CopyData: foreground short reads via ReadChars().
+ Related to report 3096275 for ReadBytes().
+
+ Prior to the fix this test waited forever for read() to return.
+} {stdio unix fcopy} {
+ file delete $path(output)
+ set f1 [open $path(output) w]
+ puts -nonewline $f1 {
+ chan configure stdin -encoding iso8859-1 -translation lf -buffering none
+ fcopy stdin stdout
+ }
+ close $f1
+ set f1 [open "|[list [info nameofexecutable] $path(output)]" r+]
+ try {
+ chan configure $f1 -encoding utf-8 -buffering none
+ puts -nonewline $f1 A
+ set ch [read $f1 1]
+ } finally {
+ if {$f1 in [chan names]} {
+ close $f1
+ }
+ }
+ lindex $ch
+} A
test io-53.13 {TclCopyChannel: read error reporting} -setup {
proc driver {cmd args} {
variable buffer