Fossil SCM
Modify 'th1' test file to run most of its tests outside of the Fossil source checkout using a new test suite infrastructure procedure.
Commit
7b9b5807f48f9e53b06d800ac488f78d351d3e9d
Parent
d141b84a9972805…
2 files changed
+18
+17
-6
+18
| --- test/tester.tcl | ||
| +++ test/tester.tcl | ||
| @@ -21,10 +21,11 @@ | ||
| 21 | 21 | # |
| 22 | 22 | # Where ../test/tester.tcl is the name of this file and ../bld/fossil |
| 23 | 23 | # is the name of the executable to be tested. |
| 24 | 24 | # |
| 25 | 25 | |
| 26 | +set testfiledir [file dirname [info script]] | |
| 26 | 27 | set testrundir [pwd] |
| 27 | 28 | set testdir [file normalize [file dir $argv0]] |
| 28 | 29 | set fossilexe [file normalize [lindex $argv 0]] |
| 29 | 30 | set argv [lrange $argv 1 end] |
| 30 | 31 | |
| @@ -188,10 +189,27 @@ | ||
| 188 | 189 | exec $::fossilexe new $filename |
| 189 | 190 | exec $::fossilexe open $filename |
| 190 | 191 | exec $::fossilexe clean -f |
| 191 | 192 | exec $::fossilexe set mtime-changes off |
| 192 | 193 | } |
| 194 | + | |
| 195 | +# This (rarely used) procedure is designed to run a test within the Fossil | |
| 196 | +# source checkout (e.g. one that does NOT modify any state), while saving | |
| 197 | +# and restoring the current directory (e.g. one used when running a test | |
| 198 | +# file outside of the Fossil source checkout). Please do NOT use this | |
| 199 | +# procedure unless you are absolutely sure it does not modify the state of | |
| 200 | +# the repository or source checkout in any way. | |
| 201 | +# | |
| 202 | +proc run_in_checkout { script {dir ""} } { | |
| 203 | + if {[string length $dir] == 0} {set dir $::testfiledir} | |
| 204 | + set savedPwd [pwd]; cd $dir | |
| 205 | + set code [catch { | |
| 206 | + uplevel 1 $script | |
| 207 | + } result] | |
| 208 | + cd $savedPwd; unset savedPwd | |
| 209 | + return -code $code $result | |
| 210 | +} | |
| 193 | 211 | |
| 194 | 212 | # Normalize file status lists (like those returned by 'fossil changes') |
| 195 | 213 | # so they can be compared using simple string comparison |
| 196 | 214 | # |
| 197 | 215 | proc normalize_status_list {list} { |
| 198 | 216 |
| --- test/tester.tcl | |
| +++ test/tester.tcl | |
| @@ -21,10 +21,11 @@ | |
| 21 | # |
| 22 | # Where ../test/tester.tcl is the name of this file and ../bld/fossil |
| 23 | # is the name of the executable to be tested. |
| 24 | # |
| 25 | |
| 26 | set testrundir [pwd] |
| 27 | set testdir [file normalize [file dir $argv0]] |
| 28 | set fossilexe [file normalize [lindex $argv 0]] |
| 29 | set argv [lrange $argv 1 end] |
| 30 | |
| @@ -188,10 +189,27 @@ | |
| 188 | exec $::fossilexe new $filename |
| 189 | exec $::fossilexe open $filename |
| 190 | exec $::fossilexe clean -f |
| 191 | exec $::fossilexe set mtime-changes off |
| 192 | } |
| 193 | |
| 194 | # Normalize file status lists (like those returned by 'fossil changes') |
| 195 | # so they can be compared using simple string comparison |
| 196 | # |
| 197 | proc normalize_status_list {list} { |
| 198 |
| --- test/tester.tcl | |
| +++ test/tester.tcl | |
| @@ -21,10 +21,11 @@ | |
| 21 | # |
| 22 | # Where ../test/tester.tcl is the name of this file and ../bld/fossil |
| 23 | # is the name of the executable to be tested. |
| 24 | # |
| 25 | |
| 26 | set testfiledir [file dirname [info script]] |
| 27 | set testrundir [pwd] |
| 28 | set testdir [file normalize [file dir $argv0]] |
| 29 | set fossilexe [file normalize [lindex $argv 0]] |
| 30 | set argv [lrange $argv 1 end] |
| 31 | |
| @@ -188,10 +189,27 @@ | |
| 189 | exec $::fossilexe new $filename |
| 190 | exec $::fossilexe open $filename |
| 191 | exec $::fossilexe clean -f |
| 192 | exec $::fossilexe set mtime-changes off |
| 193 | } |
| 194 | |
| 195 | # This (rarely used) procedure is designed to run a test within the Fossil |
| 196 | # source checkout (e.g. one that does NOT modify any state), while saving |
| 197 | # and restoring the current directory (e.g. one used when running a test |
| 198 | # file outside of the Fossil source checkout). Please do NOT use this |
| 199 | # procedure unless you are absolutely sure it does not modify the state of |
| 200 | # the repository or source checkout in any way. |
| 201 | # |
| 202 | proc run_in_checkout { script {dir ""} } { |
| 203 | if {[string length $dir] == 0} {set dir $::testfiledir} |
| 204 | set savedPwd [pwd]; cd $dir |
| 205 | set code [catch { |
| 206 | uplevel 1 $script |
| 207 | } result] |
| 208 | cd $savedPwd; unset savedPwd |
| 209 | return -code $code $result |
| 210 | } |
| 211 | |
| 212 | # Normalize file status lists (like those returned by 'fossil changes') |
| 213 | # so they can be compared using simple string comparison |
| 214 | # |
| 215 | proc normalize_status_list {list} { |
| 216 |
+17
-6
| --- test/th1.test | ||
| +++ test/th1.test | ||
| @@ -16,11 +16,11 @@ | ||
| 16 | 16 | ############################################################################ |
| 17 | 17 | # |
| 18 | 18 | # TH1 Commands |
| 19 | 19 | # |
| 20 | 20 | |
| 21 | -set dir [file dirname [info script]] | |
| 21 | +set dir [file dirname [info script]]; repo_init | |
| 22 | 22 | |
| 23 | 23 | ############################################################################### |
| 24 | 24 | |
| 25 | 25 | fossil test-th-eval --open-config "setting th1-hooks" |
| 26 | 26 | set th1Hooks [expr {$RESULT eq "1"}] |
| @@ -639,11 +639,14 @@ | ||
| 639 | 639 | fossil test-th-eval "styleHeader {Page Title Here}" |
| 640 | 640 | test th1-header-1 {$RESULT eq {TH_ERROR: repository unavailable}} |
| 641 | 641 | |
| 642 | 642 | ############################################################################### |
| 643 | 643 | |
| 644 | -fossil test-th-eval --open-config "styleHeader {Page Title Here}" | |
| 644 | +run_in_checkout { | |
| 645 | + fossil test-th-eval --open-config "styleHeader {Page Title Here}" | |
| 646 | +} | |
| 647 | + | |
| 645 | 648 | test th1-header-2 {[regexp -- {<title>Fossil: Page Title Here</title>} $RESULT]} |
| 646 | 649 | |
| 647 | 650 | ############################################################################### |
| 648 | 651 | |
| 649 | 652 | fossil test-th-eval "styleFooter" |
| @@ -722,11 +725,14 @@ | ||
| 722 | 725 | fossil test-th-eval "artifact tip" |
| 723 | 726 | test th1-artifact-2 {$RESULT eq {TH_ERROR: repository unavailable}} |
| 724 | 727 | |
| 725 | 728 | ############################################################################### |
| 726 | 729 | |
| 727 | -fossil test-th-eval --open-config "artifact tip" | |
| 730 | +run_in_checkout { | |
| 731 | + fossil test-th-eval --open-config "artifact tip" | |
| 732 | +} | |
| 733 | + | |
| 728 | 734 | test th1-artifact-3 {[regexp -- {F test/th1\.test [0-9a-f]{40}} $RESULT]} |
| 729 | 735 | |
| 730 | 736 | ############################################################################### |
| 731 | 737 | |
| 732 | 738 | fossil test-th-eval "artifact 0000000000" |
| @@ -742,11 +748,14 @@ | ||
| 742 | 748 | fossil test-th-eval "artifact tip test/th1.test" |
| 743 | 749 | test th1-artifact-6 {$RESULT eq {TH_ERROR: repository unavailable}} |
| 744 | 750 | |
| 745 | 751 | ############################################################################### |
| 746 | 752 | |
| 747 | -fossil test-th-eval --open-config "artifact tip test/th1.test" | |
| 753 | +run_in_checkout { | |
| 754 | + fossil test-th-eval --open-config "artifact tip test/th1.test" | |
| 755 | +} | |
| 756 | + | |
| 748 | 757 | test th1-artifact-7 {[regexp -- {th1-artifact-7} $RESULT]} |
| 749 | 758 | |
| 750 | 759 | ############################################################################### |
| 751 | 760 | |
| 752 | 761 | fossil test-th-eval "artifact 0000000000 test/th1.test" |
| @@ -1260,10 +1269,12 @@ | ||
| 1260 | 1269 | |
| 1261 | 1270 | # |
| 1262 | 1271 | # TODO: Modify the result of this test if the source file (i.e. |
| 1263 | 1272 | # "ajax/cgi-bin/fossil-json.cgi.example") changes. |
| 1264 | 1273 | # |
| 1265 | -fossil test-th-eval --open-config \ | |
| 1266 | - {encode64 [artifact trunk ajax/cgi-bin/fossil-json.cgi.example]} | |
| 1274 | +run_in_checkout { | |
| 1275 | + fossil test-th-eval --open-config \ | |
| 1276 | + {encode64 [artifact trunk ajax/cgi-bin/fossil-json.cgi.example]} | |
| 1277 | +} | |
| 1267 | 1278 | |
| 1268 | 1279 | test th1-encode64-3 {$RESULT eq \ |
| 1269 | 1280 | "IyEvcGF0aC90by9mb3NzaWwvYmluYXJ5CnJlcG9zaXRvcnk6IC9wYXRoL3RvL3JlcG8uZnNsCg=="} |
| 1270 | 1281 |
| --- test/th1.test | |
| +++ test/th1.test | |
| @@ -16,11 +16,11 @@ | |
| 16 | ############################################################################ |
| 17 | # |
| 18 | # TH1 Commands |
| 19 | # |
| 20 | |
| 21 | set dir [file dirname [info script]] |
| 22 | |
| 23 | ############################################################################### |
| 24 | |
| 25 | fossil test-th-eval --open-config "setting th1-hooks" |
| 26 | set th1Hooks [expr {$RESULT eq "1"}] |
| @@ -639,11 +639,14 @@ | |
| 639 | fossil test-th-eval "styleHeader {Page Title Here}" |
| 640 | test th1-header-1 {$RESULT eq {TH_ERROR: repository unavailable}} |
| 641 | |
| 642 | ############################################################################### |
| 643 | |
| 644 | fossil test-th-eval --open-config "styleHeader {Page Title Here}" |
| 645 | test th1-header-2 {[regexp -- {<title>Fossil: Page Title Here</title>} $RESULT]} |
| 646 | |
| 647 | ############################################################################### |
| 648 | |
| 649 | fossil test-th-eval "styleFooter" |
| @@ -722,11 +725,14 @@ | |
| 722 | fossil test-th-eval "artifact tip" |
| 723 | test th1-artifact-2 {$RESULT eq {TH_ERROR: repository unavailable}} |
| 724 | |
| 725 | ############################################################################### |
| 726 | |
| 727 | fossil test-th-eval --open-config "artifact tip" |
| 728 | test th1-artifact-3 {[regexp -- {F test/th1\.test [0-9a-f]{40}} $RESULT]} |
| 729 | |
| 730 | ############################################################################### |
| 731 | |
| 732 | fossil test-th-eval "artifact 0000000000" |
| @@ -742,11 +748,14 @@ | |
| 742 | fossil test-th-eval "artifact tip test/th1.test" |
| 743 | test th1-artifact-6 {$RESULT eq {TH_ERROR: repository unavailable}} |
| 744 | |
| 745 | ############################################################################### |
| 746 | |
| 747 | fossil test-th-eval --open-config "artifact tip test/th1.test" |
| 748 | test th1-artifact-7 {[regexp -- {th1-artifact-7} $RESULT]} |
| 749 | |
| 750 | ############################################################################### |
| 751 | |
| 752 | fossil test-th-eval "artifact 0000000000 test/th1.test" |
| @@ -1260,10 +1269,12 @@ | |
| 1260 | |
| 1261 | # |
| 1262 | # TODO: Modify the result of this test if the source file (i.e. |
| 1263 | # "ajax/cgi-bin/fossil-json.cgi.example") changes. |
| 1264 | # |
| 1265 | fossil test-th-eval --open-config \ |
| 1266 | {encode64 [artifact trunk ajax/cgi-bin/fossil-json.cgi.example]} |
| 1267 | |
| 1268 | test th1-encode64-3 {$RESULT eq \ |
| 1269 | "IyEvcGF0aC90by9mb3NzaWwvYmluYXJ5CnJlcG9zaXRvcnk6IC9wYXRoL3RvL3JlcG8uZnNsCg=="} |
| 1270 |
| --- test/th1.test | |
| +++ test/th1.test | |
| @@ -16,11 +16,11 @@ | |
| 16 | ############################################################################ |
| 17 | # |
| 18 | # TH1 Commands |
| 19 | # |
| 20 | |
| 21 | set dir [file dirname [info script]]; repo_init |
| 22 | |
| 23 | ############################################################################### |
| 24 | |
| 25 | fossil test-th-eval --open-config "setting th1-hooks" |
| 26 | set th1Hooks [expr {$RESULT eq "1"}] |
| @@ -639,11 +639,14 @@ | |
| 639 | fossil test-th-eval "styleHeader {Page Title Here}" |
| 640 | test th1-header-1 {$RESULT eq {TH_ERROR: repository unavailable}} |
| 641 | |
| 642 | ############################################################################### |
| 643 | |
| 644 | run_in_checkout { |
| 645 | fossil test-th-eval --open-config "styleHeader {Page Title Here}" |
| 646 | } |
| 647 | |
| 648 | test th1-header-2 {[regexp -- {<title>Fossil: Page Title Here</title>} $RESULT]} |
| 649 | |
| 650 | ############################################################################### |
| 651 | |
| 652 | fossil test-th-eval "styleFooter" |
| @@ -722,11 +725,14 @@ | |
| 725 | fossil test-th-eval "artifact tip" |
| 726 | test th1-artifact-2 {$RESULT eq {TH_ERROR: repository unavailable}} |
| 727 | |
| 728 | ############################################################################### |
| 729 | |
| 730 | run_in_checkout { |
| 731 | fossil test-th-eval --open-config "artifact tip" |
| 732 | } |
| 733 | |
| 734 | test th1-artifact-3 {[regexp -- {F test/th1\.test [0-9a-f]{40}} $RESULT]} |
| 735 | |
| 736 | ############################################################################### |
| 737 | |
| 738 | fossil test-th-eval "artifact 0000000000" |
| @@ -742,11 +748,14 @@ | |
| 748 | fossil test-th-eval "artifact tip test/th1.test" |
| 749 | test th1-artifact-6 {$RESULT eq {TH_ERROR: repository unavailable}} |
| 750 | |
| 751 | ############################################################################### |
| 752 | |
| 753 | run_in_checkout { |
| 754 | fossil test-th-eval --open-config "artifact tip test/th1.test" |
| 755 | } |
| 756 | |
| 757 | test th1-artifact-7 {[regexp -- {th1-artifact-7} $RESULT]} |
| 758 | |
| 759 | ############################################################################### |
| 760 | |
| 761 | fossil test-th-eval "artifact 0000000000 test/th1.test" |
| @@ -1260,10 +1269,12 @@ | |
| 1269 | |
| 1270 | # |
| 1271 | # TODO: Modify the result of this test if the source file (i.e. |
| 1272 | # "ajax/cgi-bin/fossil-json.cgi.example") changes. |
| 1273 | # |
| 1274 | run_in_checkout { |
| 1275 | fossil test-th-eval --open-config \ |
| 1276 | {encode64 [artifact trunk ajax/cgi-bin/fossil-json.cgi.example]} |
| 1277 | } |
| 1278 | |
| 1279 | test th1-encode64-3 {$RESULT eq \ |
| 1280 | "IyEvcGF0aC90by9mb3NzaWwvYmluYXJ5CnJlcG9zaXRvcnk6IC9wYXRoL3RvL3JlcG8uZnNsCg=="} |
| 1281 |