Fossil SCM

Reworked the UTF-8 file name classification tests along two lines: * Stratify the type checks so that a new `-utf-assurance=smoke` test level checks only one of each type. A higher =ci level is the prior level of test redundancy, and a new =stress level is merciless. * Take the actual filesystem behavior into account by probing once at tester.tcl startup time so we don't have to hard-code a static "failure expected" flag and hope we got it all right. We now *predict* behavior at runtime and report divergences. This cuts the test/unicode-pathnames.tcl runtime to a third. It doesn't save much, net, since the total was only a few seconds, but there's more to the above than speed.

wyoung 2026-11-20 17:18 UTC test-suite-new
Commit 08ba27d8908ef23469115054179e5fcab52cedbfaf8f9355211d9f1e630ad63c
+22 -1
--- test/README.md
+++ test/README.md
@@ -31,12 +31,33 @@
3131
* `-keep` leaves the temporary repositories in place.
3232
* `-prot` also writes the output to the file `prot`.
3333
* `-trials N` sets how many random trials fuzz tests (delta1, merge2, …)
3434
run per input kind. The default is 20 (5 for expensive `large` /
3535
`repeats` inputs). Use `-trials 100` for the historical full fuzz.
36
+ This flag is only the fuzz loop count; it does not select
37
+ unicode-pathnames cases.
38
+* `-utf-assurance smoke|ci|stress` selects how many Unicode
39
+ case-folding pairs `unicode-pathnames` runs. The default is `smoke`
40
+ (one pair per fold-behavior class). `ci` runs the full hand-written
41
+ lists. `stress` adds generated pairs on top of `ci`. At startup the
42
+ harness classifies the temporary filesystem once (ASCII case,
43
+ NFC/NFD, and sharp-s versus `ss`) and `unicode-pathnames` predicts
44
+ match, miss, or untestable from that classification together with
45
+ Fossil's `case-sensitive` setting (byte-for-byte when on; Unicode
46
+ D145 caseless match when off). Unmet predictions fail the run, so a
47
+ caseless lookup Fossil still mishandles is a real failure rather than
48
+ a static `knownBug`.
49
+
50
+ `make test TESTFLAGS="-quiet update"` passes options and names via `make`.
51
+
52
+Unicode case-folding recipes:
3653
37
- `make test TESTFLAGS="-quiet update"` passes options and names via `make`.
54
+```sh
55
+make test # smoke (default)
56
+make test TESTFLAGS="-utf-assurance ci" # full current lists
57
+make test TESTFLAGS="-utf-assurance stress" # ci plus generated pairs
58
+```
3859
3960
A full run normally takes a few minutes. `tester.tcl` exits with status 0 when all tests pass, 1 when one or more tests fail. Failed tests are reported with
4061
what it expected vs what it got. The summary lists skipped files with a reason, and all known bugs reported as `FAILED (knownBug)`. Skips and known bugs do not
4162
change the exit status unless `-strict` is given.
4263
4364
--- test/README.md
+++ test/README.md
@@ -31,12 +31,33 @@
31 * `-keep` leaves the temporary repositories in place.
32 * `-prot` also writes the output to the file `prot`.
33 * `-trials N` sets how many random trials fuzz tests (delta1, merge2, …)
34 run per input kind. The default is 20 (5 for expensive `large` /
35 `repeats` inputs). Use `-trials 100` for the historical full fuzz.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
37 `make test TESTFLAGS="-quiet update"` passes options and names via `make`.
 
 
 
 
38
39 A full run normally takes a few minutes. `tester.tcl` exits with status 0 when all tests pass, 1 when one or more tests fail. Failed tests are reported with
40 what it expected vs what it got. The summary lists skipped files with a reason, and all known bugs reported as `FAILED (knownBug)`. Skips and known bugs do not
41 change the exit status unless `-strict` is given.
42
43
--- test/README.md
+++ test/README.md
@@ -31,12 +31,33 @@
31 * `-keep` leaves the temporary repositories in place.
32 * `-prot` also writes the output to the file `prot`.
33 * `-trials N` sets how many random trials fuzz tests (delta1, merge2, …)
34 run per input kind. The default is 20 (5 for expensive `large` /
35 `repeats` inputs). Use `-trials 100` for the historical full fuzz.
36 This flag is only the fuzz loop count; it does not select
37 unicode-pathnames cases.
38 * `-utf-assurance smoke|ci|stress` selects how many Unicode
39 case-folding pairs `unicode-pathnames` runs. The default is `smoke`
40 (one pair per fold-behavior class). `ci` runs the full hand-written
41 lists. `stress` adds generated pairs on top of `ci`. At startup the
42 harness classifies the temporary filesystem once (ASCII case,
43 NFC/NFD, and sharp-s versus `ss`) and `unicode-pathnames` predicts
44 match, miss, or untestable from that classification together with
45 Fossil's `case-sensitive` setting (byte-for-byte when on; Unicode
46 D145 caseless match when off). Unmet predictions fail the run, so a
47 caseless lookup Fossil still mishandles is a real failure rather than
48 a static `knownBug`.
49
50 `make test TESTFLAGS="-quiet update"` passes options and names via `make`.
51
52 Unicode case-folding recipes:
53
54 ```sh
55 make test # smoke (default)
56 make test TESTFLAGS="-utf-assurance ci" # full current lists
57 make test TESTFLAGS="-utf-assurance stress" # ci plus generated pairs
58 ```
59
60 A full run normally takes a few minutes. `tester.tcl` exits with status 0 when all tests pass, 1 when one or more tests fail. Failed tests are reported with
61 what it expected vs what it got. The summary lists skipped files with a reason, and all known bugs reported as `FAILED (knownBug)`. Skips and known bugs do not
62 change the exit status unless `-strict` is given.
63
64
+69 -1
--- test/tester.tcl
+++ test/tester.tcl
@@ -21,11 +21,12 @@
2121
# tclsh ../test/tester.tcl ./fossil
2222
# tclsh ../test/tester.tcl ./fossil -quiet merge1 update
2323
#
2424
# The first argument is the fossil executable to test, followed by
2525
# the test files, so "update" runs test/update.test. See test/README.md
26
-# for details of options such as -strict, -halt, -prot, -trials etc.
26
+# for details of options such as -strict, -halt, -prot, -trials,
27
+# -utf-assurance etc.
2728
#
2829
2930
# Minimum Tcl is 8.6. auto.def should have found us a suitable Tcl
3031
# installation. Care is needed to keep compatible with both 8.6 and 9.0.
3132
package require Tcl 8.6-
@@ -88,10 +89,27 @@
8889
exit 1
8990
}
9091
set TRIALS_EXPLICIT 1
9192
set argv [lreplace $argv $i [expr {$i + 1}]]
9293
}
94
+
95
+# Unicode case-folding assurance level for unicode-pathnames.test.
96
+# Unrelated to -trials. smoke ⊂ ci ⊂ stress; default is smoke.
97
+set UTF_ASSURANCE smoke
98
+set i [lsearch -exact $argv -utf-assurance]
99
+if {$i >= 0} {
100
+ if {$i + 1 >= [llength $argv]} {
101
+ puts stderr "missing value for -utf-assurance"
102
+ exit 1
103
+ }
104
+ set UTF_ASSURANCE [lindex $argv [expr {$i + 1}]]
105
+ if {$UTF_ASSURANCE ni {smoke ci stress}} {
106
+ puts stderr "-utf-assurance requires smoke, ci, or stress"
107
+ exit 1
108
+ }
109
+ set argv [lreplace $argv $i [expr {$i + 1}]]
110
+}
93111
94112
if {[llength $argv]==0} {
95113
foreach f [lsort [glob $testfiledir/*.test]] {
96114
set base [file root [file tail $f]]
97115
lappend argv $base
@@ -587,10 +605,53 @@
587605
if {$heavy && !$::TRIALS_EXPLICIT} {
588606
return [expr {min(5, $::TRIALS)}]
589607
}
590608
return $::TRIALS
591609
}
610
+
611
+# Return the -utf-assurance level: smoke, ci, or stress.
612
+proc test_utf_assurance {} {
613
+ return $::UTF_ASSURANCE
614
+}
615
+
616
+# After writing PATH A under DIR, return 1 if PATH B names the same
617
+# directory entry on this volume.
618
+proc fs_paths_collide {dir a b} {
619
+ set pa [file join $dir $a]
620
+ set pb [file join $dir $b]
621
+ set parent [file dirname $pa]
622
+ if {![file isdirectory $parent]} {
623
+ file mkdir $parent
624
+ }
625
+ write_file $pa "fs-probe"
626
+ return [file exists $pb]
627
+}
628
+
629
+# Classify the temporary volume once: whether ASCII case, NFC vs NFD,
630
+# and sharp-s vs "ss" collapse to one directory entry. Stores a dict
631
+# on ::fs_type with keys ascii_case, normalization, and sharp_s, each
632
+# 1 when the two spellings are one entry. Called at harness startup
633
+# for every run, independent of -utf-assurance.
634
+proc fs_classify {} {
635
+ set dir [file join $::tempPath fs_classify_[pid]]
636
+ file mkdir $dir
637
+ set savedEncoding [encoding system]
638
+ encoding system utf-8
639
+ set ascii [fs_paths_collide $dir Readme.txt readme.txt]
640
+ catch {file delete -force {*}[glob -nocomplain -directory $dir *]}
641
+ set norm [fs_paths_collide $dir "\u00e9.txt" "e\u0301.txt"]
642
+ catch {file delete -force {*}[glob -nocomplain -directory $dir *]}
643
+ set sharp [fs_paths_collide $dir "stra\u00dfe.txt" strasse.txt]
644
+ encoding system $savedEncoding
645
+ catch {file delete -force $dir}
646
+ set ::fs_type [dict create \
647
+ ascii_case $ascii \
648
+ normalization $norm \
649
+ sharp_s $sharp]
650
+ protOut "***** filesystem type:\
651
+ascii_case=$ascii normalization=$norm sharp_s=$sharp" 1
652
+}
592653
593654
# This procedure only returns non-zero if the Tcl integration feature was
594655
# enabled at compile-time and is now enabled at runtime.
595656
proc is_tcl_usable_by_fossil {} {
596657
fossil test-th-eval "hasfeature tcl"
@@ -1167,10 +1228,17 @@
11671228
}
11681229
11691230
11701231
protInit $fossilexe
11711232
protOut "***** Testing $fossilexe"
1233
+protOut "***** utf-assurance: $::UTF_ASSURANCE" 1
1234
+
1235
+# Classify the temp volume before any .test file runs. Always, for
1236
+# every -utf-assurance level and even when unicode-pathnames is not
1237
+# among the files under test.
1238
+fs_classify
1239
+
11721240
set ::tempKeepHome 1
11731241
11741242
# Start in tempHomePath to help avoid errors with require_no_open_checkout
11751243
set startPwd [pwd]
11761244
cd $tempHomePath
11771245
--- test/tester.tcl
+++ test/tester.tcl
@@ -21,11 +21,12 @@
21 # tclsh ../test/tester.tcl ./fossil
22 # tclsh ../test/tester.tcl ./fossil -quiet merge1 update
23 #
24 # The first argument is the fossil executable to test, followed by
25 # the test files, so "update" runs test/update.test. See test/README.md
26 # for details of options such as -strict, -halt, -prot, -trials etc.
 
27 #
28
29 # Minimum Tcl is 8.6. auto.def should have found us a suitable Tcl
30 # installation. Care is needed to keep compatible with both 8.6 and 9.0.
31 package require Tcl 8.6-
@@ -88,10 +89,27 @@
88 exit 1
89 }
90 set TRIALS_EXPLICIT 1
91 set argv [lreplace $argv $i [expr {$i + 1}]]
92 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93
94 if {[llength $argv]==0} {
95 foreach f [lsort [glob $testfiledir/*.test]] {
96 set base [file root [file tail $f]]
97 lappend argv $base
@@ -587,10 +605,53 @@
587 if {$heavy && !$::TRIALS_EXPLICIT} {
588 return [expr {min(5, $::TRIALS)}]
589 }
590 return $::TRIALS
591 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
592
593 # This procedure only returns non-zero if the Tcl integration feature was
594 # enabled at compile-time and is now enabled at runtime.
595 proc is_tcl_usable_by_fossil {} {
596 fossil test-th-eval "hasfeature tcl"
@@ -1167,10 +1228,17 @@
1167 }
1168
1169
1170 protInit $fossilexe
1171 protOut "***** Testing $fossilexe"
 
 
 
 
 
 
 
1172 set ::tempKeepHome 1
1173
1174 # Start in tempHomePath to help avoid errors with require_no_open_checkout
1175 set startPwd [pwd]
1176 cd $tempHomePath
1177
--- test/tester.tcl
+++ test/tester.tcl
@@ -21,11 +21,12 @@
21 # tclsh ../test/tester.tcl ./fossil
22 # tclsh ../test/tester.tcl ./fossil -quiet merge1 update
23 #
24 # The first argument is the fossil executable to test, followed by
25 # the test files, so "update" runs test/update.test. See test/README.md
26 # for details of options such as -strict, -halt, -prot, -trials,
27 # -utf-assurance etc.
28 #
29
30 # Minimum Tcl is 8.6. auto.def should have found us a suitable Tcl
31 # installation. Care is needed to keep compatible with both 8.6 and 9.0.
32 package require Tcl 8.6-
@@ -88,10 +89,27 @@
89 exit 1
90 }
91 set TRIALS_EXPLICIT 1
92 set argv [lreplace $argv $i [expr {$i + 1}]]
93 }
94
95 # Unicode case-folding assurance level for unicode-pathnames.test.
96 # Unrelated to -trials. smoke ⊂ ci ⊂ stress; default is smoke.
97 set UTF_ASSURANCE smoke
98 set i [lsearch -exact $argv -utf-assurance]
99 if {$i >= 0} {
100 if {$i + 1 >= [llength $argv]} {
101 puts stderr "missing value for -utf-assurance"
102 exit 1
103 }
104 set UTF_ASSURANCE [lindex $argv [expr {$i + 1}]]
105 if {$UTF_ASSURANCE ni {smoke ci stress}} {
106 puts stderr "-utf-assurance requires smoke, ci, or stress"
107 exit 1
108 }
109 set argv [lreplace $argv $i [expr {$i + 1}]]
110 }
111
112 if {[llength $argv]==0} {
113 foreach f [lsort [glob $testfiledir/*.test]] {
114 set base [file root [file tail $f]]
115 lappend argv $base
@@ -587,10 +605,53 @@
605 if {$heavy && !$::TRIALS_EXPLICIT} {
606 return [expr {min(5, $::TRIALS)}]
607 }
608 return $::TRIALS
609 }
610
611 # Return the -utf-assurance level: smoke, ci, or stress.
612 proc test_utf_assurance {} {
613 return $::UTF_ASSURANCE
614 }
615
616 # After writing PATH A under DIR, return 1 if PATH B names the same
617 # directory entry on this volume.
618 proc fs_paths_collide {dir a b} {
619 set pa [file join $dir $a]
620 set pb [file join $dir $b]
621 set parent [file dirname $pa]
622 if {![file isdirectory $parent]} {
623 file mkdir $parent
624 }
625 write_file $pa "fs-probe"
626 return [file exists $pb]
627 }
628
629 # Classify the temporary volume once: whether ASCII case, NFC vs NFD,
630 # and sharp-s vs "ss" collapse to one directory entry. Stores a dict
631 # on ::fs_type with keys ascii_case, normalization, and sharp_s, each
632 # 1 when the two spellings are one entry. Called at harness startup
633 # for every run, independent of -utf-assurance.
634 proc fs_classify {} {
635 set dir [file join $::tempPath fs_classify_[pid]]
636 file mkdir $dir
637 set savedEncoding [encoding system]
638 encoding system utf-8
639 set ascii [fs_paths_collide $dir Readme.txt readme.txt]
640 catch {file delete -force {*}[glob -nocomplain -directory $dir *]}
641 set norm [fs_paths_collide $dir "\u00e9.txt" "e\u0301.txt"]
642 catch {file delete -force {*}[glob -nocomplain -directory $dir *]}
643 set sharp [fs_paths_collide $dir "stra\u00dfe.txt" strasse.txt]
644 encoding system $savedEncoding
645 catch {file delete -force $dir}
646 set ::fs_type [dict create \
647 ascii_case $ascii \
648 normalization $norm \
649 sharp_s $sharp]
650 protOut "***** filesystem type:\
651 ascii_case=$ascii normalization=$norm sharp_s=$sharp" 1
652 }
653
654 # This procedure only returns non-zero if the Tcl integration feature was
655 # enabled at compile-time and is now enabled at runtime.
656 proc is_tcl_usable_by_fossil {} {
657 fossil test-th-eval "hasfeature tcl"
@@ -1167,10 +1228,17 @@
1228 }
1229
1230
1231 protInit $fossilexe
1232 protOut "***** Testing $fossilexe"
1233 protOut "***** utf-assurance: $::UTF_ASSURANCE" 1
1234
1235 # Classify the temp volume before any .test file runs. Always, for
1236 # every -utf-assurance level and even when unicode-pathnames is not
1237 # among the files under test.
1238 fs_classify
1239
1240 set ::tempKeepHome 1
1241
1242 # Start in tempHomePath to help avoid errors with require_no_open_checkout
1243 set startPwd [pwd]
1244 cd $tempHomePath
1245
--- test/unicode-pathnames.test
+++ test/unicode-pathnames.test
@@ -25,29 +25,24 @@
2525
# off, two pathnames are the same file when they are a canonical
2626
# caseless match (the Unicode Standard, section 3.13, definition D145):
2727
# equal after canonical decomposition and case folding. A file system
2828
# that ignores case and normalization has one file for both names.
2929
#
30
-# With the setting off, fossil folds the ASCII letters and compares
31
-# every other byte as written, so the tests of names outside ASCII are
32
-# marked knownBug. Fossil also checks out, updates to and commits a
33
-# version that has two names for one file, so those tests are marked
34
-# knownBug for ASCII names too.
35
-#
36
-# On macOS fossil_path_to_utf8 (src/utf8.c) recomposes each argument
37
-# before fossil compares it; see the comments there for details and
38
-# Apple references. The loop below clears knownBug for pairs where
39
-# fossil_path_to_utf8 will convert to the checked-in name, such that
40
-# "fossil test-echo" prints the converted argument.
30
+# The harness classifies the temporary volume once at startup
31
+# (::fs_type). This file predicts match, miss, or untestable from
32
+# that classification, Fossil argv rewriting, and the rules above.
33
+# -utf-assurance selects how many pairs to run: smoke (one per
34
+# behavior class), ci (the lists below), or stress (ci plus generated
35
+# pairs). Unmet predictions fail the run.
4136
#
4237
# Case folding maps both the sharp s, U+00DF, and the capital sharp s,
4338
# U+1E9E, to the two letters "ss", so by D145 a name with a sharp s and
4439
# the same name with "ss" are one file. ext4 with case folding folds
4540
# each sharp s to "ss" and has one file for the two names. NTFS and
4641
# HFS+ convert each character to one character, and have two files.
47
-# The sharp-s tests expect one file, because a check-out of both names
48
-# loses a file on a file system that has one file for them.
42
+# Collide tests require two names on disk, so they are skipped when
43
+# ::fs_type says this volume has one entry for the pair.
4944
#
5045
5146
require_no_open_checkout
5247
5348
# Fossil reads the pathnames on its command line, and Tcl reads
@@ -54,10 +49,13 @@
5449
# fossil's output, in the system encoding.
5550
#
5651
set upSavedEncoding [encoding system]
5752
encoding system utf-8
5853
54
+set upPredMet 0
55
+set upPredUnmet 0
56
+
5957
# Returns NAME with each character outside ASCII written as a Tcl
6058
# escape, so that two spellings that look the same can be distinguished.
6159
#
6260
proc up_escape {name} {
6361
set escaped ""
@@ -85,59 +83,159 @@
8583
proc up_new_version {} {
8684
regexp {New_Version: ([0-9a-f]+)} $::RESULT -> hash
8785
return $hash
8886
}
8987
90
-# Each row is a label, the pathname that is checked in, another
91
-# spelling of it, and the constraint for the tests that need fossil to
92
-# treat the two as one name.
93
-#
94
-set upSame [list \
95
- ascii readme.txt README.TXT "" \
96
- ascii-dir dir/notes.txt DIR/Notes.TXT "" \
97
- latin "\u00e4rger.txt" "\u00c4RGER.TXT" knownBug \
88
+# Which ::fs_type key governs whether this volume stores A and B as one
89
+# directory entry. Case-only pairs use ascii_case; NFC/NFD and
90
+# compatibility decompositions use normalization; sharp-s uses sharp_s.
91
+#
92
+proc up_fs_key {label} {
93
+ switch -exact -- $label {
94
+ sharp-s - capital-sharp-s - stress-sharp {
95
+ return sharp_s
96
+ }
97
+ nfd - nfd-case - nfd-dir - marks - kana - arabic - angstrom -
98
+ hangul - han-compat - devanagari - stress-nfd {
99
+ return normalization
100
+ }
101
+ default {
102
+ return ascii_case
103
+ }
104
+ }
105
+}
106
+
107
+# Return 1 when ::fs_type says this volume has one directory entry for
108
+# the two spellings of LABEL.
109
+#
110
+proc up_fs_collides {label} {
111
+ return [dict get $::fs_type [up_fs_key $label]]
112
+}
113
+
114
+# Return 1 when fossil test-echo rewrites B to the checked-in spelling A.
115
+#
116
+proc up_argv_maps {a b} {
117
+ fossil test-echo $b
118
+ return [expr {[string first "argv\[2\] = \[$a\]" $::RESULT] >= 0}]
119
+}
120
+
121
+# Record whether ACTUAL equals EXPECTED for prediction NAME.
122
+#
123
+proc up_expect {name actual expected} {
124
+ set ok [expr {$actual eq $expected}]
125
+ if {$ok} {
126
+ incr ::upPredMet
127
+ } else {
128
+ incr ::upPredUnmet
129
+ }
130
+ test_eq $name $actual $expected
131
+}
132
+
133
+# Each row is a label, the pathname that is checked in, and another
134
+# spelling that is a D145 caseless match (or treated as one file in
135
+# the header for compatibility pairs).
136
+#
137
+set upSameAll [list \
138
+ ascii readme.txt README.TXT \
139
+ ascii-dir dir/notes.txt DIR/Notes.TXT \
140
+ latin "\u00e4rger.txt" "\u00c4RGER.TXT" \
98141
greek "\u03b1\u03c1\u03c7\u03b5\u03af\u03bf.txt" \
99
- "\u0391\u03a1\u03a7\u0395\u038a\u039f.TXT" knownBug \
142
+ "\u0391\u03a1\u03a7\u0395\u038a\u039f.TXT" \
100143
cyrillic "\u0444\u0430\u0439\u043b.txt" \
101
- "\u0424\u0410\u0419\u041b.TXT" knownBug \
144
+ "\u0424\u0410\u0419\u041b.TXT" \
102145
sigma "\u03bf\u03b4\u03cc\u03c2.txt" \
103
- "\u039f\u0394\u038c\u03a3.TXT" knownBug \
104
- nfd "r\u00e9sum\u00e9.txt" "re\u0301sume\u0301.txt" knownBug \
105
- nfd-case "cr\u00e8me.txt" "CRE\u0300ME.TXT" knownBug \
106
- marks "\u1ead.txt" "a\u0323\u0302.txt" knownBug \
107
- angstrom "\u00e5.txt" "\u212b.TXT" knownBug \
146
+ "\u039f\u0394\u038c\u03a3.TXT" \
147
+ nfd "r\u00e9sum\u00e9.txt" "re\u0301sume\u0301.txt" \
148
+ nfd-case "cr\u00e8me.txt" "CRE\u0300ME.TXT" \
149
+ marks "\u1ead.txt" "a\u0323\u0302.txt" \
150
+ angstrom "\u00e5.txt" "\u212b.TXT" \
108151
hangul "\ud55c\uae00.txt" \
109
- "\u1112\u1161\u11ab\u1100\u1173\u11af.txt" knownBug \
110
- nfd-dir "caf\u00e9/menu.txt" "CAFE\u0301/MENU.TXT" knownBug \
111
- sharp-s "stra\u00dfe.txt" "STRASSE.TXT" knownBug \
112
- capital-sharp-s "gro\u00df.txt" "GRO\u1e9e.TXT" knownBug \
113
- han "\u4e2d\u6587.txt" "\u4e2d\u6587.TXT" "" \
114
- han-compat "\u8c48.txt" "\uf900.txt" knownBug \
152
+ "\u1112\u1161\u11ab\u1100\u1173\u11af.txt" \
153
+ nfd-dir "caf\u00e9/menu.txt" "CAFE\u0301/MENU.TXT" \
154
+ sharp-s "stra\u00dfe.txt" "STRASSE.TXT" \
155
+ capital-sharp-s "gro\u00df.txt" "GRO\u1e9e.TXT" \
156
+ han "\u4e2d\u6587.txt" "\u4e2d\u6587.TXT" \
157
+ han-compat "\u8c48.txt" "\uf900.txt" \
115158
kana "\u30ac\u30d1.txt" \
116
- "\u30ab\u3099\u30cf\u309a.txt" knownBug \
159
+ "\u30ab\u3099\u30cf\u309a.txt" \
117160
fullwidth "\uff46\uff49\uff4c\uff45.txt" \
118
- "\uff26\uff29\uff2c\uff25.TXT" knownBug \
161
+ "\uff26\uff29\uff2c\uff25.TXT" \
119162
arabic "\u0623\u062d\u0645\u062f.txt" \
120
- "\u0627\u0654\u062d\u0645\u062f.txt" knownBug \
121
- devanagari "\u0915\u093c.txt" "\u0958.txt" knownBug \
163
+ "\u0627\u0654\u062d\u0645\u062f.txt" \
164
+ devanagari "\u0915\u093c.txt" "\u0958.txt" \
122165
]
123166
124167
# Each row is a label, the pathname that is checked in, and a pathname
125
-# that is a different file with the setting on or off: a letter without
126
-# its accent, a letter with another accent, a digit in place of its
127
-# superscript form, a simplified Chinese character in place of the
128
-# traditional one, katakana in place of hiragana, and ASCII letters in
129
-# place of fullwidth ones.
168
+# that is a different file with the setting on or off.
130169
#
131
-set upDifferent [list \
170
+set upDifferentAll [list \
132171
accent "expos\u00e9.txt" expose.txt \
133172
other-mark "\u00e5ngstr.txt" "\u00e4ngstr.txt" \
134173
superscript "x\u00b2.txt" x2.txt \
135174
han-variant "\u6a94\u6848.txt" "\u6863\u6848.txt" \
136175
kana-script "\u304b\u306a.txt" "\u30ab\u30ca.txt" \
137176
fullwidth-ascii "\uff41\uff42.txt" ab.txt \
138177
]
178
+
179
+set upCollideAll [list \
180
+ ascii readme.txt README.TXT \
181
+ latin "\u00e4rger.txt" "\u00c4RGER.TXT" \
182
+ nfd "r\u00e9sum\u00e9.txt" "re\u0301sume\u0301.txt" \
183
+ nfd-case "cr\u00e8me.txt" "CRE\u0300ME.TXT" \
184
+ sharp-s "stra\u00dfe.txt" "STRASSE.TXT" \
185
+]
186
+
187
+# Smoke: one pair per behavior class.
188
+set upSmokeSame {ascii latin sigma nfd sharp-s han-compat}
189
+set upSmokeDifferent {accent}
190
+set upSmokeCollide {ascii}
191
+
192
+# Stress-only pairs (not in the ci lists).
193
+set upStressSame [list \
194
+ stress-latin "\u00f6ffentlich.txt" "\u00d6FFENTLICH.TXT" \
195
+ stress-nfd "na\u00efve.txt" "nai\u0308ve.txt" \
196
+ stress-sharp "gro\u00dfartig.txt" "GROSSARTIG.TXT" \
197
+]
198
+set upStressDifferent [list \
199
+ stress-miss "caf\u00e9.txt" cafe.txt \
200
+]
201
+set upStressCollide [list \
202
+ stress-latin "\u00f6ffentlich.txt" "\u00d6FFENTLICH.TXT" \
203
+ stress-nfd "na\u00efve.txt" "nai\u0308ve.txt" \
204
+]
205
+
206
+# Build the pair lists for the current -utf-assurance level.
207
+#
208
+proc up_select {all smokeLabels} {
209
+ set level [test_utf_assurance]
210
+ if {$level eq "smoke"} {
211
+ set out [list]
212
+ foreach {label a b} $all {
213
+ if {$label in $smokeLabels} {
214
+ lappend out $label $a $b
215
+ }
216
+ }
217
+ return $out
218
+ }
219
+ return $all
220
+}
221
+
222
+set upSame [up_select $upSameAll $upSmokeSame]
223
+set upDifferent [up_select $upDifferentAll $upSmokeDifferent]
224
+set upCollide [up_select $upCollideAll $upSmokeCollide]
225
+
226
+if {[test_utf_assurance] eq "stress"} {
227
+ foreach {label a b} $upStressSame {
228
+ lappend upSame $label $a $b
229
+ }
230
+ foreach {label a b} $upStressDifferent {
231
+ lappend upDifferent $label $a $b
232
+ }
233
+ foreach {label a b} $upStressCollide {
234
+ lappend upCollide $label $a $b
235
+ }
236
+}
139237
140238
###############################################################################
141239
#
142240
# One spelling of each pathname is checked in and on disk. Fossil is
143241
# then given the other spelling.
@@ -144,11 +242,11 @@
144242
#
145243
test_setup
146244
fossil settings case-sensitive 1
147245
148246
set upNames [list]
149
-foreach {label a b constraint} $upSame {
247
+foreach {label a b} $upSame {
150248
file mkdir [file dirname $a]
151249
write_file $a "$label\n"
152250
lappend upNames $a
153251
}
154252
foreach {label a b} $upDifferent {
@@ -160,111 +258,101 @@
160258
161259
fossil ls
162260
test_eq unicode-pathnames-ls [lsort [split [normalize_result] \n]] \
163261
[lsort $upNames]
164262
165
-# upConverted lists the pairs whose other spelling fossil converts to
166
-# the checked-in one when it reads its arguments. Each is one name to
167
-# fossil, so its tests with the setting off are not marked knownBug.
263
+# upConverted lists pairs whose other spelling fossil rewrites to the
264
+# checked-in name when it reads its arguments.
168265
#
169266
set upConverted [list]
170
-set upRows [list]
171
-foreach {label a b constraint} $upSame {
172
- fossil test-echo $b
173
- if {[string first "argv\[2\] = \[$a\]" $RESULT] >= 0} {
267
+foreach {label a b} $upSame {
268
+ if {[up_argv_maps $a $b]} {
174269
lappend upConverted $label
175
- set constraint ""
176270
}
177
- lappend upRows $label $a $b $constraint
178271
}
179
-set upSame $upRows
180272
181273
# With the setting on, the other spelling is not a file under
182
-# management, unless fossil converts it.
274
+# management, unless fossil converts it. Positive: converted pairs
275
+# find the file. Negative: unconverted pairs do not.
183276
#
184
-foreach {label a b constraint} $upSame {
277
+foreach {label a b} $upSame {
185278
up_show $label $a $b
186279
set converted [expr {$label in $upConverted}]
187280
fossil ls $b
188
- test_eq unicode-pathnames-on-$label-ls [normalize_result] \
281
+ up_expect unicode-pathnames-on-$label-ls [normalize_result] \
189282
[expr {$converted ? $a : ""}]
190283
fossil cat $b {*}[expr {$converted ? "" : "-expectError"}]
191
- test_eq unicode-pathnames-on-$label-cat $CODE [expr {!$converted}]
284
+ up_expect unicode-pathnames-on-$label-cat $CODE [expr {!$converted}]
192285
}
193286
194
-# With the setting off, "fossil ls", "fossil cat" and "fossil rm" find
195
-# the file by its other spelling.
287
+# With the setting off, D145 matches must be found by the other
288
+# spelling; upDifferent pairs must not.
196289
#
197290
fossil settings case-sensitive 0
198291
199
-foreach {label a b constraint} $upSame {
292
+foreach {label a b} $upSame {
200293
up_show $label $a $b
201294
fossil ls $b
202
- test_eq unicode-pathnames-off-$label-ls [normalize_result] $a $constraint
203
- fossil cat $b {*}[expr {$constraint eq "" ? "" : "-$constraint"}]
204
- test_eq unicode-pathnames-off-$label-cat [normalize_result] $label \
205
- $constraint
295
+ up_expect unicode-pathnames-off-$label-ls [normalize_result] $a
296
+ fossil cat $b
297
+ up_expect unicode-pathnames-off-$label-cat-code $CODE 0
298
+ up_expect unicode-pathnames-off-$label-cat [normalize_result] $label
206299
fossil rm --soft -n $b
207
- test_eq unicode-pathnames-off-$label-rm [normalize_result] "DELETED $a" \
208
- $constraint
300
+ up_expect unicode-pathnames-off-$label-rm [normalize_result] "DELETED $a"
209301
}
210302
211303
foreach {label a b} $upDifferent {
212304
up_show $label $a $b
213305
fossil ls $b
214
- test_eq unicode-pathnames-off-$label-ls [normalize_result] ""
306
+ up_expect unicode-pathnames-off-$label-ls [normalize_result] ""
215307
fossil cat $b -expectError
216
- test_eq unicode-pathnames-off-$label-cat $CODE 1
308
+ up_expect unicode-pathnames-off-$label-cat $CODE 1
217309
fossil rm --soft -n $b
218
- test_eq unicode-pathnames-off-$label-rm [normalize_result] ""
310
+ up_expect unicode-pathnames-off-$label-rm [normalize_result] ""
219311
}
220312
221313
# A file on disk under the other spelling is not an extra file, and
222
-# "fossil add" does not add it. These tests need a file system that
223
-# has two files for the two spellings.
314
+# "fossil add" does not add it. Needs a volume that stores two names.
224315
#
225316
set upOneFile [list]
226
-foreach {label a b constraint} $upSame {
317
+foreach {label a b} $upSame {
227318
up_show $label $a $b
228
- if {[file exists $b] || $label in $upConverted} {
319
+ if {[up_fs_collides $label] || $label in $upConverted} {
320
+ lappend upOneFile $label
321
+ continue
322
+ }
323
+ # Confirm the working tree still has two distinct entries.
324
+ if {[file exists $b]} {
229325
lappend upOneFile $label
230326
continue
231327
}
232328
file mkdir [file dirname $b]
233329
write_file $b "other spelling\n"
234330
fossil extras
235
- test_eq unicode-pathnames-off-$label-extras [normalize_result] "" \
236
- $constraint
331
+ up_expect unicode-pathnames-off-$label-extras [normalize_result] ""
237332
fossil add $b
238333
fossil changes
239
- test_eq unicode-pathnames-off-$label-add [normalize_result] "" $constraint
334
+ up_expect unicode-pathnames-off-$label-add [normalize_result] ""
240335
fossil revert
241336
file delete $b
242337
if {[file dirname $b] ne "."} {
243
- file delete [file dirname $b]
338
+ catch {file delete [file dirname $b]}
244339
}
245340
}
246341
if {[llength $upOneFile] > 0} {
247342
test_skip_part "extras and add tests of [join $upOneFile {, }]:\
248
- fossil or the file system has one name for both spellings"
343
+ filesystem type or argv rewriting has one name for both spellings\
344
+ (fs_type: $::fs_type)"
249345
}
250346
251347
###############################################################################
252348
#
253349
# A version made with the setting on has both spellings of a pathname.
254
-# With the setting off, fossil does not commit from a check-out of that
255
-# version and does not update to it, because a file system that has one
256
-# file for both names would give both the same content.
257
-#
258
-set upCollide [list \
259
- ascii readme.txt README.TXT \
260
- latin "\u00e4rger.txt" "\u00c4RGER.TXT" \
261
- nfd "r\u00e9sum\u00e9.txt" "re\u0301sume\u0301.txt" \
262
- nfd-case "cr\u00e8me.txt" "CRE\u0300ME.TXT" \
263
- sharp-s "stra\u00dfe.txt" "STRASSE.TXT" \
264
-]
265
-
350
+# With the setting off, fossil must refuse to commit from a check-out of
351
+# that version and refuse to update to it, because a file system that
352
+# has one file for both names would give both the same content.
353
+#
266354
set upOneFile [list]
267355
foreach {label a b} $upCollide {
268356
up_show $label $a $b
269357
test_setup
270358
fossil settings case-sensitive 1
@@ -271,11 +359,15 @@
271359
write_file $a "first spelling\n"
272360
write_file plain.txt "plain\n"
273361
fossil add $a plain.txt
274362
fossil commit -m "first spelling"
275363
set upFirst [up_new_version]
276
- if {[file exists $b] || $label in $upConverted} {
364
+ set converted [up_argv_maps $a $b]
365
+ if {$converted} {
366
+ lappend upConverted $label
367
+ }
368
+ if {[up_fs_collides $label] || $converted || [file exists $b]} {
277369
lappend upOneFile $label
278370
continue
279371
}
280372
write_file $b "second spelling\n"
281373
fossil add $b
@@ -282,26 +374,31 @@
282374
fossil commit -m "second spelling"
283375
set upBoth [up_new_version]
284376
285377
fossil settings case-sensitive 0
286378
write_file plain.txt "edited\n"
287
- fossil commit -m "edit plain.txt" -expectError -knownBug
288
- test_eq unicode-pathnames-collide-$label-commit $CODE 1 knownBug
379
+ fossil commit -m "edit plain.txt" -expectError
380
+ up_expect unicode-pathnames-collide-$label-commit $CODE 1
289381
290382
fossil settings case-sensitive 1
291383
fossil revert
292384
fossil update $upFirst
293385
fossil settings case-sensitive 0
294
- fossil update $upBoth -expectError -knownBug
295
- test_eq unicode-pathnames-collide-$label-update $CODE 1 knownBug
296
- test_eq unicode-pathnames-collide-$label-update-file [file exists $b] 0 \
297
- knownBug
386
+ fossil update $upBoth -expectError
387
+ up_expect unicode-pathnames-collide-$label-update $CODE 1
388
+ up_expect unicode-pathnames-collide-$label-update-file \
389
+ [file exists $b] 0
298390
}
299391
if {[llength $upOneFile] > 0} {
300392
test_skip_part "commit and update tests of [join $upOneFile {, }]:\
301
- fossil or the file system has one name for both spellings"
393
+ filesystem type or argv rewriting has one name for both spellings\
394
+ (fs_type: $::fs_type)"
302395
}
303396
304397
###############################################################################
305398
399
+protOut "***** unicode-pathnames predictions:\
400
+met=$upPredMet unmet=$upPredUnmet"
401
+test unicode-pathnames-predictions-met {$upPredUnmet == 0}
402
+
306403
encoding system $upSavedEncoding
307404
test_cleanup
308405
--- test/unicode-pathnames.test
+++ test/unicode-pathnames.test
@@ -25,29 +25,24 @@
25 # off, two pathnames are the same file when they are a canonical
26 # caseless match (the Unicode Standard, section 3.13, definition D145):
27 # equal after canonical decomposition and case folding. A file system
28 # that ignores case and normalization has one file for both names.
29 #
30 # With the setting off, fossil folds the ASCII letters and compares
31 # every other byte as written, so the tests of names outside ASCII are
32 # marked knownBug. Fossil also checks out, updates to and commits a
33 # version that has two names for one file, so those tests are marked
34 # knownBug for ASCII names too.
35 #
36 # On macOS fossil_path_to_utf8 (src/utf8.c) recomposes each argument
37 # before fossil compares it; see the comments there for details and
38 # Apple references. The loop below clears knownBug for pairs where
39 # fossil_path_to_utf8 will convert to the checked-in name, such that
40 # "fossil test-echo" prints the converted argument.
41 #
42 # Case folding maps both the sharp s, U+00DF, and the capital sharp s,
43 # U+1E9E, to the two letters "ss", so by D145 a name with a sharp s and
44 # the same name with "ss" are one file. ext4 with case folding folds
45 # each sharp s to "ss" and has one file for the two names. NTFS and
46 # HFS+ convert each character to one character, and have two files.
47 # The sharp-s tests expect one file, because a check-out of both names
48 # loses a file on a file system that has one file for them.
49 #
50
51 require_no_open_checkout
52
53 # Fossil reads the pathnames on its command line, and Tcl reads
@@ -54,10 +49,13 @@
54 # fossil's output, in the system encoding.
55 #
56 set upSavedEncoding [encoding system]
57 encoding system utf-8
58
 
 
 
59 # Returns NAME with each character outside ASCII written as a Tcl
60 # escape, so that two spellings that look the same can be distinguished.
61 #
62 proc up_escape {name} {
63 set escaped ""
@@ -85,59 +83,159 @@
85 proc up_new_version {} {
86 regexp {New_Version: ([0-9a-f]+)} $::RESULT -> hash
87 return $hash
88 }
89
90 # Each row is a label, the pathname that is checked in, another
91 # spelling of it, and the constraint for the tests that need fossil to
92 # treat the two as one name.
93 #
94 set upSame [list \
95 ascii readme.txt README.TXT "" \
96 ascii-dir dir/notes.txt DIR/Notes.TXT "" \
97 latin "\u00e4rger.txt" "\u00c4RGER.TXT" knownBug \
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
98 greek "\u03b1\u03c1\u03c7\u03b5\u03af\u03bf.txt" \
99 "\u0391\u03a1\u03a7\u0395\u038a\u039f.TXT" knownBug \
100 cyrillic "\u0444\u0430\u0439\u043b.txt" \
101 "\u0424\u0410\u0419\u041b.TXT" knownBug \
102 sigma "\u03bf\u03b4\u03cc\u03c2.txt" \
103 "\u039f\u0394\u038c\u03a3.TXT" knownBug \
104 nfd "r\u00e9sum\u00e9.txt" "re\u0301sume\u0301.txt" knownBug \
105 nfd-case "cr\u00e8me.txt" "CRE\u0300ME.TXT" knownBug \
106 marks "\u1ead.txt" "a\u0323\u0302.txt" knownBug \
107 angstrom "\u00e5.txt" "\u212b.TXT" knownBug \
108 hangul "\ud55c\uae00.txt" \
109 "\u1112\u1161\u11ab\u1100\u1173\u11af.txt" knownBug \
110 nfd-dir "caf\u00e9/menu.txt" "CAFE\u0301/MENU.TXT" knownBug \
111 sharp-s "stra\u00dfe.txt" "STRASSE.TXT" knownBug \
112 capital-sharp-s "gro\u00df.txt" "GRO\u1e9e.TXT" knownBug \
113 han "\u4e2d\u6587.txt" "\u4e2d\u6587.TXT" "" \
114 han-compat "\u8c48.txt" "\uf900.txt" knownBug \
115 kana "\u30ac\u30d1.txt" \
116 "\u30ab\u3099\u30cf\u309a.txt" knownBug \
117 fullwidth "\uff46\uff49\uff4c\uff45.txt" \
118 "\uff26\uff29\uff2c\uff25.TXT" knownBug \
119 arabic "\u0623\u062d\u0645\u062f.txt" \
120 "\u0627\u0654\u062d\u0645\u062f.txt" knownBug \
121 devanagari "\u0915\u093c.txt" "\u0958.txt" knownBug \
122 ]
123
124 # Each row is a label, the pathname that is checked in, and a pathname
125 # that is a different file with the setting on or off: a letter without
126 # its accent, a letter with another accent, a digit in place of its
127 # superscript form, a simplified Chinese character in place of the
128 # traditional one, katakana in place of hiragana, and ASCII letters in
129 # place of fullwidth ones.
130 #
131 set upDifferent [list \
132 accent "expos\u00e9.txt" expose.txt \
133 other-mark "\u00e5ngstr.txt" "\u00e4ngstr.txt" \
134 superscript "x\u00b2.txt" x2.txt \
135 han-variant "\u6a94\u6848.txt" "\u6863\u6848.txt" \
136 kana-script "\u304b\u306a.txt" "\u30ab\u30ca.txt" \
137 fullwidth-ascii "\uff41\uff42.txt" ab.txt \
138 ]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
139
140 ###############################################################################
141 #
142 # One spelling of each pathname is checked in and on disk. Fossil is
143 # then given the other spelling.
@@ -144,11 +242,11 @@
144 #
145 test_setup
146 fossil settings case-sensitive 1
147
148 set upNames [list]
149 foreach {label a b constraint} $upSame {
150 file mkdir [file dirname $a]
151 write_file $a "$label\n"
152 lappend upNames $a
153 }
154 foreach {label a b} $upDifferent {
@@ -160,111 +258,101 @@
160
161 fossil ls
162 test_eq unicode-pathnames-ls [lsort [split [normalize_result] \n]] \
163 [lsort $upNames]
164
165 # upConverted lists the pairs whose other spelling fossil converts to
166 # the checked-in one when it reads its arguments. Each is one name to
167 # fossil, so its tests with the setting off are not marked knownBug.
168 #
169 set upConverted [list]
170 set upRows [list]
171 foreach {label a b constraint} $upSame {
172 fossil test-echo $b
173 if {[string first "argv\[2\] = \[$a\]" $RESULT] >= 0} {
174 lappend upConverted $label
175 set constraint ""
176 }
177 lappend upRows $label $a $b $constraint
178 }
179 set upSame $upRows
180
181 # With the setting on, the other spelling is not a file under
182 # management, unless fossil converts it.
 
183 #
184 foreach {label a b constraint} $upSame {
185 up_show $label $a $b
186 set converted [expr {$label in $upConverted}]
187 fossil ls $b
188 test_eq unicode-pathnames-on-$label-ls [normalize_result] \
189 [expr {$converted ? $a : ""}]
190 fossil cat $b {*}[expr {$converted ? "" : "-expectError"}]
191 test_eq unicode-pathnames-on-$label-cat $CODE [expr {!$converted}]
192 }
193
194 # With the setting off, "fossil ls", "fossil cat" and "fossil rm" find
195 # the file by its other spelling.
196 #
197 fossil settings case-sensitive 0
198
199 foreach {label a b constraint} $upSame {
200 up_show $label $a $b
201 fossil ls $b
202 test_eq unicode-pathnames-off-$label-ls [normalize_result] $a $constraint
203 fossil cat $b {*}[expr {$constraint eq "" ? "" : "-$constraint"}]
204 test_eq unicode-pathnames-off-$label-cat [normalize_result] $label \
205 $constraint
206 fossil rm --soft -n $b
207 test_eq unicode-pathnames-off-$label-rm [normalize_result] "DELETED $a" \
208 $constraint
209 }
210
211 foreach {label a b} $upDifferent {
212 up_show $label $a $b
213 fossil ls $b
214 test_eq unicode-pathnames-off-$label-ls [normalize_result] ""
215 fossil cat $b -expectError
216 test_eq unicode-pathnames-off-$label-cat $CODE 1
217 fossil rm --soft -n $b
218 test_eq unicode-pathnames-off-$label-rm [normalize_result] ""
219 }
220
221 # A file on disk under the other spelling is not an extra file, and
222 # "fossil add" does not add it. These tests need a file system that
223 # has two files for the two spellings.
224 #
225 set upOneFile [list]
226 foreach {label a b constraint} $upSame {
227 up_show $label $a $b
228 if {[file exists $b] || $label in $upConverted} {
 
 
 
 
 
229 lappend upOneFile $label
230 continue
231 }
232 file mkdir [file dirname $b]
233 write_file $b "other spelling\n"
234 fossil extras
235 test_eq unicode-pathnames-off-$label-extras [normalize_result] "" \
236 $constraint
237 fossil add $b
238 fossil changes
239 test_eq unicode-pathnames-off-$label-add [normalize_result] "" $constraint
240 fossil revert
241 file delete $b
242 if {[file dirname $b] ne "."} {
243 file delete [file dirname $b]
244 }
245 }
246 if {[llength $upOneFile] > 0} {
247 test_skip_part "extras and add tests of [join $upOneFile {, }]:\
248 fossil or the file system has one name for both spellings"
 
249 }
250
251 ###############################################################################
252 #
253 # A version made with the setting on has both spellings of a pathname.
254 # With the setting off, fossil does not commit from a check-out of that
255 # version and does not update to it, because a file system that has one
256 # file for both names would give both the same content.
257 #
258 set upCollide [list \
259 ascii readme.txt README.TXT \
260 latin "\u00e4rger.txt" "\u00c4RGER.TXT" \
261 nfd "r\u00e9sum\u00e9.txt" "re\u0301sume\u0301.txt" \
262 nfd-case "cr\u00e8me.txt" "CRE\u0300ME.TXT" \
263 sharp-s "stra\u00dfe.txt" "STRASSE.TXT" \
264 ]
265
266 set upOneFile [list]
267 foreach {label a b} $upCollide {
268 up_show $label $a $b
269 test_setup
270 fossil settings case-sensitive 1
@@ -271,11 +359,15 @@
271 write_file $a "first spelling\n"
272 write_file plain.txt "plain\n"
273 fossil add $a plain.txt
274 fossil commit -m "first spelling"
275 set upFirst [up_new_version]
276 if {[file exists $b] || $label in $upConverted} {
 
 
 
 
277 lappend upOneFile $label
278 continue
279 }
280 write_file $b "second spelling\n"
281 fossil add $b
@@ -282,26 +374,31 @@
282 fossil commit -m "second spelling"
283 set upBoth [up_new_version]
284
285 fossil settings case-sensitive 0
286 write_file plain.txt "edited\n"
287 fossil commit -m "edit plain.txt" -expectError -knownBug
288 test_eq unicode-pathnames-collide-$label-commit $CODE 1 knownBug
289
290 fossil settings case-sensitive 1
291 fossil revert
292 fossil update $upFirst
293 fossil settings case-sensitive 0
294 fossil update $upBoth -expectError -knownBug
295 test_eq unicode-pathnames-collide-$label-update $CODE 1 knownBug
296 test_eq unicode-pathnames-collide-$label-update-file [file exists $b] 0 \
297 knownBug
298 }
299 if {[llength $upOneFile] > 0} {
300 test_skip_part "commit and update tests of [join $upOneFile {, }]:\
301 fossil or the file system has one name for both spellings"
 
302 }
303
304 ###############################################################################
305
 
 
 
 
306 encoding system $upSavedEncoding
307 test_cleanup
308
--- test/unicode-pathnames.test
+++ test/unicode-pathnames.test
@@ -25,29 +25,24 @@
25 # off, two pathnames are the same file when they are a canonical
26 # caseless match (the Unicode Standard, section 3.13, definition D145):
27 # equal after canonical decomposition and case folding. A file system
28 # that ignores case and normalization has one file for both names.
29 #
30 # The harness classifies the temporary volume once at startup
31 # (::fs_type). This file predicts match, miss, or untestable from
32 # that classification, Fossil argv rewriting, and the rules above.
33 # -utf-assurance selects how many pairs to run: smoke (one per
34 # behavior class), ci (the lists below), or stress (ci plus generated
35 # pairs). Unmet predictions fail the run.
 
 
 
 
 
36 #
37 # Case folding maps both the sharp s, U+00DF, and the capital sharp s,
38 # U+1E9E, to the two letters "ss", so by D145 a name with a sharp s and
39 # the same name with "ss" are one file. ext4 with case folding folds
40 # each sharp s to "ss" and has one file for the two names. NTFS and
41 # HFS+ convert each character to one character, and have two files.
42 # Collide tests require two names on disk, so they are skipped when
43 # ::fs_type says this volume has one entry for the pair.
44 #
45
46 require_no_open_checkout
47
48 # Fossil reads the pathnames on its command line, and Tcl reads
@@ -54,10 +49,13 @@
49 # fossil's output, in the system encoding.
50 #
51 set upSavedEncoding [encoding system]
52 encoding system utf-8
53
54 set upPredMet 0
55 set upPredUnmet 0
56
57 # Returns NAME with each character outside ASCII written as a Tcl
58 # escape, so that two spellings that look the same can be distinguished.
59 #
60 proc up_escape {name} {
61 set escaped ""
@@ -85,59 +83,159 @@
83 proc up_new_version {} {
84 regexp {New_Version: ([0-9a-f]+)} $::RESULT -> hash
85 return $hash
86 }
87
88 # Which ::fs_type key governs whether this volume stores A and B as one
89 # directory entry. Case-only pairs use ascii_case; NFC/NFD and
90 # compatibility decompositions use normalization; sharp-s uses sharp_s.
91 #
92 proc up_fs_key {label} {
93 switch -exact -- $label {
94 sharp-s - capital-sharp-s - stress-sharp {
95 return sharp_s
96 }
97 nfd - nfd-case - nfd-dir - marks - kana - arabic - angstrom -
98 hangul - han-compat - devanagari - stress-nfd {
99 return normalization
100 }
101 default {
102 return ascii_case
103 }
104 }
105 }
106
107 # Return 1 when ::fs_type says this volume has one directory entry for
108 # the two spellings of LABEL.
109 #
110 proc up_fs_collides {label} {
111 return [dict get $::fs_type [up_fs_key $label]]
112 }
113
114 # Return 1 when fossil test-echo rewrites B to the checked-in spelling A.
115 #
116 proc up_argv_maps {a b} {
117 fossil test-echo $b
118 return [expr {[string first "argv\[2\] = \[$a\]" $::RESULT] >= 0}]
119 }
120
121 # Record whether ACTUAL equals EXPECTED for prediction NAME.
122 #
123 proc up_expect {name actual expected} {
124 set ok [expr {$actual eq $expected}]
125 if {$ok} {
126 incr ::upPredMet
127 } else {
128 incr ::upPredUnmet
129 }
130 test_eq $name $actual $expected
131 }
132
133 # Each row is a label, the pathname that is checked in, and another
134 # spelling that is a D145 caseless match (or treated as one file in
135 # the header for compatibility pairs).
136 #
137 set upSameAll [list \
138 ascii readme.txt README.TXT \
139 ascii-dir dir/notes.txt DIR/Notes.TXT \
140 latin "\u00e4rger.txt" "\u00c4RGER.TXT" \
141 greek "\u03b1\u03c1\u03c7\u03b5\u03af\u03bf.txt" \
142 "\u0391\u03a1\u03a7\u0395\u038a\u039f.TXT" \
143 cyrillic "\u0444\u0430\u0439\u043b.txt" \
144 "\u0424\u0410\u0419\u041b.TXT" \
145 sigma "\u03bf\u03b4\u03cc\u03c2.txt" \
146 "\u039f\u0394\u038c\u03a3.TXT" \
147 nfd "r\u00e9sum\u00e9.txt" "re\u0301sume\u0301.txt" \
148 nfd-case "cr\u00e8me.txt" "CRE\u0300ME.TXT" \
149 marks "\u1ead.txt" "a\u0323\u0302.txt" \
150 angstrom "\u00e5.txt" "\u212b.TXT" \
151 hangul "\ud55c\uae00.txt" \
152 "\u1112\u1161\u11ab\u1100\u1173\u11af.txt" \
153 nfd-dir "caf\u00e9/menu.txt" "CAFE\u0301/MENU.TXT" \
154 sharp-s "stra\u00dfe.txt" "STRASSE.TXT" \
155 capital-sharp-s "gro\u00df.txt" "GRO\u1e9e.TXT" \
156 han "\u4e2d\u6587.txt" "\u4e2d\u6587.TXT" \
157 han-compat "\u8c48.txt" "\uf900.txt" \
158 kana "\u30ac\u30d1.txt" \
159 "\u30ab\u3099\u30cf\u309a.txt" \
160 fullwidth "\uff46\uff49\uff4c\uff45.txt" \
161 "\uff26\uff29\uff2c\uff25.TXT" \
162 arabic "\u0623\u062d\u0645\u062f.txt" \
163 "\u0627\u0654\u062d\u0645\u062f.txt" \
164 devanagari "\u0915\u093c.txt" "\u0958.txt" \
165 ]
166
167 # Each row is a label, the pathname that is checked in, and a pathname
168 # that is a different file with the setting on or off.
 
 
 
 
169 #
170 set upDifferentAll [list \
171 accent "expos\u00e9.txt" expose.txt \
172 other-mark "\u00e5ngstr.txt" "\u00e4ngstr.txt" \
173 superscript "x\u00b2.txt" x2.txt \
174 han-variant "\u6a94\u6848.txt" "\u6863\u6848.txt" \
175 kana-script "\u304b\u306a.txt" "\u30ab\u30ca.txt" \
176 fullwidth-ascii "\uff41\uff42.txt" ab.txt \
177 ]
178
179 set upCollideAll [list \
180 ascii readme.txt README.TXT \
181 latin "\u00e4rger.txt" "\u00c4RGER.TXT" \
182 nfd "r\u00e9sum\u00e9.txt" "re\u0301sume\u0301.txt" \
183 nfd-case "cr\u00e8me.txt" "CRE\u0300ME.TXT" \
184 sharp-s "stra\u00dfe.txt" "STRASSE.TXT" \
185 ]
186
187 # Smoke: one pair per behavior class.
188 set upSmokeSame {ascii latin sigma nfd sharp-s han-compat}
189 set upSmokeDifferent {accent}
190 set upSmokeCollide {ascii}
191
192 # Stress-only pairs (not in the ci lists).
193 set upStressSame [list \
194 stress-latin "\u00f6ffentlich.txt" "\u00d6FFENTLICH.TXT" \
195 stress-nfd "na\u00efve.txt" "nai\u0308ve.txt" \
196 stress-sharp "gro\u00dfartig.txt" "GROSSARTIG.TXT" \
197 ]
198 set upStressDifferent [list \
199 stress-miss "caf\u00e9.txt" cafe.txt \
200 ]
201 set upStressCollide [list \
202 stress-latin "\u00f6ffentlich.txt" "\u00d6FFENTLICH.TXT" \
203 stress-nfd "na\u00efve.txt" "nai\u0308ve.txt" \
204 ]
205
206 # Build the pair lists for the current -utf-assurance level.
207 #
208 proc up_select {all smokeLabels} {
209 set level [test_utf_assurance]
210 if {$level eq "smoke"} {
211 set out [list]
212 foreach {label a b} $all {
213 if {$label in $smokeLabels} {
214 lappend out $label $a $b
215 }
216 }
217 return $out
218 }
219 return $all
220 }
221
222 set upSame [up_select $upSameAll $upSmokeSame]
223 set upDifferent [up_select $upDifferentAll $upSmokeDifferent]
224 set upCollide [up_select $upCollideAll $upSmokeCollide]
225
226 if {[test_utf_assurance] eq "stress"} {
227 foreach {label a b} $upStressSame {
228 lappend upSame $label $a $b
229 }
230 foreach {label a b} $upStressDifferent {
231 lappend upDifferent $label $a $b
232 }
233 foreach {label a b} $upStressCollide {
234 lappend upCollide $label $a $b
235 }
236 }
237
238 ###############################################################################
239 #
240 # One spelling of each pathname is checked in and on disk. Fossil is
241 # then given the other spelling.
@@ -144,11 +242,11 @@
242 #
243 test_setup
244 fossil settings case-sensitive 1
245
246 set upNames [list]
247 foreach {label a b} $upSame {
248 file mkdir [file dirname $a]
249 write_file $a "$label\n"
250 lappend upNames $a
251 }
252 foreach {label a b} $upDifferent {
@@ -160,111 +258,101 @@
258
259 fossil ls
260 test_eq unicode-pathnames-ls [lsort [split [normalize_result] \n]] \
261 [lsort $upNames]
262
263 # upConverted lists pairs whose other spelling fossil rewrites to the
264 # checked-in name when it reads its arguments.
 
265 #
266 set upConverted [list]
267 foreach {label a b} $upSame {
268 if {[up_argv_maps $a $b]} {
 
 
269 lappend upConverted $label
 
270 }
 
271 }
 
272
273 # With the setting on, the other spelling is not a file under
274 # management, unless fossil converts it. Positive: converted pairs
275 # find the file. Negative: unconverted pairs do not.
276 #
277 foreach {label a b} $upSame {
278 up_show $label $a $b
279 set converted [expr {$label in $upConverted}]
280 fossil ls $b
281 up_expect unicode-pathnames-on-$label-ls [normalize_result] \
282 [expr {$converted ? $a : ""}]
283 fossil cat $b {*}[expr {$converted ? "" : "-expectError"}]
284 up_expect unicode-pathnames-on-$label-cat $CODE [expr {!$converted}]
285 }
286
287 # With the setting off, D145 matches must be found by the other
288 # spelling; upDifferent pairs must not.
289 #
290 fossil settings case-sensitive 0
291
292 foreach {label a b} $upSame {
293 up_show $label $a $b
294 fossil ls $b
295 up_expect unicode-pathnames-off-$label-ls [normalize_result] $a
296 fossil cat $b
297 up_expect unicode-pathnames-off-$label-cat-code $CODE 0
298 up_expect unicode-pathnames-off-$label-cat [normalize_result] $label
299 fossil rm --soft -n $b
300 up_expect unicode-pathnames-off-$label-rm [normalize_result] "DELETED $a"
 
301 }
302
303 foreach {label a b} $upDifferent {
304 up_show $label $a $b
305 fossil ls $b
306 up_expect unicode-pathnames-off-$label-ls [normalize_result] ""
307 fossil cat $b -expectError
308 up_expect unicode-pathnames-off-$label-cat $CODE 1
309 fossil rm --soft -n $b
310 up_expect unicode-pathnames-off-$label-rm [normalize_result] ""
311 }
312
313 # A file on disk under the other spelling is not an extra file, and
314 # "fossil add" does not add it. Needs a volume that stores two names.
 
315 #
316 set upOneFile [list]
317 foreach {label a b} $upSame {
318 up_show $label $a $b
319 if {[up_fs_collides $label] || $label in $upConverted} {
320 lappend upOneFile $label
321 continue
322 }
323 # Confirm the working tree still has two distinct entries.
324 if {[file exists $b]} {
325 lappend upOneFile $label
326 continue
327 }
328 file mkdir [file dirname $b]
329 write_file $b "other spelling\n"
330 fossil extras
331 up_expect unicode-pathnames-off-$label-extras [normalize_result] ""
 
332 fossil add $b
333 fossil changes
334 up_expect unicode-pathnames-off-$label-add [normalize_result] ""
335 fossil revert
336 file delete $b
337 if {[file dirname $b] ne "."} {
338 catch {file delete [file dirname $b]}
339 }
340 }
341 if {[llength $upOneFile] > 0} {
342 test_skip_part "extras and add tests of [join $upOneFile {, }]:\
343 filesystem type or argv rewriting has one name for both spellings\
344 (fs_type: $::fs_type)"
345 }
346
347 ###############################################################################
348 #
349 # A version made with the setting on has both spellings of a pathname.
350 # With the setting off, fossil must refuse to commit from a check-out of
351 # that version and refuse to update to it, because a file system that
352 # has one file for both names would give both the same content.
353 #
 
 
 
 
 
 
 
 
354 set upOneFile [list]
355 foreach {label a b} $upCollide {
356 up_show $label $a $b
357 test_setup
358 fossil settings case-sensitive 1
@@ -271,11 +359,15 @@
359 write_file $a "first spelling\n"
360 write_file plain.txt "plain\n"
361 fossil add $a plain.txt
362 fossil commit -m "first spelling"
363 set upFirst [up_new_version]
364 set converted [up_argv_maps $a $b]
365 if {$converted} {
366 lappend upConverted $label
367 }
368 if {[up_fs_collides $label] || $converted || [file exists $b]} {
369 lappend upOneFile $label
370 continue
371 }
372 write_file $b "second spelling\n"
373 fossil add $b
@@ -282,26 +374,31 @@
374 fossil commit -m "second spelling"
375 set upBoth [up_new_version]
376
377 fossil settings case-sensitive 0
378 write_file plain.txt "edited\n"
379 fossil commit -m "edit plain.txt" -expectError
380 up_expect unicode-pathnames-collide-$label-commit $CODE 1
381
382 fossil settings case-sensitive 1
383 fossil revert
384 fossil update $upFirst
385 fossil settings case-sensitive 0
386 fossil update $upBoth -expectError
387 up_expect unicode-pathnames-collide-$label-update $CODE 1
388 up_expect unicode-pathnames-collide-$label-update-file \
389 [file exists $b] 0
390 }
391 if {[llength $upOneFile] > 0} {
392 test_skip_part "commit and update tests of [join $upOneFile {, }]:\
393 filesystem type or argv rewriting has one name for both spellings\
394 (fs_type: $::fs_type)"
395 }
396
397 ###############################################################################
398
399 protOut "***** unicode-pathnames predictions:\
400 met=$upPredMet unmet=$upPredUnmet"
401 test unicode-pathnames-predictions-met {$upPredUnmet == 0}
402
403 encoding system $upSavedEncoding
404 test_cleanup
405

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button