Check-in [ad7092b843]
Overview
Comment:Updated to use tcltest
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: ad7092b843f0c21a8de914c00b0da3e5b845b26c23bece58eb368f8c5e557210
User & Date: rkeene on 2019-09-16 19:28:04
Other Links: manifest | tags
Context
2019-09-16
19:31
Mark more things as requiring Tcl 8.7 check-in: e4bde431db user: rkeene tags: trunk
19:28
Updated to use tcltest check-in: ad7092b843 user: rkeene tags: trunk
18:36
Fix file permissions such that Tcl thinks it can read these files check-in: 6b8ea28911 user: rkeene tags: trunk
Changes

Modified example/main.tcl from [eabae151b2] to [9e5c601d1d].








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
48
49
50
51
52
53
54

55
56
57
58

59
60

61
62

63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98

99
100
101
102
103
104
105
106
107
108


109
110
111
112
113

114
115


116
117
118
119



120
121
122



123

124




















125
126
127









set dir  "//xvfs:/example"
set dirNative  [file join [pwd] example]


#set dir $dirNative



set file "${dir}/foo"


















set fd [open $file]

seek $fd 0 end
seek $fd -1 current
set check [read $fd 1]
if {$check != "\n"} {
	error "EXPECTED: (new line); GOT: [binary encode hex $check]"
}


close $fd




set fd1 [open $file]
set fd2 [open $file]

set data1 [read $fd1]
close $fd1
set data2 [read $fd2]
close $fd2
if {$data1 != $data2} {
	error "EXPECTED match, differs"
}






set fd [open $file]
seek $fd 0 end
set size [tell $fd]
close $fd
set fd [open $file]
set done false
set calls 0
set output ""

fileevent $fd readable [list apply {{fd} {
	set pos [tell $fd]
	set x [read $fd 1]
	if {[string length $x] == 0} {
		set ::done true
		fileevent $fd readable ""
	}

	lappend ::output $pos
	incr ::calls
}} $fd]
vwait done
if {$calls != ($size + 1)} {
	error "EXPECTED [expr {$size + 1}], got $calls"
}
if {[lsort -integer $output] != $output} {
	error "EXPECTED [lsort -integer $output], GOT $output"
}
close $fd
update idle



proc glob_verify {args} {
	set rv [glob -nocomplain -directory $::dir {*}$args]
	set verify [glob -nocomplain -directory $::dirNative {*}$args]


	if {[llength $rv] != [llength $verify]} {
		error "VERIFY FAILED: glob ... $args ($rv versus $verify)"

	}


	return $rv
}

set check [glob_verify *]
if {[llength $check] < 2} {
	error "EXPECTED >=2, GOT [llength $check] ($check)"
}

set check [glob_verify f*]
if {[llength $check] != 1} {
	error "EXPECTED 1, GOT [llength $check] ($check)"
}

set check [glob_verify ./f*]
if {[llength $check] != 1} {
	error "EXPECTED 1, GOT [llength $check] ($check)"
}

set check [glob_verify -type f ./f*]
if {[llength $check] != 1} {
	error "EXPECTED 1, GOT [llength $check] ($check)"
}

set check [glob_verify -type d ./f*]
if {[llength $check] != 0} {
	error "EXPECTED 0, GOT [llength $check] ($check)"
}

set check [glob_verify x*]
if {[llength $check] != 0} {
	error "EXPECTED 0, GOT [llength $check] ($check)"
}

