Fossil SCM
Detect where an OS (in this case probably Darwin) has already done a case mapping, using "fossil echo-test". Fix docs.
Commit
cb01eaabfd97b051f7c45a0c7749b4a223f4a4fead40adc7e7ba9e035bbea0c9
Parent
b881f34206fa3d9…
2 files changed
+1
-1
+33
-9
+1
-1
| --- test/README.md | ||
| +++ test/README.md | ||
| @@ -86,11 +86,11 @@ | ||
| 86 | 86 | |
| 87 | 87 | When a test finds a fault that is not yet fixed, add `knownBug` as the test's last argument, so that the suite still exits with status 0. A known bug that passes is reported as `OK (knownBug)?`. Don't forget to remove `knownBug` when you're sure the fault is fixed. |
| 88 | 88 | |
| 89 | 89 | If the known bug is the exit status of a `fossil` command, add `-knownBug` to that command too. Otherwise the command prints an `ERROR` line on every run, even with `-quiet`. With `-knownBug` you only see that line under `-strict`. |
| 90 | 90 | |
| 91 | -A known bug should fail on every system. If the fault only shows up in some environments, have the test set up that environment itself. If a test needs something the system might not have, that's a requirement, so use `test_skip`. | |
| 91 | +A test marked `knownBug` should fail on every system where it's marked. If the fault only shows up in some environments, have the test set up that environment itself. If Fossil really does behave differently on some system, as it does with decomposed pathnames on macOS, have the test check that behavior and leave the mark off there; don't test for the operating system's name. If a test needs something the system might not have, that's a requirement, so use `test_skip`. | |
| 92 | 92 | |
| 93 | 93 | Stray files in `test/` can be confusing because `delta1.test` and `merge2.test` run their tests on every file and the counts may differ from what is expected. A different total is not a failure. |
| 94 | 94 | |
| 95 | 95 | Beware of global variables! If you must create a new global variable, be sure there isn't a collision with other files. Some future design should avoid this |
| 96 | 96 | problem. |
| 97 | 97 |
| --- test/README.md | |
| +++ test/README.md | |
| @@ -86,11 +86,11 @@ | |
| 86 | |
| 87 | When a test finds a fault that is not yet fixed, add `knownBug` as the test's last argument, so that the suite still exits with status 0. A known bug that passes is reported as `OK (knownBug)?`. Don't forget to remove `knownBug` when you're sure the fault is fixed. |
| 88 | |
| 89 | If the known bug is the exit status of a `fossil` command, add `-knownBug` to that command too. Otherwise the command prints an `ERROR` line on every run, even with `-quiet`. With `-knownBug` you only see that line under `-strict`. |
| 90 | |
| 91 | A known bug should fail on every system. If the fault only shows up in some environments, have the test set up that environment itself. If a test needs something the system might not have, that's a requirement, so use `test_skip`. |
| 92 | |
| 93 | Stray files in `test/` can be confusing because `delta1.test` and `merge2.test` run their tests on every file and the counts may differ from what is expected. A different total is not a failure. |
| 94 | |
| 95 | Beware of global variables! If you must create a new global variable, be sure there isn't a collision with other files. Some future design should avoid this |
| 96 | problem. |
| 97 |
| --- test/README.md | |
| +++ test/README.md | |
| @@ -86,11 +86,11 @@ | |
| 86 | |
| 87 | When a test finds a fault that is not yet fixed, add `knownBug` as the test's last argument, so that the suite still exits with status 0. A known bug that passes is reported as `OK (knownBug)?`. Don't forget to remove `knownBug` when you're sure the fault is fixed. |
| 88 | |
| 89 | If the known bug is the exit status of a `fossil` command, add `-knownBug` to that command too. Otherwise the command prints an `ERROR` line on every run, even with `-quiet`. With `-knownBug` you only see that line under `-strict`. |
| 90 | |
| 91 | A test marked `knownBug` should fail on every system where it's marked. If the fault only shows up in some environments, have the test set up that environment itself. If Fossil really does behave differently on some system, as it does with decomposed pathnames on macOS, have the test check that behavior and leave the mark off there; don't test for the operating system's name. If a test needs something the system might not have, that's a requirement, so use `test_skip`. |
| 92 | |
| 93 | Stray files in `test/` can be confusing because `delta1.test` and `merge2.test` run their tests on every file and the counts may differ from what is expected. A different total is not a failure. |
| 94 | |
| 95 | Beware of global variables! If you must create a new global variable, be sure there isn't a collision with other files. Some future design should avoid this |
| 96 | problem. |
| 97 |
+33
-9
| --- test/unicode-pathnames.test | ||
| +++ test/unicode-pathnames.test | ||
| @@ -30,10 +30,16 @@ | ||
| 30 | 30 | # With the setting off, fossil folds the ASCII letters and compares |
| 31 | 31 | # every other byte as written, so the tests of names outside ASCII are |
| 32 | 32 | # marked knownBug. Fossil also checks out, updates to and commits a |
| 33 | 33 | # version that has two names for one file, so those tests are marked |
| 34 | 34 | # knownBug for ASCII names too. |
| 35 | +# | |
| 36 | +# On macOS Fossil converts every pathname from Apple's decomposed form | |
| 37 | +# to NFC, so some of these pairs will end up normalised to the same name | |
| 38 | +# before fossil gets to compare. "fossil test-echo" reliably detects this. | |
| 39 | +# With case-sensitive on we expect to find the file, and with it off | |
| 40 | +# we won't find the file, and it's an actual bug. | |
| 35 | 41 | # |
| 36 | 42 | # Case folding maps both the sharp s, U+00DF, and the capital sharp s, |
| 37 | 43 | # U+1E9E, to the two letters "ss", so by D145 a name with a sharp s and |
| 38 | 44 | # the same name with "ss" are one file. ext4 with case folding folds |
| 39 | 45 | # each sharp s to "ss" and has one file for the two names. NTFS and |
| @@ -49,11 +55,11 @@ | ||
| 49 | 55 | # |
| 50 | 56 | set upSavedEncoding [encoding system] |
| 51 | 57 | encoding system utf-8 |
| 52 | 58 | |
| 53 | 59 | # Returns NAME with each character outside ASCII written as a Tcl |
| 54 | -# escape, so that two spellings that look the same can be told apart. | |
| 60 | +# escape, so that two spellings that look the same can be distinguished. | |
| 55 | 61 | # |
| 56 | 62 | proc up_escape {name} { |
| 57 | 63 | set escaped "" |
| 58 | 64 | foreach char [split $name ""] { |
| 59 | 65 | scan $char %c code |
| @@ -153,20 +159,38 @@ | ||
| 153 | 159 | fossil commit -m "one spelling of each pathname" |
| 154 | 160 | |
| 155 | 161 | fossil ls |
| 156 | 162 | test_eq unicode-pathnames-ls [lsort [split [normalize_result] \n]] \ |
| 157 | 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 | |
| 158 | 180 | |
| 159 | 181 | # With the setting on, the other spelling is not a file under |
| 160 | -# management. | |
| 182 | +# management, unless fossil converts it. | |
| 161 | 183 | # |
| 162 | 184 | foreach {label a b constraint} $upSame { |
| 163 | 185 | up_show $label $a $b |
| 186 | + set converted [expr {$label in $upConverted}] | |
| 164 | 187 | fossil ls $b |
| 165 | - test_eq unicode-pathnames-on-$label-ls [normalize_result] "" | |
| 166 | - fossil cat $b -expectError | |
| 167 | - test_eq unicode-pathnames-on-$label-cat $CODE 1 | |
| 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}] | |
| 168 | 192 | } |
| 169 | 193 | |
| 170 | 194 | # With the setting off, "fossil ls", "fossil cat" and "fossil rm" find |
| 171 | 195 | # the file by its other spelling. |
| 172 | 196 | # |
| @@ -199,11 +223,11 @@ | ||
| 199 | 223 | # has two files for the two spellings. |
| 200 | 224 | # |
| 201 | 225 | set upOneFile [list] |
| 202 | 226 | foreach {label a b constraint} $upSame { |
| 203 | 227 | up_show $label $a $b |
| 204 | - if {[file exists $b]} { | |
| 228 | + if {[file exists $b] || $label in $upConverted} { | |
| 205 | 229 | lappend upOneFile $label |
| 206 | 230 | continue |
| 207 | 231 | } |
| 208 | 232 | file mkdir [file dirname $b] |
| 209 | 233 | write_file $b "other spelling\n" |
| @@ -219,11 +243,11 @@ | ||
| 219 | 243 | file delete [file dirname $b] |
| 220 | 244 | } |
| 221 | 245 | } |
| 222 | 246 | if {[llength $upOneFile] > 0} { |
| 223 | 247 | test_skip_part "extras and add tests of [join $upOneFile {, }]:\ |
| 224 | - the file system has one file for both spellings" | |
| 248 | + fossil or the file system has one name for both spellings" | |
| 225 | 249 | } |
| 226 | 250 | |
| 227 | 251 | ############################################################################### |
| 228 | 252 | # |
| 229 | 253 | # A version made with the setting on has both spellings of a pathname. |
| @@ -247,11 +271,11 @@ | ||
| 247 | 271 | write_file $a "first spelling\n" |
| 248 | 272 | write_file plain.txt "plain\n" |
| 249 | 273 | fossil add $a plain.txt |
| 250 | 274 | fossil commit -m "first spelling" |
| 251 | 275 | set upFirst [up_new_version] |
| 252 | - if {[file exists $b]} { | |
| 276 | + if {[file exists $b] || $label in $upConverted} { | |
| 253 | 277 | lappend upOneFile $label |
| 254 | 278 | continue |
| 255 | 279 | } |
| 256 | 280 | write_file $b "second spelling\n" |
| 257 | 281 | fossil add $b |
| @@ -272,12 +296,12 @@ | ||
| 272 | 296 | test_eq unicode-pathnames-collide-$label-update-file [file exists $b] 0 \ |
| 273 | 297 | knownBug |
| 274 | 298 | } |
| 275 | 299 | if {[llength $upOneFile] > 0} { |
| 276 | 300 | test_skip_part "commit and update tests of [join $upOneFile {, }]:\ |
| 277 | - the file system has one file for both spellings" | |
| 301 | + fossil or the file system has one name for both spellings" | |
| 278 | 302 | } |
| 279 | 303 | |
| 280 | 304 | ############################################################################### |
| 281 | 305 | |
| 282 | 306 | encoding system $upSavedEncoding |
| 283 | 307 | test_cleanup |
| 284 | 308 |
| --- test/unicode-pathnames.test | |
| +++ test/unicode-pathnames.test | |
| @@ -30,10 +30,16 @@ | |
| 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 | # Case folding maps both the sharp s, U+00DF, and the capital sharp s, |
| 37 | # U+1E9E, to the two letters "ss", so by D145 a name with a sharp s and |
| 38 | # the same name with "ss" are one file. ext4 with case folding folds |
| 39 | # each sharp s to "ss" and has one file for the two names. NTFS and |
| @@ -49,11 +55,11 @@ | |
| 49 | # |
| 50 | set upSavedEncoding [encoding system] |
| 51 | encoding system utf-8 |
| 52 | |
| 53 | # Returns NAME with each character outside ASCII written as a Tcl |
| 54 | # escape, so that two spellings that look the same can be told apart. |
| 55 | # |
| 56 | proc up_escape {name} { |
| 57 | set escaped "" |
| 58 | foreach char [split $name ""] { |
| 59 | scan $char %c code |
| @@ -153,20 +159,38 @@ | |
| 153 | fossil commit -m "one spelling of each pathname" |
| 154 | |
| 155 | fossil ls |
| 156 | test_eq unicode-pathnames-ls [lsort [split [normalize_result] \n]] \ |
| 157 | [lsort $upNames] |
| 158 | |
| 159 | # With the setting on, the other spelling is not a file under |
| 160 | # management. |
| 161 | # |
| 162 | foreach {label a b constraint} $upSame { |
| 163 | up_show $label $a $b |
| 164 | fossil ls $b |
| 165 | test_eq unicode-pathnames-on-$label-ls [normalize_result] "" |
| 166 | fossil cat $b -expectError |
| 167 | test_eq unicode-pathnames-on-$label-cat $CODE 1 |
| 168 | } |
| 169 | |
| 170 | # With the setting off, "fossil ls", "fossil cat" and "fossil rm" find |
| 171 | # the file by its other spelling. |
| 172 | # |
| @@ -199,11 +223,11 @@ | |
| 199 | # has two files for the two spellings. |
| 200 | # |
| 201 | set upOneFile [list] |
| 202 | foreach {label a b constraint} $upSame { |
| 203 | up_show $label $a $b |
| 204 | if {[file exists $b]} { |
| 205 | lappend upOneFile $label |
| 206 | continue |
| 207 | } |
| 208 | file mkdir [file dirname $b] |
| 209 | write_file $b "other spelling\n" |
| @@ -219,11 +243,11 @@ | |
| 219 | file delete [file dirname $b] |
| 220 | } |
| 221 | } |
| 222 | if {[llength $upOneFile] > 0} { |
| 223 | test_skip_part "extras and add tests of [join $upOneFile {, }]:\ |
| 224 | the file system has one file for both spellings" |
| 225 | } |
| 226 | |
| 227 | ############################################################################### |
| 228 | # |
| 229 | # A version made with the setting on has both spellings of a pathname. |
| @@ -247,11 +271,11 @@ | |
| 247 | write_file $a "first spelling\n" |
| 248 | write_file plain.txt "plain\n" |
| 249 | fossil add $a plain.txt |
| 250 | fossil commit -m "first spelling" |
| 251 | set upFirst [up_new_version] |
| 252 | if {[file exists $b]} { |
| 253 | lappend upOneFile $label |
| 254 | continue |
| 255 | } |
| 256 | write_file $b "second spelling\n" |
| 257 | fossil add $b |
| @@ -272,12 +296,12 @@ | |
| 272 | test_eq unicode-pathnames-collide-$label-update-file [file exists $b] 0 \ |
| 273 | knownBug |
| 274 | } |
| 275 | if {[llength $upOneFile] > 0} { |
| 276 | test_skip_part "commit and update tests of [join $upOneFile {, }]:\ |
| 277 | the file system has one file for both spellings" |
| 278 | } |
| 279 | |
| 280 | ############################################################################### |
| 281 | |
| 282 | encoding system $upSavedEncoding |
| 283 | test_cleanup |
| 284 |
| --- test/unicode-pathnames.test | |
| +++ test/unicode-pathnames.test | |
| @@ -30,10 +30,16 @@ | |
| 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 converts every pathname from Apple's decomposed form |
| 37 | # to NFC, so some of these pairs will end up normalised to the same name |
| 38 | # before fossil gets to compare. "fossil test-echo" reliably detects this. |
| 39 | # With case-sensitive on we expect to find the file, and with it off |
| 40 | # we won't find the file, and it's an actual bug. |
| 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 |
| @@ -49,11 +55,11 @@ | |
| 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 "" |
| 64 | foreach char [split $name ""] { |
| 65 | scan $char %c code |
| @@ -153,20 +159,38 @@ | |
| 159 | fossil commit -m "one spelling of each pathname" |
| 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 | # |
| @@ -199,11 +223,11 @@ | |
| 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" |
| @@ -219,11 +243,11 @@ | |
| 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. |
| @@ -247,11 +271,11 @@ | |
| 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 |
| @@ -272,12 +296,12 @@ | |
| 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 |