Fossil SCM
Extracted the logic that was in tester.tcl's new outside_fossil_repo proc to the global level which just saves the result to a global variable so the logic doesn't have to be re-run for each test that relies on it. The result doesn't change from one call to the next, as you'd hope for a proc without parameters.
Commit
1a4e87dcc118aa5c0e10602a4a9b65c89368e8bd895a6603e7d94cae491022aa
Parent
33efa2fa05c1ff7…
2 files changed
+10
-17
+1
-1
+10
-17
| --- test/tester.tcl | ||
| +++ test/tester.tcl | ||
| @@ -31,13 +31,17 @@ | ||
| 31 | 31 | set testrundir [pwd] |
| 32 | 32 | set testdir [file normalize [file dirname $argv0]] |
| 33 | 33 | set fossilexe [file normalize [lindex $argv 0]] |
| 34 | 34 | set is_windows [expr {$::tcl_platform(platform) eq "windows"}] |
| 35 | 35 | |
| 36 | -if {$is_windows && \ | |
| 37 | - [string length [file extension $fossilexe]] == 0} { | |
| 38 | - append fossilexe .exe | |
| 36 | +if {$::is_windows} { | |
| 37 | + if {[string length [file extension $fossilexe]] == 0} { | |
| 38 | + append fossilexe .exe | |
| 39 | + } | |
| 40 | + set outside_fossil_repo ![file exists "$::testfiledir\\..\\_FOSSIL_"] | |
| 41 | +} else { | |
| 42 | + set outside_fossil_repo ![file exists "$::testfiledir/../.fslckout"] | |
| 39 | 43 | } |
| 40 | 44 | |
| 41 | 45 | set argv [lrange $argv 1 end] |
| 42 | 46 | |
| 43 | 47 | set i [lsearch $argv -keep] |
| @@ -522,12 +526,12 @@ | ||
| 522 | 526 | # Run the given command script inside the Fossil source repo checkout. |
| 523 | 527 | # |
| 524 | 528 | # Callers of this function must ensure two things: |
| 525 | 529 | # |
| 526 | 530 | # 1. This test run is in fact being done from within a Fossil repo |
| 527 | -# checkout directory. If you are unsure, call outside_fossil_repo | |
| 528 | -# or one of the test_* wrappers below it which do call it first. | |
| 531 | +# checkout directory. If you are unsure, test $::outside_fossil_repo | |
| 532 | +# or call one of the test_* wrappers below which do that for you. | |
| 529 | 533 | # |
| 530 | 534 | # As a rule, you should not be calling this function directly! |
| 531 | 535 | # |
| 532 | 536 | # 2. The test does NOT modify the Fossil checkout tree in any way. |
| 533 | 537 | proc run_in_checkout { script {dir ""} } { |
| @@ -538,28 +542,17 @@ | ||
| 538 | 542 | } result] |
| 539 | 543 | cd $savedPwd; unset savedPwd |
| 540 | 544 | return -code $code $result |
| 541 | 545 | } |
| 542 | 546 | |
| 543 | -# Return zero if we're being run from within a Fossil repo checkout. | |
| 544 | -# Used to skip uses of run_in_checkout so that those tests don't fail | |
| 545 | -# when run elsewhere, such as from a release tarball checkout. | |
| 546 | -proc outside_fossil_repo {} { | |
| 547 | - if {$::is_windows} { | |
| 548 | - return ![file exists "$::testfiledir\\..\\_FOSSIL_"] | |
| 549 | - } else { | |
| 550 | - return ![file exists "$::testfiledir/../.fslckout"] | |
| 551 | - } | |
| 552 | -} | |
| 553 | - | |
| 554 | 547 | # Wrapper for the above function pair. The tscript parameter is an |
| 555 | 548 | # optional post-run test script. Some callers choose instead to put |
| 556 | 549 | # the tests inline with the rscript commands. |
| 557 | 550 | # |
| 558 | 551 | # Be sure to adhere to the requirements of run_in_checkout! |
| 559 | 552 | proc test_block_in_checkout { name rscript {tscript ""} } { |
| 560 | - if {[outside_fossil_repo]} { | |
| 553 | + if {$::outside_fossil_repo} { | |
| 561 | 554 | puts "Skipping $name test: not in Fossil repo checkout." |
| 562 | 555 | } else { |
| 563 | 556 | run_in_checkout $rscript |
| 564 | 557 | if {[string length $tscript] == 0} { |
| 565 | 558 | return "" |
| 566 | 559 |
| --- test/tester.tcl | |
| +++ test/tester.tcl | |
| @@ -31,13 +31,17 @@ | |
| 31 | set testrundir [pwd] |
| 32 | set testdir [file normalize [file dirname $argv0]] |
| 33 | set fossilexe [file normalize [lindex $argv 0]] |
| 34 | set is_windows [expr {$::tcl_platform(platform) eq "windows"}] |
| 35 | |
| 36 | if {$is_windows && \ |
| 37 | [string length [file extension $fossilexe]] == 0} { |
| 38 | append fossilexe .exe |
| 39 | } |
| 40 | |
| 41 | set argv [lrange $argv 1 end] |
| 42 | |
| 43 | set i [lsearch $argv -keep] |
| @@ -522,12 +526,12 @@ | |
| 522 | # Run the given command script inside the Fossil source repo checkout. |
| 523 | # |
| 524 | # Callers of this function must ensure two things: |
| 525 | # |
| 526 | # 1. This test run is in fact being done from within a Fossil repo |
| 527 | # checkout directory. If you are unsure, call outside_fossil_repo |
| 528 | # or one of the test_* wrappers below it which do call it first. |
| 529 | # |
| 530 | # As a rule, you should not be calling this function directly! |
| 531 | # |
| 532 | # 2. The test does NOT modify the Fossil checkout tree in any way. |
| 533 | proc run_in_checkout { script {dir ""} } { |
| @@ -538,28 +542,17 @@ | |
| 538 | } result] |
| 539 | cd $savedPwd; unset savedPwd |
| 540 | return -code $code $result |
| 541 | } |
| 542 | |
| 543 | # Return zero if we're being run from within a Fossil repo checkout. |
| 544 | # Used to skip uses of run_in_checkout so that those tests don't fail |
| 545 | # when run elsewhere, such as from a release tarball checkout. |
| 546 | proc outside_fossil_repo {} { |
| 547 | if {$::is_windows} { |
| 548 | return ![file exists "$::testfiledir\\..\\_FOSSIL_"] |
| 549 | } else { |
| 550 | return ![file exists "$::testfiledir/../.fslckout"] |
| 551 | } |
| 552 | } |
| 553 | |
| 554 | # Wrapper for the above function pair. The tscript parameter is an |
| 555 | # optional post-run test script. Some callers choose instead to put |
| 556 | # the tests inline with the rscript commands. |
| 557 | # |
| 558 | # Be sure to adhere to the requirements of run_in_checkout! |
| 559 | proc test_block_in_checkout { name rscript {tscript ""} } { |
| 560 | if {[outside_fossil_repo]} { |
| 561 | puts "Skipping $name test: not in Fossil repo checkout." |
| 562 | } else { |
| 563 | run_in_checkout $rscript |
| 564 | if {[string length $tscript] == 0} { |
| 565 | return "" |
| 566 |
| --- test/tester.tcl | |
| +++ test/tester.tcl | |
| @@ -31,13 +31,17 @@ | |
| 31 | set testrundir [pwd] |
| 32 | set testdir [file normalize [file dirname $argv0]] |
| 33 | set fossilexe [file normalize [lindex $argv 0]] |
| 34 | set is_windows [expr {$::tcl_platform(platform) eq "windows"}] |
| 35 | |
| 36 | if {$::is_windows} { |
| 37 | if {[string length [file extension $fossilexe]] == 0} { |
| 38 | append fossilexe .exe |
| 39 | } |
| 40 | set outside_fossil_repo ![file exists "$::testfiledir\\..\\_FOSSIL_"] |
| 41 | } else { |
| 42 | set outside_fossil_repo ![file exists "$::testfiledir/../.fslckout"] |
| 43 | } |
| 44 | |
| 45 | set argv [lrange $argv 1 end] |
| 46 | |
| 47 | set i [lsearch $argv -keep] |
| @@ -522,12 +526,12 @@ | |
| 526 | # Run the given command script inside the Fossil source repo checkout. |
| 527 | # |
| 528 | # Callers of this function must ensure two things: |
| 529 | # |
| 530 | # 1. This test run is in fact being done from within a Fossil repo |
| 531 | # checkout directory. If you are unsure, test $::outside_fossil_repo |
| 532 | # or call one of the test_* wrappers below which do that for you. |
| 533 | # |
| 534 | # As a rule, you should not be calling this function directly! |
| 535 | # |
| 536 | # 2. The test does NOT modify the Fossil checkout tree in any way. |
| 537 | proc run_in_checkout { script {dir ""} } { |
| @@ -538,28 +542,17 @@ | |
| 542 | } result] |
| 543 | cd $savedPwd; unset savedPwd |
| 544 | return -code $code $result |
| 545 | } |
| 546 | |
| 547 | # Wrapper for the above function pair. The tscript parameter is an |
| 548 | # optional post-run test script. Some callers choose instead to put |
| 549 | # the tests inline with the rscript commands. |
| 550 | # |
| 551 | # Be sure to adhere to the requirements of run_in_checkout! |
| 552 | proc test_block_in_checkout { name rscript {tscript ""} } { |
| 553 | if {$::outside_fossil_repo} { |
| 554 | puts "Skipping $name test: not in Fossil repo checkout." |
| 555 | } else { |
| 556 | run_in_checkout $rscript |
| 557 | if {[string length $tscript] == 0} { |
| 558 | return "" |
| 559 |
+1
-1
| --- test/th1-docs.test | ||
| +++ test/th1-docs.test | ||
| @@ -16,11 +16,11 @@ | ||
| 16 | 16 | ############################################################################ |
| 17 | 17 | # |
| 18 | 18 | # TH1 Docs |
| 19 | 19 | # |
| 20 | 20 | |
| 21 | -if {[outside_fossil_repo]} { | |
| 21 | +if {$::outside_fossil_repo} { | |
| 22 | 22 | puts "Skipping th1-docs-* tests: not in Fossil repo checkout." |
| 23 | 23 | test_cleanup_then_return |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | fossil test-th-eval "hasfeature th1Docs" |
| 27 | 27 |
| --- test/th1-docs.test | |
| +++ test/th1-docs.test | |
| @@ -16,11 +16,11 @@ | |
| 16 | ############################################################################ |
| 17 | # |
| 18 | # TH1 Docs |
| 19 | # |
| 20 | |
| 21 | if {[outside_fossil_repo]} { |
| 22 | puts "Skipping th1-docs-* tests: not in Fossil repo checkout." |
| 23 | test_cleanup_then_return |
| 24 | } |
| 25 | |
| 26 | fossil test-th-eval "hasfeature th1Docs" |
| 27 |
| --- test/th1-docs.test | |
| +++ test/th1-docs.test | |
| @@ -16,11 +16,11 @@ | |
| 16 | ############################################################################ |
| 17 | # |
| 18 | # TH1 Docs |
| 19 | # |
| 20 | |
| 21 | if {$::outside_fossil_repo} { |
| 22 | puts "Skipping th1-docs-* tests: not in Fossil repo checkout." |
| 23 | test_cleanup_then_return |
| 24 | } |
| 25 | |
| 26 | fossil test-th-eval "hasfeature th1Docs" |
| 27 |