set check [glob_verify lib/*]
if {[llength $check] != 1} {
	error "EXPECTED 1, GOT [llength $check] ($check)"

}

set check [lindex $check 0]
if {![string match $dir/* $check]} {
	error "EXPECTED \"$dir/*\", GOT $check"
}

set check [glob_verify -type d *]
if {[llength $check] != 1} {
	error "EXPECTED 1, GOT [llength $check] ($check)"


}

set check [glob_verify -type d lib/*]
if {[llength $check] != 1} {
	error "EXPECTED 1, GOT [llength $check] ($check)"

}



cd $dir
cd lib
glob *





# XXX:TODO:CURRENTLY BROKEN
if {0} {



lappend auto_path ${dir}/lib

package require hello




















}

puts "ALL TESTS PASSED"


>
>
>
>
>
>
>
|
|
>
>
|
>
>
>
|
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>


<
<
<
|
>
>

>
>

>
|
|
>




<
<
|
>
>
>
>

>
|


|
|



>












<
<
|
|
<
|

|
|

>
|
<
|

>
|
<
>
|
|
>
|
|
|
|
|
<
|
|
|
|
<
|
|
|
|
<
|
|
|
|
<
|
|
|
|
<
|
|
<
<
<
<
|
<
|
<
>
|
|
|
|
<
|
|
|
|
<
>
>
|
|
|
<
<
>
|
|
>
>
|

|
|
>
>
>

<
<
>
>
>
|
>

>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>



>
>
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
48
49
50
51
52
53


54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81


82
83

84
85
86
87
88
89
90

91
92
93
94

95
96
97
98
99
100
101
102
103

104
105
106
107

108
109
110
111

112
113
114
115

116
117
118
119

120
121




122

123

124
125
126
127
128

129
130
131
132

133
134
135
136
137


138
139
140
141
142
143
144
145
146
147
148
149
150


151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
#! /usr/bin/env tclsh

package require tcltest

tcltest::configure -verbose pbse
tcltest::configure {*}$argv

set rootDir "//xvfs:/example"
set rootDirNative  [file join [pwd] example]
#set rootDir $rootDirNative
set testFile "${rootDir}/foo"

proc glob_verify {args} {
	set rv [glob -nocomplain -directory $::rootDir {*}$args]
	set verify [glob -nocomplain -directory $::rootDirNative {*}$args]

	if {[llength $rv] != [llength $verify]} {
		error "VERIFY FAILED: glob ... $args ($rv versus $verify)"
	}

	return $rv
}

tcltest::customMatch boolean [list apply {{expected actual} {
	if {!!$expected == !!$actual} {
		return true
	} else {
		return false
	}
}}]

tcltest::testConstraint tcl87 [string match "8.7.*" [info patchlevel]]

tcltest::test xvfs-basic-seek "Xvfs Seek Test" -setup {
	set fd [open $testFile]
} -body {
seek $fd 0 end
seek $fd -1 current




	read $fd 1
} -cleanup {
close $fd
	unset fd
} -result "\n"

tcltest::test xvfs-basic-two-files "Xvfs Multiple Open Files Test" -setup {
	set fd1 [open $testFile]
	set fd2 [open $testFile]
} -body {
set data1 [read $fd1]
close $fd1
set data2 [read $fd2]
close $fd2



	expr {$data1 eq $data2}
} -cleanup {
	unset -nocomplain fd1 fd2 data1 data2
} -match boolean -result true

tcltest::test xvfs-events "Xvfs Fileevent Test" -setup {
	set fd [open $testFile]
seek $fd 0 end
set size [tell $fd]
	seek $fd 0 start

set done false
set calls 0
set output ""
} -body {
fileevent $fd readable [list apply {{fd} {
	set pos [tell $fd]
	set x [read $fd 1]
	if {[string length $x] == 0} {
		set ::done true
		fileevent $fd readable ""
	}

	lappend ::output $pos
	incr ::calls
}} $fd]
vwait done



	list [expr {$calls == ($size + 1)}] [expr {[lsort -integer $output] eq $output}]

} -cleanup {
close $fd
	unset -nocomplain fd size done calls output
} -result {1 1}

tcltest::test xvfs-glob-basic-any "Xvfs Glob Match Any Test" -body {
	llength [glob_verify *]

} -result 3

tcltest::test xvfs-glob-basic-limited "Xvfs Glob Match Limited Test" -body {
	llength [glob_verify f*]

} -result 1

tcltest::test xvfs-glob-basic-limited-neg "Xvfs Glob Match Limited Negative Test" -body {
	llength [glob_verify x*]
} -result 0

tcltest::test xvfs-glob-basic-limited-prefixed "Xvfs Glob Match Limited But With Directory Prefix Test" -body {
	llength [glob_verify ./f*]
} -result 1


tcltest::test xvfs-glob-basic-limited-and-typed-prefixed "Xvfs Glob Match Limited Path and Type Positive Test" -body {
	llength [glob_verify -type f ./f*]
} -result 1


tcltest::test xvfs-glob-basic-limited-and-typed-prefixed-neg "Xvfs Glob Match Limited Path and Type Negative Test" -body {
	llength [glob_verify -type d ./f*]
} -result 0


tcltest::test xvfs-glob-basic-limited-prefixed-other-dir-1 "Xvfs Glob Match Directory Included in Search Test (Count)" -body {
	llength [glob_verify lib/*]
} -result 1


tcltest::test xvfs-glob-basic-limited-prefixed-other-dir-2 "Xvfs Glob Match Directory Included in Search Test (Value)" -body {
	lindex [glob_verify lib/*] 0
} -match glob -result "$rootDir/*"


# Broken in Tcl 8.6 and earlier




tcltest::test xvfs-glob-advanced-dir-with-pattern "Xvfs Glob Match Pattern and Directory Together" -body {

	llength [glob //xvfs:/example/*]

} -constraints tcl87 -result 3

tcltest::test xvfs-glob-file-dirname "Xvfs Relies on file dirname" -body {
	lindex [glob -directory [file dirname $testFile] *] 0
} -constraints tcl87 -match glob -result "$rootDir/*"


tcltest::test xvfs-cwd-1 "Xvfs Can Be cwd" -setup {
	set startDir [pwd]
} -body {

	cd $rootDir
	pwd
} -cleanup {
	cd $startDir
	unset startDir


} -result $rootDir

tcltest::test xvfs-cwd-2 "Xvfs Can Be cwd" -setup {
	set startDir [pwd]
} -body {
	cd $rootDir
cd lib
	lindex [glob *] 0
} -cleanup {
	cd $startDir
	unset startDir
} -result "hello"



# Currently broken
tcltest::test xvfs-package "Xvfs Can Be Package Directory" -setup {
	set startAutoPath $auto_path
	lappend auto_path ${rootDir}/lib
} -body {
package require hello
	set auto_path
} -cleanup {
	set auto_path $startAutoPath
	unset startAutoPath
} -constraints knownBug -result ""

# Output results
if {$::tcltest::numTests(Failed) != 0} {
	set format "| %20s | %20s | %20s | %20s |"
	puts [string repeat - [string length [format $format - - - -]]]
	puts [format $format "Passed" "Failed" "Skipped" "Total"]
	puts [format $format \
		$::tcltest::numTests(Passed) \
		$::tcltest::numTests(Failed) \
		$::tcltest::numTests(Skipped) \
		$::tcltest::numTests(Total) \
	]
	puts [string repeat - [string length [format $format - - - -]]]

	exit 1
}

puts "ALL TESTS PASSED"

exit 0