Lines of
example/main.tcl
from check-in 5583d77f1c
that are changed by the sequence of edits moving toward
check-in 12ff77016f:
1: set dir "//xvfs:/example"
2: set dirNative [file join [pwd] example]
3: set file "${dir}/foo"
4:
5: set fd [open $file]
6: seek $fd 0 end
7: seek $fd -1 current
8: set check [read $fd 1]
9: if {$check != "\n"} {
10: error "EXPECTED: (new line); GOT: [binary encode hex $check]"
11: }
12: close $fd
13:
14: set fd1 [open $file]
15: set fd2 [open $file]
16: set data1 [read $fd1]
17: close $fd1
18: set data2 [read $fd2]
19: close $fd2
20: if {$data1 != $data2} {
21: error "EXPECTED match, differs"
22: }
23:
24: set fd [open $file]
25: seek $fd 0 end
26: set size [tell $fd]
27: close $fd
28: set fd [open $file]
29: set done false
30: set calls 0
31: set output ""
32: fileevent $fd readable [list apply {{fd} {
33: set pos [tell $fd]
34: set x [read $fd 1]
35: if {[string length $x] == 0} {
36: set ::done true
37: fileevent $fd readable ""
38: }
39:
40: lappend ::output $pos
41: incr ::calls
42: }} $fd]
43: vwait done
44: if {$calls != ($size + 1)} {
45: error "EXPECTED [expr {$size + 1}], got $calls"
46: }
47: if {[lsort -integer $output] != $output} {
48: error "EXPECTED [lsort -integer $output], GOT $output"
49: }
50: close $fd
51: update idle
52:
53:
54: proc glob_verify {args} {
55: set rv [glob -nocomplain -directory $::dir {*}$args]
56: set verify [glob -nocomplain -directory $::dirNative {*}$args]
57:
58: if {[llength $rv] != [llength $verify]} {
59: error "VERIFY FAILED: glob ... $args ($rv versus $verify)"
60: }
61:
62: return $rv
63: }
64:
65: set check [glob_verify *]
66: if {[llength $check] < 2} {
67: error "EXPECTED >=2, GOT [llength $check] ($check)"
68: }
69:
70: set check [glob_verify f*]
71: if {[llength $check] != 1} {
72: error "EXPECTED 1, GOT [llength $check] ($check)"
73: }
74:
75: set check [glob_verify ./f*]
76: if {[llength $check] != 1} {
77: error "EXPECTED 1, GOT [llength $check] ($check)"
78: }
79:
80: set check [glob_verify -type f ./f*]
81: if {[llength $check] != 1} {
82: error "EXPECTED 1, GOT [llength $check] ($check)"
83: }
84:
85: set check [glob_verify -type d ./f*]
86: if {[llength $check] != 0} {
87: error "EXPECTED 0, GOT [llength $check] ($check)"
88: }
89:
90: set check [glob_verify x*]
91: if {[llength $check] != 0} {
92: error "EXPECTED 0, GOT [llength $check] ($check)"
93: }
94:
95: set check [glob_verify lib/*]
96: if {[llength $check] != 1} {
97: error "EXPECTED 1, GOT [llength $check] ($check)"
98: }
99:
100: set check [lindex $check 0]
101: if {![string match $dir/* $check]} {
102: error "EXPECTED \"$dir/*\", GOT $check"
103: }
104:
105: set check [glob_verify -type d *]
106: if {[llength $check] != 1} {
107: error "EXPECTED 1, GOT [llength $check] ($check)"
108: }
109:
110: puts "ALL TESTS PASSED"