diff options
author | apnadkarni <apnmbx-wits@yahoo.com> | 2023-06-11 02:34:35 (GMT) |
---|---|---|
committer | apnadkarni <apnmbx-wits@yahoo.com> | 2023-06-11 02:34:35 (GMT) |
commit | 9cf727affb1f44a61c77f90a48c92b3a70e6d8b4 (patch) | |
tree | eb7b02519851fa039477326729ed61ba56ea68cc | |
parent | 5140d2419c9c9705ba10631ce5367690f670dabc (diff) | |
download | tcl-9cf727affb1f44a61c77f90a48c92b3a70e6d8b4.zip tcl-9cf727affb1f44a61c77f90a48c92b3a70e6d8b4.tar.gz tcl-9cf727affb1f44a61c77f90a48c92b3a70e6d8b4.tar.bz2 |
Tests for invalidly encoded file names and env (TIP 671 motivation)
-rw-r--r-- | tests/env.test | 21 | ||||
-rw-r--r-- | tests/fileName.test | 22 |
2 files changed, 42 insertions, 1 deletions
diff --git a/tests/env.test b/tests/env.test index 7debb2f..345567b 100644 --- a/tests/env.test +++ b/tests/env.test @@ -18,6 +18,11 @@ if {"::tcltest" ni [namespace children]} { source [file join [file dirname [info script]] tcltests.tcl] +testConstraint utf8system [string equal [encoding system] utf-8] +if {[llength [auto_execok bash]]} { + testConstraint haveBash 1 +} + # [exec] is required here to see the actual environment received by child # processes. proc getenv {} { @@ -508,6 +513,22 @@ test env-9.1 { } } -result {} +test env-10.0 { + Unequal environment strings test should test unequal +} -constraints {unix haveBash utf8system knownBug} -setup { + set tclScript [makeFile { + puts [string equal $env(XX) $env(YY)] + } tclScript] + set shellCode { + export XX=$'\351' + export YY=$'\303\251' + } + append shellCode "[info nameofexecutable] $tclScript\n" + set shScript [makeFile $shellCode shScript] +} -body { + exec {*}[auto_execok bash] $shScript +} -result 0 + # cleanup diff --git a/tests/fileName.test b/tests/fileName.test index be424e2..46f1c5e 100644 --- a/tests/fileName.test +++ b/tests/fileName.test @@ -1610,7 +1610,27 @@ test fileName-20.10 {globbing for special chars} -setup { removeFile fileName-20.10 $s removeDirectory sub [file home] } -result [file home]/sub/fileName-20.10 - +test fileName-20.11 {glob dir with undecodable file names} -setup { + # Specifically use /tmp as on WSL [temporaryDirectory] + # on NTFS prevents creation of arbitrary byte sequences in names. + set prevDir [pwd] + set testDir /tmp/tcltest/fileName-20.11 + file delete -force $testDir; # Clear it + file mkdir $testDir + cd $testDir + set prevEnc [encoding system] + # Create a file name that is invalid if interpreted as utf-8 + encoding system iso8859-1 + close [open \xe9 w] +} -cleanup { + encoding system $prevEnc + cd $prevDir + file delete -force $testDir +} -constraints {unix knownBug} -body { + set result [file exists [lindex [glob *] 0]] + encoding system utf-8 + lappend result [file exists [lindex [glob *] 0]] +} -result {1 1} apply [list {} { test fileName-6d4e9d1af5bf5b7d { |