Fossil SCM
Make settings-repo.test much faster, in part by improving the routines in tester.tcl that extract the settings from the fossil source.
Commit
62da8157b9e8edc51d57273c9379171d2a2342d8788149bc344b82f3d0092825
Parent
f12a09cc224b49a…
2 files changed
+23
-14
+32
-3
+23
-14
| --- test/settings-repo.test | ||
| +++ test/settings-repo.test | ||
| @@ -42,27 +42,36 @@ | ||
| 42 | 42 | |
| 43 | 43 | set all_settings [get_all_settings] |
| 44 | 44 | |
| 45 | 45 | # |
| 46 | 46 | # Spot-check the TH1 "setting" bridge on a small fixed sample only. |
| 47 | -# Every setting still gets full CLI set/unset/get coverage below; | |
| 48 | 47 | # th1.test already exercises TH1 setting more broadly. |
| 49 | 48 | # |
| 50 | 49 | set th1_sample [list autosync ignore-glob manifest] |
| 51 | 50 | |
| 52 | -foreach name $all_settings { | |
| 53 | - # | |
| 54 | - # HACK: Make 100% sure that there are no non-default setting values | |
| 55 | - # present anywhere. | |
| 56 | - # | |
| 57 | - if {$name eq "manifest"} { | |
| 58 | - fossil unset $name --exact --global -expectError | |
| 59 | - } else { | |
| 60 | - fossil unset $name --exact --global | |
| 61 | - } | |
| 62 | - fossil unset $name --exact | |
| 63 | -} | |
| 51 | +# | |
| 52 | +# At -assurance smoke, returns the settings in NAMES that are in | |
| 53 | +# th1_sample or that get_sample_settings returns, which is the first | |
| 54 | +# setting in NAMES for each distinct KINDS value from | |
| 55 | +# get_source_settings. At ci and stress, returns NAMES, so the tests | |
| 56 | +# below run the CLI set, unset and get commands on every setting. | |
| 57 | +# | |
| 58 | +proc smoke_sample {names} { | |
| 59 | + if {[test_assurance] ne "smoke"} { | |
| 60 | + return $names | |
| 61 | + } | |
| 62 | + set sample [concat $::th1_sample [get_sample_settings $names]] | |
| 63 | + return [lmap name $names { | |
| 64 | + expr {$name in $sample ? $name : [continue]} | |
| 65 | + }] | |
| 66 | +} | |
| 67 | + | |
| 68 | +if {[test_assurance] eq "smoke"} { | |
| 69 | + test_skip_part "all but one setting of each flag combination need\ | |
| 70 | +-assurance ci or stress" | |
| 71 | +} | |
| 72 | +set all_settings [smoke_sample $all_settings] | |
| 64 | 73 | |
| 65 | 74 | foreach name $th1_sample { |
| 66 | 75 | # |
| 67 | 76 | # NOTE: Query for the hard-coded default value of this setting and |
| 68 | 77 | # save it for the TH1 unset checks below. |
| @@ -208,11 +217,11 @@ | ||
| 208 | 217 | ############################################################################### |
| 209 | 218 | |
| 210 | 219 | set pattern(5) \ |
| 211 | 220 | {^%name%[ ]+\n \(overridden by contents of file \.fossil-settings/%name%\)$} |
| 212 | 221 | |
| 213 | -set versionable_settings [get_versionable_settings] | |
| 222 | +set versionable_settings [smoke_sample [get_versionable_settings]] | |
| 214 | 223 | file mkdir .fossil-settings |
| 215 | 224 | |
| 216 | 225 | foreach name $versionable_settings { |
| 217 | 226 | fossil settings $name --exact |
| 218 | 227 | set data [normalize_result] |
| 219 | 228 |
| --- test/settings-repo.test | |
| +++ test/settings-repo.test | |
| @@ -42,27 +42,36 @@ | |
| 42 | |
| 43 | set all_settings [get_all_settings] |
| 44 | |
| 45 | # |
| 46 | # Spot-check the TH1 "setting" bridge on a small fixed sample only. |
| 47 | # Every setting still gets full CLI set/unset/get coverage below; |
| 48 | # th1.test already exercises TH1 setting more broadly. |
| 49 | # |
| 50 | set th1_sample [list autosync ignore-glob manifest] |
| 51 | |
| 52 | foreach name $all_settings { |
| 53 | # |
| 54 | # HACK: Make 100% sure that there are no non-default setting values |
| 55 | # present anywhere. |
| 56 | # |
| 57 | if {$name eq "manifest"} { |
| 58 | fossil unset $name --exact --global -expectError |
| 59 | } else { |
| 60 | fossil unset $name --exact --global |
| 61 | } |
| 62 | fossil unset $name --exact |
| 63 | } |
| 64 | |
| 65 | foreach name $th1_sample { |
| 66 | # |
| 67 | # NOTE: Query for the hard-coded default value of this setting and |
| 68 | # save it for the TH1 unset checks below. |
| @@ -208,11 +217,11 @@ | |
| 208 | ############################################################################### |
| 209 | |
| 210 | set pattern(5) \ |
| 211 | {^%name%[ ]+\n \(overridden by contents of file \.fossil-settings/%name%\)$} |
| 212 | |
| 213 | set versionable_settings [get_versionable_settings] |
| 214 | file mkdir .fossil-settings |
| 215 | |
| 216 | foreach name $versionable_settings { |
| 217 | fossil settings $name --exact |
| 218 | set data [normalize_result] |
| 219 |
| --- test/settings-repo.test | |
| +++ test/settings-repo.test | |
| @@ -42,27 +42,36 @@ | |
| 42 | |
| 43 | set all_settings [get_all_settings] |
| 44 | |
| 45 | # |
| 46 | # Spot-check the TH1 "setting" bridge on a small fixed sample only. |
| 47 | # th1.test already exercises TH1 setting more broadly. |
| 48 | # |
| 49 | set th1_sample [list autosync ignore-glob manifest] |
| 50 | |
| 51 | # |
| 52 | # At -assurance smoke, returns the settings in NAMES that are in |
| 53 | # th1_sample or that get_sample_settings returns, which is the first |
| 54 | # setting in NAMES for each distinct KINDS value from |
| 55 | # get_source_settings. At ci and stress, returns NAMES, so the tests |
| 56 | # below run the CLI set, unset and get commands on every setting. |
| 57 | # |
| 58 | proc smoke_sample {names} { |
| 59 | if {[test_assurance] ne "smoke"} { |
| 60 | return $names |
| 61 | } |
| 62 | set sample [concat $::th1_sample [get_sample_settings $names]] |
| 63 | return [lmap name $names { |
| 64 | expr {$name in $sample ? $name : [continue]} |
| 65 | }] |
| 66 | } |
| 67 | |
| 68 | if {[test_assurance] eq "smoke"} { |
| 69 | test_skip_part "all but one setting of each flag combination need\ |
| 70 | -assurance ci or stress" |
| 71 | } |
| 72 | set all_settings [smoke_sample $all_settings] |
| 73 | |
| 74 | foreach name $th1_sample { |
| 75 | # |
| 76 | # NOTE: Query for the hard-coded default value of this setting and |
| 77 | # save it for the TH1 unset checks below. |
| @@ -208,11 +217,11 @@ | |
| 217 | ############################################################################### |
| 218 | |
| 219 | set pattern(5) \ |
| 220 | {^%name%[ ]+\n \(overridden by contents of file \.fossil-settings/%name%\)$} |
| 221 | |
| 222 | set versionable_settings [smoke_sample [get_versionable_settings]] |
| 223 | file mkdir .fossil-settings |
| 224 | |
| 225 | foreach name $versionable_settings { |
| 226 | fossil settings $name --exact |
| 227 | set data [normalize_result] |
| 228 |
+32
-3
| --- test/tester.tcl | ||
| +++ test/tester.tcl | ||
| @@ -526,11 +526,13 @@ | ||
| 526 | 526 | proc get_source_dir {} { |
| 527 | 527 | return [file join [file dirname $::testfiledir] src] |
| 528 | 528 | } |
| 529 | 529 | |
| 530 | 530 | # Returns a dictionary of the settings defined in the source files, with |
| 531 | -# the setting name as key and a list {VERSIONABLE CONDITIONAL} as value. | |
| 531 | +# the setting name as key and a list {VERSIONABLE CONDITIONAL KINDS} as | |
| 532 | +# value. KINDS is the sorted list of the setting's FLAGS, without | |
| 533 | +# "width" and "default" and without the "=VALUE" of any flag. | |
| 532 | 534 | # |
| 533 | 535 | # A setting is defined by a "** SETTING: NAME ?FLAGS?" comment, which |
| 534 | 536 | # tools/mkindex.c reads to build the table of settings compiled into |
| 535 | 537 | # fossil. The setting is versionable if FLAGS include "versionable". |
| 536 | 538 | # As in mkindex, a setting is conditional when the last preprocessor |
| @@ -553,25 +555,52 @@ | ||
| 553 | 555 | } |
| 554 | 556 | } elseif {[regexp -- {^\*\* SETTING:\s+(\S+)(.*)$} $line \ |
| 555 | 557 | dummy name flags]} { |
| 556 | 558 | set flags [regexp -all -inline {\S+} $flags] |
| 557 | 559 | set versionable [expr {"versionable" in $flags}] |
| 560 | + set kinds [list] | |
| 561 | + foreach flag $flags { | |
| 562 | + set kind [lindex [split $flag =] 0] | |
| 563 | + if {$kind ni {width default}} { | |
| 564 | + lappend kinds $kind | |
| 565 | + } | |
| 566 | + } | |
| 567 | + set kinds [lsort -unique $kinds] | |
| 558 | 568 | dict incr count $name |
| 559 | - dict set result $name [list $versionable $inIf] | |
| 569 | + dict set result $name [list $versionable $inIf $kinds] | |
| 560 | 570 | } |
| 561 | 571 | } |
| 562 | 572 | } |
| 563 | 573 | if {[dict size $result] == 0} { |
| 564 | 574 | error "No \"** SETTING:\" comments found in [get_source_dir]/*.c" |
| 565 | 575 | } |
| 566 | 576 | dict for {name n} $count { |
| 567 | 577 | if {$n > 1} { |
| 568 | - dict set result $name [list [lindex [dict get $result $name] 0] 0] | |
| 578 | + lassign [dict get $result $name] versionable inIf kinds | |
| 579 | + dict set result $name [list $versionable 0 $kinds] | |
| 569 | 580 | } |
| 570 | 581 | } |
| 571 | 582 | return $result |
| 572 | 583 | } |
| 584 | + | |
| 585 | +# Returns each setting in NAMES that is the first in NAMES to have its | |
| 586 | +# value of KINDS, where get_source_settings returns the KINDS of each | |
| 587 | +# setting. The "settings" and "unset" | |
| 588 | +# commands run the same code for two settings that have the same KINDS. | |
| 589 | +# | |
| 590 | +proc get_sample_settings {names} { | |
| 591 | + set source [get_source_settings] | |
| 592 | + set seen [dict create] | |
| 593 | + set result [list] | |
| 594 | + foreach name $names { | |
| 595 | + set kinds [lindex [dict get $source $name] 2] | |
| 596 | + if {[dict exists $seen $kinds]} continue | |
| 597 | + dict set seen $kinds 1 | |
| 598 | + lappend result $name | |
| 599 | + } | |
| 600 | + return $result | |
| 601 | +} | |
| 573 | 602 | |
| 574 | 603 | # Returns the settings defined in the source files that this fossil |
| 575 | 604 | # binary has: every unconditional setting, and each conditional setting |
| 576 | 605 | # that "fossil settings NAME --exact" accepts. With VERSIONABLE true, |
| 577 | 606 | # returns only the versionable ones. |
| 578 | 607 |
| --- test/tester.tcl | |
| +++ test/tester.tcl | |
| @@ -526,11 +526,13 @@ | |
| 526 | proc get_source_dir {} { |
| 527 | return [file join [file dirname $::testfiledir] src] |
| 528 | } |
| 529 | |
| 530 | # Returns a dictionary of the settings defined in the source files, with |
| 531 | # the setting name as key and a list {VERSIONABLE CONDITIONAL} as value. |
| 532 | # |
| 533 | # A setting is defined by a "** SETTING: NAME ?FLAGS?" comment, which |
| 534 | # tools/mkindex.c reads to build the table of settings compiled into |
| 535 | # fossil. The setting is versionable if FLAGS include "versionable". |
| 536 | # As in mkindex, a setting is conditional when the last preprocessor |
| @@ -553,25 +555,52 @@ | |
| 553 | } |
| 554 | } elseif {[regexp -- {^\*\* SETTING:\s+(\S+)(.*)$} $line \ |
| 555 | dummy name flags]} { |
| 556 | set flags [regexp -all -inline {\S+} $flags] |
| 557 | set versionable [expr {"versionable" in $flags}] |
| 558 | dict incr count $name |
| 559 | dict set result $name [list $versionable $inIf] |
| 560 | } |
| 561 | } |
| 562 | } |
| 563 | if {[dict size $result] == 0} { |
| 564 | error "No \"** SETTING:\" comments found in [get_source_dir]/*.c" |
| 565 | } |
| 566 | dict for {name n} $count { |
| 567 | if {$n > 1} { |
| 568 | dict set result $name [list [lindex [dict get $result $name] 0] 0] |
| 569 | } |
| 570 | } |
| 571 | return $result |
| 572 | } |
| 573 | |
| 574 | # Returns the settings defined in the source files that this fossil |
| 575 | # binary has: every unconditional setting, and each conditional setting |
| 576 | # that "fossil settings NAME --exact" accepts. With VERSIONABLE true, |
| 577 | # returns only the versionable ones. |
| 578 |
| --- test/tester.tcl | |
| +++ test/tester.tcl | |
| @@ -526,11 +526,13 @@ | |
| 526 | proc get_source_dir {} { |
| 527 | return [file join [file dirname $::testfiledir] src] |
| 528 | } |
| 529 | |
| 530 | # Returns a dictionary of the settings defined in the source files, with |
| 531 | # the setting name as key and a list {VERSIONABLE CONDITIONAL KINDS} as |
| 532 | # value. KINDS is the sorted list of the setting's FLAGS, without |
| 533 | # "width" and "default" and without the "=VALUE" of any flag. |
| 534 | # |
| 535 | # A setting is defined by a "** SETTING: NAME ?FLAGS?" comment, which |
| 536 | # tools/mkindex.c reads to build the table of settings compiled into |
| 537 | # fossil. The setting is versionable if FLAGS include "versionable". |
| 538 | # As in mkindex, a setting is conditional when the last preprocessor |
| @@ -553,25 +555,52 @@ | |
| 555 | } |
| 556 | } elseif {[regexp -- {^\*\* SETTING:\s+(\S+)(.*)$} $line \ |
| 557 | dummy name flags]} { |
| 558 | set flags [regexp -all -inline {\S+} $flags] |
| 559 | set versionable [expr {"versionable" in $flags}] |
| 560 | set kinds [list] |
| 561 | foreach flag $flags { |
| 562 | set kind [lindex [split $flag =] 0] |
| 563 | if {$kind ni {width default}} { |
| 564 | lappend kinds $kind |
| 565 | } |
| 566 | } |
| 567 | set kinds [lsort -unique $kinds] |
| 568 | dict incr count $name |
| 569 | dict set result $name [list $versionable $inIf $kinds] |
| 570 | } |
| 571 | } |
| 572 | } |
| 573 | if {[dict size $result] == 0} { |
| 574 | error "No \"** SETTING:\" comments found in [get_source_dir]/*.c" |
| 575 | } |
| 576 | dict for {name n} $count { |
| 577 | if {$n > 1} { |
| 578 | lassign [dict get $result $name] versionable inIf kinds |
| 579 | dict set result $name [list $versionable 0 $kinds] |
| 580 | } |
| 581 | } |
| 582 | return $result |
| 583 | } |
| 584 | |
| 585 | # Returns each setting in NAMES that is the first in NAMES to have its |
| 586 | # value of KINDS, where get_source_settings returns the KINDS of each |
| 587 | # setting. The "settings" and "unset" |
| 588 | # commands run the same code for two settings that have the same KINDS. |
| 589 | # |
| 590 | proc get_sample_settings {names} { |
| 591 | set source [get_source_settings] |
| 592 | set seen [dict create] |
| 593 | set result [list] |
| 594 | foreach name $names { |
| 595 | set kinds [lindex [dict get $source $name] 2] |
| 596 | if {[dict exists $seen $kinds]} continue |
| 597 | dict set seen $kinds 1 |
| 598 | lappend result $name |
| 599 | } |
| 600 | return $result |
| 601 | } |
| 602 | |
| 603 | # Returns the settings defined in the source files that this fossil |
| 604 | # binary has: every unconditional setting, and each conditional setting |
| 605 | # that "fossil settings NAME --exact" accepts. With VERSIONABLE true, |
| 606 | # returns only the versionable ones. |
| 607 |