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.

wyoung 2018-09-03 02:57 wrap-run_in_checkout
Commit 1a4e87dcc118aa5c0e10602a4a9b65c89368e8bd895a6603e7d94cae491022aa
2 files changed +10 -17 +1 -1
+10 -17
--- test/tester.tcl
+++ test/tester.tcl
@@ -31,13 +31,17 @@
3131
set testrundir [pwd]
3232
set testdir [file normalize [file dirname $argv0]]
3333
set fossilexe [file normalize [lindex $argv 0]]
3434
set is_windows [expr {$::tcl_platform(platform) eq "windows"}]
3535
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"]
3943
}
4044
4145
set argv [lrange $argv 1 end]
4246
4347
set i [lsearch $argv -keep]
@@ -522,12 +526,12 @@
522526
# Run the given command script inside the Fossil source repo checkout.
523527
#
524528
# Callers of this function must ensure two things:
525529
#
526530
# 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.
529533
#
530534
# As a rule, you should not be calling this function directly!
531535
#
532536
# 2. The test does NOT modify the Fossil checkout tree in any way.
533537
proc run_in_checkout { script {dir ""} } {
@@ -538,28 +542,17 @@
538542
} result]
539543
cd $savedPwd; unset savedPwd
540544
return -code $code $result
541545
}
542546
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
-
554547
# Wrapper for the above function pair. The tscript parameter is an
555548
# optional post-run test script. Some callers choose instead to put
556549
# the tests inline with the rscript commands.
557550
#
558551
# Be sure to adhere to the requirements of run_in_checkout!
559552
proc test_block_in_checkout { name rscript {tscript ""} } {
560
- if {[outside_fossil_repo]} {
553
+ if {$::outside_fossil_repo} {
561554
puts "Skipping $name test: not in Fossil repo checkout."
562555
} else {
563556
run_in_checkout $rscript
564557
if {[string length $tscript] == 0} {
565558
return ""
566559
--- 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
--- test/th1-docs.test
+++ test/th1-docs.test
@@ -16,11 +16,11 @@
1616
############################################################################
1717
#
1818
# TH1 Docs
1919
#
2020
21
-if {[outside_fossil_repo]} {
21
+if {$::outside_fossil_repo} {
2222
puts "Skipping th1-docs-* tests: not in Fossil repo checkout."
2323
test_cleanup_then_return
2424
}
2525
2626
fossil test-th-eval "hasfeature th1Docs"
2727
--- 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

Keyboard Shortcuts

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