Fossil SCM

Reworked the wiki date collision test from a stochastic process that typically takes ~30 seconds to trip here to a planted collision test that hits in ~4 seconds.

wyoung 2026-11-20 17:42 UTC test-suite-new
Commit 250e1b140df3c3f4cc5e784fe54bb4578390cb30493430acb6668bdf0b8f3280
--- test/rewrite-test-output.tcl
+++ test/rewrite-test-output.tcl
@@ -373,17 +373,10 @@
373373
set UNKOWN_PLATFORM 0
374374
set UNIX 1
375375
set WINDOWS 2
376376
set CYGWIN 3
377377
378
-# One specific wiki test creates repetitive output of varying length
379
-set wiki_f13_cmd1 "fossil wiki create {timestamp of 2399999} f13 --technote 2399999"
380
-set wiki_f13_cmd2 "fossil wiki list --technote --show-technote-ids"
381
-set wiki_f13_cmd3 "fossil wiki export a13 --technote ID"
382
-set collecting_f3 0
383
-set collecting_f3_verbose 0
384
-
385378
# Collected lines for summaries in --extra mode
386379
set amend_ed_lines [list]
387380
set amend_ed_failed 0
388381
set symlinks_lines [list]
389382
set symlinks_failed 0
@@ -466,32 +459,10 @@
466459
}
467460
set check_json_empty_line 0
468461
}
469462
}
470463
471
- # Summarise repetitive output of varying length for f13 in wiki test
472
- if { $testname eq "wiki" } {
473
- if { $collecting_f3 == 2 } {
474
- if { $collecting_f3_verbose == 1 && [regexp {^HASH } $line] } {
475
- incr collecting_f3_verbose
476
- } elseif { $line eq $wiki_f13_cmd3 } {
477
- incr collecting_f3
478
- puts "\[...\]"
479
- } else {
480
- continue
481
- }
482
- } elseif { $collecting_f3 == 1 } {
483
- if { $line eq $wiki_f13_cmd2 } {
484
- incr collecting_f3
485
- } elseif { $collecting_f3_verbose == 0 } {
486
- incr collecting_f3_verbose
487
- }
488
- } elseif { $line eq $wiki_f13_cmd1 } {
489
- incr collecting_f3
490
- }
491
- }
492
-
493464
if { $EXTRA } {
494465
if { $line eq "ERROR (0): " && $platform == $WINDOWS } {
495466
if { [string match "fossil http --in *" $prev_line] } {
496467
continue
497468
}
498469
--- test/rewrite-test-output.tcl
+++ test/rewrite-test-output.tcl
@@ -373,17 +373,10 @@
373 set UNKOWN_PLATFORM 0
374 set UNIX 1
375 set WINDOWS 2
376 set CYGWIN 3
377
378 # One specific wiki test creates repetitive output of varying length
379 set wiki_f13_cmd1 "fossil wiki create {timestamp of 2399999} f13 --technote 2399999"
380 set wiki_f13_cmd2 "fossil wiki list --technote --show-technote-ids"
381 set wiki_f13_cmd3 "fossil wiki export a13 --technote ID"
382 set collecting_f3 0
383 set collecting_f3_verbose 0
384
385 # Collected lines for summaries in --extra mode
386 set amend_ed_lines [list]
387 set amend_ed_failed 0
388 set symlinks_lines [list]
389 set symlinks_failed 0
@@ -466,32 +459,10 @@
466 }
467 set check_json_empty_line 0
468 }
469 }
470
471 # Summarise repetitive output of varying length for f13 in wiki test
472 if { $testname eq "wiki" } {
473 if { $collecting_f3 == 2 } {
474 if { $collecting_f3_verbose == 1 && [regexp {^HASH } $line] } {
475 incr collecting_f3_verbose
476 } elseif { $line eq $wiki_f13_cmd3 } {
477 incr collecting_f3
478 puts "\[...\]"
479 } else {
480 continue
481 }
482 } elseif { $collecting_f3 == 1 } {
483 if { $line eq $wiki_f13_cmd2 } {
484 incr collecting_f3
485 } elseif { $collecting_f3_verbose == 0 } {
486 incr collecting_f3_verbose
487 }
488 } elseif { $line eq $wiki_f13_cmd1 } {
489 incr collecting_f3
490 }
491 }
492
493 if { $EXTRA } {
494 if { $line eq "ERROR (0): " && $platform == $WINDOWS } {
495 if { [string match "fossil http --in *" $prev_line] } {
496 continue
497 }
498
--- test/rewrite-test-output.tcl
+++ test/rewrite-test-output.tcl
@@ -373,17 +373,10 @@
373 set UNKOWN_PLATFORM 0
374 set UNIX 1
375 set WINDOWS 2
376 set CYGWIN 3
377
 
 
 
 
 
 
 
378 # Collected lines for summaries in --extra mode
379 set amend_ed_lines [list]
380 set amend_ed_failed 0
381 set symlinks_lines [list]
382 set symlinks_failed 0
@@ -466,32 +459,10 @@
459 }
460 set check_json_empty_line 0
461 }
462 }
463
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
464 if { $EXTRA } {
465 if { $line eq "ERROR (0): " && $platform == $WINDOWS } {
466 if { [string match "fossil http --in *" $prev_line] } {
467 continue
468 }
469
+29 -36
--- test/wiki.test
+++ test/wiki.test
@@ -307,46 +307,39 @@
307307
# approximately 1 in 10^22 so this test ignores that possibility.)
308308
fossil wiki export a12.1 --technote [string range $anoldtechnoteid 0 20]
309309
test wiki-41 {[similar_file f12 a12.1]}
310310
311311
###############################################################################
312
-# Now we need to force a collision in the first four characters of the tech
313
-# note id if we don't already have one so we can check we get an error if the
314
-# tech note id is ambiguous
315
-set idcounts [dict create]
316
-set maxcount 0
317
-fossil wiki list --technote --show-technote-ids
318
-set technotelist [split $RESULT "\n"]
319
-for {set i 0} {$i < [llength $technotelist]} {incr i} {
320
- set fullid [lindex $technotelist $i]
321
- set id [string range $fullid 0 3]
322
- dict incr idcounts $id
323
- if {[dict get $idcounts $id] > $maxcount} {
324
- set maxid $id
325
- incr maxcount
326
- }
327
-}
328
-# get i so that, as a julian date, it is in the 1800s, i.e., older than
329
-# any other tech note, but after 1 AD
330
-set i 2400000
331
-while {$maxcount < 2} {
332
- # keep getting older
333
- incr i -1
334
- write_file f13 "A tech note with timestamp of jday=$i"
335
- fossil wiki create "timestamp of $i" f13 --technote "$i"
336
- fossil wiki list --technote --show-technote-ids
337
- set technotelist [split $RESULT "\n"]
338
- set oldesttechnoteid [lindex [split [lindex $technotelist [llength $technotelist]-1]] 0]
339
- set id [string range $oldesttechnoteid 0 3]
340
- dict incr idcounts $id
341
- if {[dict get $idcounts $id] > $maxcount} {
342
- set maxid $id
343
- incr maxcount
344
- }
345
-}
346
-# Save the duplicate id for this and later tests
347
-set duplicateid $maxid
312
+# Force a collision in the first four characters of the tech note id so we
313
+# can check we get an error if the tech note id is ambiguous.
314
+#
315
+# Plant the collision: rewrite one event- tag so it shares another technote's
316
+# 4-char id prefix. That exercises wiki_technote_to_rid's ambiguity path in
317
+# O(1) instead of a birthday-paradox create storm (unbounded wall time at
318
+# smoke). Leave $anoldtechnoteid alone — later tests update that note by id.
319
+set techIds {}
320
+fossil wiki list --technote --show-technote-ids
321
+foreach line [split $RESULT "\n"] {
322
+ if {$line eq ""} continue
323
+ set id [lindex $line 0]
324
+ if {$id eq $anoldtechnoteid} continue
325
+ lappend techIds $id
326
+}
327
+if {[llength $techIds] < 2} {
328
+ error "wiki-collision: need two technotes besides the old one to plant\
329
+a prefix collision"
330
+}
331
+set idA [lindex $techIds 0]
332
+set idB [lindex $techIds 1]
333
+set duplicateid [string range $idA 0 3]
334
+if {[string range $idB 0 3] ne $duplicateid} {
335
+ set planted "$duplicateid[string range $idB 4 end]"
336
+ fossil sql "UPDATE tag SET tagname='event-$planted' WHERE tagname='event-$idB';"
337
+ if {$CODE != 0} {
338
+ error "wiki-collision: failed to plant prefix collision:\n$RESULT"
339
+ }
340
+}
348341
fossil wiki export a13 --technote $duplicateid -expectError
349342
test wiki-42 {$CODE != 0}
350343
351344
###############################################################################
352345
# Check we can update technote by its id
353346
--- test/wiki.test
+++ test/wiki.test
@@ -307,46 +307,39 @@
307 # approximately 1 in 10^22 so this test ignores that possibility.)
308 fossil wiki export a12.1 --technote [string range $anoldtechnoteid 0 20]
309 test wiki-41 {[similar_file f12 a12.1]}
310
311 ###############################################################################
312 # Now we need to force a collision in the first four characters of the tech
313 # note id if we don't already have one so we can check we get an error if the
314 # tech note id is ambiguous
315 set idcounts [dict create]
316 set maxcount 0
317 fossil wiki list --technote --show-technote-ids
318 set technotelist [split $RESULT "\n"]
319 for {set i 0} {$i < [llength $technotelist]} {incr i} {
320 set fullid [lindex $technotelist $i]
321 set id [string range $fullid 0 3]
322 dict incr idcounts $id
323 if {[dict get $idcounts $id] > $maxcount} {
324 set maxid $id
325 incr maxcount
326 }
327 }
328 # get i so that, as a julian date, it is in the 1800s, i.e., older than
329 # any other tech note, but after 1 AD
330 set i 2400000
331 while {$maxcount < 2} {
332 # keep getting older
333 incr i -1
334 write_file f13 "A tech note with timestamp of jday=$i"
335 fossil wiki create "timestamp of $i" f13 --technote "$i"
336 fossil wiki list --technote --show-technote-ids
337 set technotelist [split $RESULT "\n"]
338 set oldesttechnoteid [lindex [split [lindex $technotelist [llength $technotelist]-1]] 0]
339 set id [string range $oldesttechnoteid 0 3]
340 dict incr idcounts $id
341 if {[dict get $idcounts $id] > $maxcount} {
342 set maxid $id
343 incr maxcount
344 }
345 }
346 # Save the duplicate id for this and later tests
347 set duplicateid $maxid
348 fossil wiki export a13 --technote $duplicateid -expectError
349 test wiki-42 {$CODE != 0}
350
351 ###############################################################################
352 # Check we can update technote by its id
353
--- test/wiki.test
+++ test/wiki.test
@@ -307,46 +307,39 @@
307 # approximately 1 in 10^22 so this test ignores that possibility.)
308 fossil wiki export a12.1 --technote [string range $anoldtechnoteid 0 20]
309 test wiki-41 {[similar_file f12 a12.1]}
310
311 ###############################################################################
312 # Force a collision in the first four characters of the tech note id so we
313 # can check we get an error if the tech note id is ambiguous.
314 #
315 # Plant the collision: rewrite one event- tag so it shares another technote's
316 # 4-char id prefix. That exercises wiki_technote_to_rid's ambiguity path in
317 # O(1) instead of a birthday-paradox create storm (unbounded wall time at
318 # smoke). Leave $anoldtechnoteid alone — later tests update that note by id.
319 set techIds {}
320 fossil wiki list --technote --show-technote-ids
321 foreach line [split $RESULT "\n"] {
322 if {$line eq ""} continue
323 set id [lindex $line 0]
324 if {$id eq $anoldtechnoteid} continue
325 lappend techIds $id
326 }
327 if {[llength $techIds] < 2} {
328 error "wiki-collision: need two technotes besides the old one to plant\
329 a prefix collision"
330 }
331 set idA [lindex $techIds 0]
332 set idB [lindex $techIds 1]
333 set duplicateid [string range $idA 0 3]
334 if {[string range $idB 0 3] ne $duplicateid} {
335 set planted "$duplicateid[string range $idB 4 end]"
336 fossil sql "UPDATE tag SET tagname='event-$planted' WHERE tagname='event-$idB';"
337 if {$CODE != 0} {
338 error "wiki-collision: failed to plant prefix collision:\n$RESULT"
339 }
340 }
 
 
 
 
 
 
 
341 fossil wiki export a13 --technote $duplicateid -expectError
342 test wiki-42 {$CODE != 0}
343
344 ###############################################################################
345 # Check we can update technote by its id
346

Keyboard Shortcuts

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