diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/fileSystemEncoding.test | 51 | ||||
-rw-r--r-- | tests/tcltests.tcl | 37 |
2 files changed, 86 insertions, 2 deletions
diff --git a/tests/fileSystemEncoding.test b/tests/fileSystemEncoding.test new file mode 100644 index 0000000..fa67646 --- /dev/null +++ b/tests/fileSystemEncoding.test @@ -0,0 +1,51 @@ +#! /usr/bin/env tclsh + +# Copyright (c) 2019 Poor Yorick + +if {[string equal $::tcl_platform(os) "Windows NT"]} { + return +} + +namespace eval ::tcl::test::fileSystemEncoding { + package require tcltest 2 + namespace import ::tcltest::* + + variable fname1 \u767b\u9e1b\u9d72\u6a13 + + proc autopath {} { + global auto_path + set scriptpath [info script] + set scriptpathnorm [file dirname [file normalize $scriptpath/...]] + set dirnorm [file dirname $scriptpathnorm] + set idx [lsearch -exact $auto_path $dirnorm] + if {$idx >= 0} { + set auto_path [lreplace $auto_path[set auto_path {}] $idx $idx {}] + } + set auto_path [linsert $auto_path[set auto_path {}] 0 0 $dirnorm] + } + autopath + + package require tcltests + + test filesystemEncoding-1.0 { + issue bcd100410465 + } -body { + set dir [tcltests::tempdir] + set saved [encoding system] + encoding system iso8859-1 + set fname1a $dir/$fname1 + set utf8name [encoding convertto utf-8 $fname1a] + makeFile {} $utf8name + set globbed [lindex [glob -directory $dir *] 0] + encoding system utf-8 + lappend res [file exists $globbed] + encoding system iso8859-1 + lappend res [file exists $globbed] + return $res + } -cleanup { + file delete -force $dir + encoding system $saved + } -result {0 1} + + cleanupTests +} diff --git a/tests/tcltests.tcl b/tests/tcltests.tcl index c8759a8..c3c8650 100644 --- a/tests/tcltests.tcl +++ b/tests/tcltests.tcl @@ -2,7 +2,6 @@ package require tcltest 2.2 namespace import ::tcltest::* - testConstraint exec [llength [info commands exec]] testConstraint fcopy [llength [info commands fcopy]] testConstraint fileevent [llength [info commands fileevent]] @@ -10,4 +9,38 @@ testConstraint thread [ expr {0 == [catch {package require Thread 2.7-}]}] testConstraint notValgrind [expr {![testConstraint valgrind]}] -package provide tcltests 0.1
\ No newline at end of file + +namespace eval ::tcltests { + + + proc init {} { + if {[namespace which ::tcl::file::tempdir] eq {}} { + interp alias {} [namespace current]::tempdir {} [ + namespace current]::tempdir_alternate + } else { + interp alias {} [namespace current]::tempdir {} ::tcl::file::tempdir + } + } + + + proc tempdir_alternate {} { + file tempfile tempfile + set tmpdir [file dirname $tempfile] + set execname [info nameofexecutable] + regsub -all {[^[:alpha:][:digit:]]} $execname _ execname + for {set i 0} {$i < 10000} {incr i} { + set time [clock milliseconds] + set name $tmpdir/${execname}_${time}_$i + if {![file exists $name]} { + file mkdir $name + return $name + } + } + error [list {could not create temporary directory}] + } + + init + + package provide tcltests 0.1 +} + |