Fossil SCM
Fix direct fossil exec calls in 3 test files to call the "fossil" and "fossil_raw" the helper procedures in tester.tcl.
Commit
f9fea473a4540c5ee6fdf5f971410a50b125f6b58c931eaf96c2717d0c8cb567
Parent
c7137e0f928ffde…
4 files changed
+1
-1
+1
-2
+8
-6
+2
-1
+1
-1
| --- test/README.md | ||
| +++ test/README.md | ||
| @@ -194,11 +194,11 @@ | ||
| 194 | 194 | |
| 195 | 195 | * Start each test name and each procedure name with the file's name or a short form of it, such as `sync-clone-artifacts` and `sync_commit`. A failure report then says which file to open. |
| 196 | 196 | * Comment a procedure only if its name and arguments don't say what it does. Don't repeat the code in a comment. |
| 197 | 197 | * Call your global variables what you like. `tester.tcl` removes them when your file ends, so two files can't collide. Don't set a variable that `tester.tcl` owns, such as `RESULT`, `CODE`, `testdir` or `fossilexe`. |
| 198 | 198 | * If the file needs something the system might not have, call `test_skip` near the top so the summary shows it. |
| 199 | -* `fossil ARGS` counts output on standard error as a failure and can't tell a crash from an error. If your test expects either, reads the output as bytes, gives `fossil` input or needs a time limit, use `fossil_raw ARGS`, which sets `CODE` to the exit status, `crash` or `timeout`. Don't call `exec $::fossilexe` yourself. | |
| 199 | +* `fossil ARGS` counts output on standard error as a failure and can't tell a crash from an error. If your test expects either, reads the output as bytes, gives `fossil` input or needs a time limit, use `fossil_raw ARGS`, which sets `CODE` to the exit status, `crash` or `timeout`. Don't call `exec $::fossilexe` yourself, unless the test has to leave `fossil` running in the background. | |
| 200 | 200 | * Read a file with `read_file` and write one with `write_file`. |
| 201 | 201 | * If a test needs a program to stand in for a server, `ssh` or a merge tool, look in `standin/` before writing another script inside a Tcl string. `test_standin NAME DESTINATION` copies one into the test's directory. |
| 202 | 202 | * Keep lines within 80 columns. |
| 203 | 203 | |
| 204 | 204 | A command that fails under `fossil_raw` isn't reported as an error, so |
| 205 | 205 |
| --- test/README.md | |
| +++ test/README.md | |
| @@ -194,11 +194,11 @@ | |
| 194 | |
| 195 | * Start each test name and each procedure name with the file's name or a short form of it, such as `sync-clone-artifacts` and `sync_commit`. A failure report then says which file to open. |
| 196 | * Comment a procedure only if its name and arguments don't say what it does. Don't repeat the code in a comment. |
| 197 | * Call your global variables what you like. `tester.tcl` removes them when your file ends, so two files can't collide. Don't set a variable that `tester.tcl` owns, such as `RESULT`, `CODE`, `testdir` or `fossilexe`. |
| 198 | * If the file needs something the system might not have, call `test_skip` near the top so the summary shows it. |
| 199 | * `fossil ARGS` counts output on standard error as a failure and can't tell a crash from an error. If your test expects either, reads the output as bytes, gives `fossil` input or needs a time limit, use `fossil_raw ARGS`, which sets `CODE` to the exit status, `crash` or `timeout`. Don't call `exec $::fossilexe` yourself. |
| 200 | * Read a file with `read_file` and write one with `write_file`. |
| 201 | * If a test needs a program to stand in for a server, `ssh` or a merge tool, look in `standin/` before writing another script inside a Tcl string. `test_standin NAME DESTINATION` copies one into the test's directory. |
| 202 | * Keep lines within 80 columns. |
| 203 | |
| 204 | A command that fails under `fossil_raw` isn't reported as an error, so |
| 205 |
| --- test/README.md | |
| +++ test/README.md | |
| @@ -194,11 +194,11 @@ | |
| 194 | |
| 195 | * Start each test name and each procedure name with the file's name or a short form of it, such as `sync-clone-artifacts` and `sync_commit`. A failure report then says which file to open. |
| 196 | * Comment a procedure only if its name and arguments don't say what it does. Don't repeat the code in a comment. |
| 197 | * Call your global variables what you like. `tester.tcl` removes them when your file ends, so two files can't collide. Don't set a variable that `tester.tcl` owns, such as `RESULT`, `CODE`, `testdir` or `fossilexe`. |
| 198 | * If the file needs something the system might not have, call `test_skip` near the top so the summary shows it. |
| 199 | * `fossil ARGS` counts output on standard error as a failure and can't tell a crash from an error. If your test expects either, reads the output as bytes, gives `fossil` input or needs a time limit, use `fossil_raw ARGS`, which sets `CODE` to the exit status, `crash` or `timeout`. Don't call `exec $::fossilexe` yourself, unless the test has to leave `fossil` running in the background. |
| 200 | * Read a file with `read_file` and write one with `write_file`. |
| 201 | * If a test needs a program to stand in for a server, `ssh` or a merge tool, look in `standin/` before writing another script inside a Tcl string. `test_standin NAME DESTINATION` copies one into the test's directory. |
| 202 | * Keep lines within 80 columns. |
| 203 | |
| 204 | A command that fails under `fossil_raw` isn't reported as an error, so |
| 205 |
+1
-2
| --- test/login.test | ||
| +++ test/login.test | ||
| @@ -237,12 +237,11 @@ | ||
| 237 | 237 | |
| 238 | 238 | ############################################################################### |
| 239 | 239 | # test-ishuman labels User-Agent strings read from standard input. |
| 240 | 240 | |
| 241 | 241 | proc login_ishuman {agent} { |
| 242 | - write_file agent.txt "$agent\n" | |
| 243 | - set ::RESULT [exec $::fossilexe test-ishuman < agent.txt] | |
| 242 | + fossil_raw -input "$agent\n" test-ishuman | |
| 244 | 243 | return [lindex [split [string trim $::RESULT]] 0] |
| 245 | 244 | } |
| 246 | 245 | test_eq login-ishuman-firefox [login_ishuman "Mozilla/5.0 Firefox/122"] HUMAN |
| 247 | 246 | test_eq login-ishuman-spider [login_ishuman "something spider"] ROBOT |
| 248 | 247 | test_eq login-ishuman-url [login_ishuman "agent http://x"] ROBOT |
| 249 | 248 |
| --- test/login.test | |
| +++ test/login.test | |
| @@ -237,12 +237,11 @@ | |
| 237 | |
| 238 | ############################################################################### |
| 239 | # test-ishuman labels User-Agent strings read from standard input. |
| 240 | |
| 241 | proc login_ishuman {agent} { |
| 242 | write_file agent.txt "$agent\n" |
| 243 | set ::RESULT [exec $::fossilexe test-ishuman < agent.txt] |
| 244 | return [lindex [split [string trim $::RESULT]] 0] |
| 245 | } |
| 246 | test_eq login-ishuman-firefox [login_ishuman "Mozilla/5.0 Firefox/122"] HUMAN |
| 247 | test_eq login-ishuman-spider [login_ishuman "something spider"] ROBOT |
| 248 | test_eq login-ishuman-url [login_ishuman "agent http://x"] ROBOT |
| 249 |
| --- test/login.test | |
| +++ test/login.test | |
| @@ -237,12 +237,11 @@ | |
| 237 | |
| 238 | ############################################################################### |
| 239 | # test-ishuman labels User-Agent strings read from standard input. |
| 240 | |
| 241 | proc login_ishuman {agent} { |
| 242 | fossil_raw -input "$agent\n" test-ishuman |
| 243 | return [lindex [split [string trim $::RESULT]] 0] |
| 244 | } |
| 245 | test_eq login-ishuman-firefox [login_ishuman "Mozilla/5.0 Firefox/122"] HUMAN |
| 246 | test_eq login-ishuman-spider [login_ishuman "something spider"] ROBOT |
| 247 | test_eq login-ishuman-url [login_ishuman "agent http://x"] ROBOT |
| 248 |
+8
-6
| --- test/merge5.test | ||
| +++ test/merge5.test | ||
| @@ -19,16 +19,17 @@ | ||
| 19 | 19 | # |
| 20 | 20 | |
| 21 | 21 | # Verify the results of a check-out |
| 22 | 22 | # |
| 23 | 23 | proc checkout-test {testid expected_content} { |
| 24 | + global RESULT | |
| 24 | 25 | set flist {} |
| 25 | - foreach {status filename} [exec $::fossilexe ls -l] { | |
| 26 | + fossil ls -l | |
| 27 | + foreach {status filename} $RESULT { | |
| 26 | 28 | if {$status!="DELETED"} {lappend flist $filename} |
| 27 | 29 | } |
| 28 | 30 | eval fossil sha1sum [lsort $flist] |
| 29 | - global RESULT | |
| 30 | 31 | regsub -all {\n *} [string trim $expected_content] "\n " expected |
| 31 | 32 | regsub -all {\n *} [string trim $RESULT] "\n " result |
| 32 | 33 | if {$result!=$expected} { |
| 33 | 34 | protOut " Expected:\n $expected" |
| 34 | 35 | protOut " Got:\n $result" |
| @@ -40,15 +41,15 @@ | ||
| 40 | 41 | |
| 41 | 42 | require_no_open_checkout; test_setup "" |
| 42 | 43 | |
| 43 | 44 | # Construct a test repository |
| 44 | 45 | # |
| 45 | -exec $::fossilexe sqlite3 --no-repository m5.fossil \ | |
| 46 | - <$testfiledir/${testfile}_repo.sql | |
| 46 | +fossil_raw -input [read_file $testfiledir/${testfile}_repo.sql] \ | |
| 47 | + sqlite3 --no-repository m5.fossil | |
| 47 | 48 | # The SQL is a dump of a repository from 2010, whose config table has no |
| 48 | 49 | # mtime column, and "fossil rebuild" writes to config.mtime. |
| 49 | -exec $::fossilexe sqlite3 --no-repository m5.fossil \ | |
| 50 | +fossil_raw sqlite3 --no-repository m5.fossil \ | |
| 50 | 51 | "ALTER TABLE config ADD COLUMN mtime INTEGER;" |
| 51 | 52 | fossil rebuild m5.fossil |
| 52 | 53 | fossil open m5.fossil |
| 53 | 54 | fossil user default drh --user drh |
| 54 | 55 | fossil update baseline |
| @@ -219,11 +220,12 @@ | ||
| 219 | 220 | proc conflict-test {testid} { |
| 220 | 221 | global RESULT |
| 221 | 222 | set reported [string match "*WARNING: 1 merge conflicts*" $RESULT] |
| 222 | 223 | test merge5-$testid-reported $reported |
| 223 | 224 | set flist {} |
| 224 | - foreach {status filename} [exec $::fossilexe ls -l] { | |
| 225 | + fossil ls -l | |
| 226 | + foreach {status filename} $RESULT { | |
| 225 | 227 | if {$status!="DELETED"} {lappend flist $filename} |
| 226 | 228 | } |
| 227 | 229 | test merge5-$testid-files {[lsort $flist] eq "four.txt three.txt two.txt"} |
| 228 | 230 | set four [read_file four.txt] |
| 229 | 231 | set marked [string match "*BEGIN MERGE CONFLICT*END MERGE CONFLICT*" $four] |
| 230 | 232 |
| --- test/merge5.test | |
| +++ test/merge5.test | |
| @@ -19,16 +19,17 @@ | |
| 19 | # |
| 20 | |
| 21 | # Verify the results of a check-out |
| 22 | # |
| 23 | proc checkout-test {testid expected_content} { |
| 24 | set flist {} |
| 25 | foreach {status filename} [exec $::fossilexe ls -l] { |
| 26 | if {$status!="DELETED"} {lappend flist $filename} |
| 27 | } |
| 28 | eval fossil sha1sum [lsort $flist] |
| 29 | global RESULT |
| 30 | regsub -all {\n *} [string trim $expected_content] "\n " expected |
| 31 | regsub -all {\n *} [string trim $RESULT] "\n " result |
| 32 | if {$result!=$expected} { |
| 33 | protOut " Expected:\n $expected" |
| 34 | protOut " Got:\n $result" |
| @@ -40,15 +41,15 @@ | |
| 40 | |
| 41 | require_no_open_checkout; test_setup "" |
| 42 | |
| 43 | # Construct a test repository |
| 44 | # |
| 45 | exec $::fossilexe sqlite3 --no-repository m5.fossil \ |
| 46 | <$testfiledir/${testfile}_repo.sql |
| 47 | # The SQL is a dump of a repository from 2010, whose config table has no |
| 48 | # mtime column, and "fossil rebuild" writes to config.mtime. |
| 49 | exec $::fossilexe sqlite3 --no-repository m5.fossil \ |
| 50 | "ALTER TABLE config ADD COLUMN mtime INTEGER;" |
| 51 | fossil rebuild m5.fossil |
| 52 | fossil open m5.fossil |
| 53 | fossil user default drh --user drh |
| 54 | fossil update baseline |
| @@ -219,11 +220,12 @@ | |
| 219 | proc conflict-test {testid} { |
| 220 | global RESULT |
| 221 | set reported [string match "*WARNING: 1 merge conflicts*" $RESULT] |
| 222 | test merge5-$testid-reported $reported |
| 223 | set flist {} |
| 224 | foreach {status filename} [exec $::fossilexe ls -l] { |
| 225 | if {$status!="DELETED"} {lappend flist $filename} |
| 226 | } |
| 227 | test merge5-$testid-files {[lsort $flist] eq "four.txt three.txt two.txt"} |
| 228 | set four [read_file four.txt] |
| 229 | set marked [string match "*BEGIN MERGE CONFLICT*END MERGE CONFLICT*" $four] |
| 230 |
| --- test/merge5.test | |
| +++ test/merge5.test | |
| @@ -19,16 +19,17 @@ | |
| 19 | # |
| 20 | |
| 21 | # Verify the results of a check-out |
| 22 | # |
| 23 | proc checkout-test {testid expected_content} { |
| 24 | global RESULT |
| 25 | set flist {} |
| 26 | fossil ls -l |
| 27 | foreach {status filename} $RESULT { |
| 28 | if {$status!="DELETED"} {lappend flist $filename} |
| 29 | } |
| 30 | eval fossil sha1sum [lsort $flist] |
| 31 | regsub -all {\n *} [string trim $expected_content] "\n " expected |
| 32 | regsub -all {\n *} [string trim $RESULT] "\n " result |
| 33 | if {$result!=$expected} { |
| 34 | protOut " Expected:\n $expected" |
| 35 | protOut " Got:\n $result" |
| @@ -40,15 +41,15 @@ | |
| 41 | |
| 42 | require_no_open_checkout; test_setup "" |
| 43 | |
| 44 | # Construct a test repository |
| 45 | # |
| 46 | fossil_raw -input [read_file $testfiledir/${testfile}_repo.sql] \ |
| 47 | sqlite3 --no-repository m5.fossil |
| 48 | # The SQL is a dump of a repository from 2010, whose config table has no |
| 49 | # mtime column, and "fossil rebuild" writes to config.mtime. |
| 50 | fossil_raw sqlite3 --no-repository m5.fossil \ |
| 51 | "ALTER TABLE config ADD COLUMN mtime INTEGER;" |
| 52 | fossil rebuild m5.fossil |
| 53 | fossil open m5.fossil |
| 54 | fossil user default drh --user drh |
| 55 | fossil update baseline |
| @@ -219,11 +220,12 @@ | |
| 220 | proc conflict-test {testid} { |
| 221 | global RESULT |
| 222 | set reported [string match "*WARNING: 1 merge conflicts*" $RESULT] |
| 223 | test merge5-$testid-reported $reported |
| 224 | set flist {} |
| 225 | fossil ls -l |
| 226 | foreach {status filename} $RESULT { |
| 227 | if {$status!="DELETED"} {lappend flist $filename} |
| 228 | } |
| 229 | test merge5-$testid-files {[lsort $flist] eq "four.txt three.txt two.txt"} |
| 230 | set four [read_file four.txt] |
| 231 | set marked [string match "*BEGIN MERGE CONFLICT*END MERGE CONFLICT*" $four] |
| 232 |
+2
-1
| --- test/merge_exe.test | ||
| +++ test/merge_exe.test | ||
| @@ -30,11 +30,12 @@ | ||
| 30 | 30 | # WARNING: This is a hack for setting and testing a file's execute bit |
| 31 | 31 | # on Windows. Never operate directly on Fossil database files like this |
| 32 | 32 | # unless you really need to and really know what you're doing. |
| 33 | 33 | |
| 34 | 34 | proc query {sql} { |
| 35 | - return [exec $::fossilexe sqlite3 --no-repository _FOSSIL_ $sql] | |
| 35 | + fossil_raw sqlite3 --no-repository _FOSSIL_ $sql | |
| 36 | + return [string trim $::RESULT] | |
| 36 | 37 | } |
| 37 | 38 | |
| 38 | 39 | proc setx {fn isexe} { |
| 39 | 40 | set isexe [expr {bool($isexe)}] |
| 40 | 41 | query "UPDATE vfile SET isexe=$isexe WHERE pathname='$fn'" |
| 41 | 42 |
| --- test/merge_exe.test | |
| +++ test/merge_exe.test | |
| @@ -30,11 +30,12 @@ | |
| 30 | # WARNING: This is a hack for setting and testing a file's execute bit |
| 31 | # on Windows. Never operate directly on Fossil database files like this |
| 32 | # unless you really need to and really know what you're doing. |
| 33 | |
| 34 | proc query {sql} { |
| 35 | return [exec $::fossilexe sqlite3 --no-repository _FOSSIL_ $sql] |
| 36 | } |
| 37 | |
| 38 | proc setx {fn isexe} { |
| 39 | set isexe [expr {bool($isexe)}] |
| 40 | query "UPDATE vfile SET isexe=$isexe WHERE pathname='$fn'" |
| 41 |
| --- test/merge_exe.test | |
| +++ test/merge_exe.test | |
| @@ -30,11 +30,12 @@ | |
| 30 | # WARNING: This is a hack for setting and testing a file's execute bit |
| 31 | # on Windows. Never operate directly on Fossil database files like this |
| 32 | # unless you really need to and really know what you're doing. |
| 33 | |
| 34 | proc query {sql} { |
| 35 | fossil_raw sqlite3 --no-repository _FOSSIL_ $sql |
| 36 | return [string trim $::RESULT] |
| 37 | } |
| 38 | |
| 39 | proc setx {fn isexe} { |
| 40 | set isexe [expr {bool($isexe)}] |
| 41 | query "UPDATE vfile SET isexe=$isexe WHERE pathname='$fn'" |
| 42 |