summaryrefslogtreecommitdiffstats
path: root/tests/fileSystemEncoding.test
blob: 12683b207e5ff25f4a9262b1452bb0c7875de375 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!  /usr/bin/env tclsh

# Copyright (c) 2019 Poor Yorick

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
}