Fossil SCM
Update 5 tests to use new test runner procedures especially fossil_raw
Commit
2ef9a4868e8e89f3f5662c3320df7f89fe5dc99c9481c4061688708da082f502
Parent
5862da0a752ef3c…
5 files changed
+1
-4
+2
-4
+11
-9
+4
-4
+2
-14
+1
-4
| --- test/amend.test | ||
| +++ test/amend.test | ||
| @@ -121,14 +121,11 @@ | ||
| 121 | 121 | } |
| 122 | 122 | } |
| 123 | 123 | fossil amend $HASH -bgcolor {} |
| 124 | 124 | test amend-bgcolor-2.1 {[string match "*hash:*$HASH*" $RESULT]} |
| 125 | 125 | fossil tag list --raw $HASH |
| 126 | -test amend-bgcolor-2.2 { | |
| 127 | - [string first "bgcolor=" $RESULT] == -1 && | |
| 128 | - [string first "bgcolor" $RESULT] != -1 | |
| 129 | -} | |
| 126 | +test amend-bgcolor-2.2 {[holds_strings $RESULT {!bgcolor= bgcolor}]} | |
| 130 | 127 | fossil timeline -n 1 |
| 131 | 128 | test amend-bgcolor-2.3 {[string match "*Cancel*background*color.*" $RESULT]} |
| 132 | 129 | if {[artifact_from_timeline $RESULT artid]} { |
| 133 | 130 | fossil artifact $artid |
| 134 | 131 | test amend-bgcolor-2.4 {[string match "*T -bgcolor $HASH*" $RESULT]} |
| 135 | 132 |
| --- test/amend.test | |
| +++ test/amend.test | |
| @@ -121,14 +121,11 @@ | |
| 121 | } |
| 122 | } |
| 123 | fossil amend $HASH -bgcolor {} |
| 124 | test amend-bgcolor-2.1 {[string match "*hash:*$HASH*" $RESULT]} |
| 125 | fossil tag list --raw $HASH |
| 126 | test amend-bgcolor-2.2 { |
| 127 | [string first "bgcolor=" $RESULT] == -1 && |
| 128 | [string first "bgcolor" $RESULT] != -1 |
| 129 | } |
| 130 | fossil timeline -n 1 |
| 131 | test amend-bgcolor-2.3 {[string match "*Cancel*background*color.*" $RESULT]} |
| 132 | if {[artifact_from_timeline $RESULT artid]} { |
| 133 | fossil artifact $artid |
| 134 | test amend-bgcolor-2.4 {[string match "*T -bgcolor $HASH*" $RESULT]} |
| 135 |
| --- test/amend.test | |
| +++ test/amend.test | |
| @@ -121,14 +121,11 @@ | |
| 121 | } |
| 122 | } |
| 123 | fossil amend $HASH -bgcolor {} |
| 124 | test amend-bgcolor-2.1 {[string match "*hash:*$HASH*" $RESULT]} |
| 125 | fossil tag list --raw $HASH |
| 126 | test amend-bgcolor-2.2 {[holds_strings $RESULT {!bgcolor= bgcolor}]} |
| 127 | fossil timeline -n 1 |
| 128 | test amend-bgcolor-2.3 {[string match "*Cancel*background*color.*" $RESULT]} |
| 129 | if {[artifact_from_timeline $RESULT artid]} { |
| 130 | fossil artifact $artid |
| 131 | test amend-bgcolor-2.4 {[string match "*T -bgcolor $HASH*" $RESULT]} |
| 132 |
+2
-4
| --- test/json.test | ||
| +++ test/json.test | ||
| @@ -792,14 +792,12 @@ | ||
| 792 | 792 | |
| 793 | 793 | |
| 794 | 794 | # FOSSIL-1103 FSL_JSON_E_UNKNOWN |
| 795 | 795 | # Unknown error |
| 796 | 796 | |
| 797 | -write_file bad.sql { | |
| 798 | -CREATE TABLE spam(a integer, b text); | |
| 799 | -} | |
| 800 | -exec $::fossilexe sqlite3 --no-repository bad.fossil <bad.sql | |
| 797 | +fossil_raw -input "CREATE TABLE spam(a integer, b text);\n" \ | |
| 798 | + sqlite3 --no-repository bad.fossil | |
| 801 | 799 | fossil_json HAI -R bad.fossil -expectError |
| 802 | 800 | test json-env-RC-1103-CLI-exit {$CODE != 0} |
| 803 | 801 | if { $JR ne "" } { |
| 804 | 802 | test_json_envelope json-env-RC-1103-env {fossil timestamp command procTimeUs \ |
| 805 | 803 | procTimeMs resultCode resultText} {payload} |
| 806 | 804 |
| --- test/json.test | |
| +++ test/json.test | |
| @@ -792,14 +792,12 @@ | |
| 792 | |
| 793 | |
| 794 | # FOSSIL-1103 FSL_JSON_E_UNKNOWN |
| 795 | # Unknown error |
| 796 | |
| 797 | write_file bad.sql { |
| 798 | CREATE TABLE spam(a integer, b text); |
| 799 | } |
| 800 | exec $::fossilexe sqlite3 --no-repository bad.fossil <bad.sql |
| 801 | fossil_json HAI -R bad.fossil -expectError |
| 802 | test json-env-RC-1103-CLI-exit {$CODE != 0} |
| 803 | if { $JR ne "" } { |
| 804 | test_json_envelope json-env-RC-1103-env {fossil timestamp command procTimeUs \ |
| 805 | procTimeMs resultCode resultText} {payload} |
| 806 |
| --- test/json.test | |
| +++ test/json.test | |
| @@ -792,14 +792,12 @@ | |
| 792 | |
| 793 | |
| 794 | # FOSSIL-1103 FSL_JSON_E_UNKNOWN |
| 795 | # Unknown error |
| 796 | |
| 797 | fossil_raw -input "CREATE TABLE spam(a integer, b text);\n" \ |
| 798 | sqlite3 --no-repository bad.fossil |
| 799 | fossil_json HAI -R bad.fossil -expectError |
| 800 | test json-env-RC-1103-CLI-exit {$CODE != 0} |
| 801 | if { $JR ne "" } { |
| 802 | test_json_envelope json-env-RC-1103-env {fossil timestamp command procTimeUs \ |
| 803 | procTimeMs resultCode resultText} {payload} |
| 804 |
+11
-9
| --- test/powerloss.test | ||
| +++ test/powerloss.test | ||
| @@ -46,22 +46,24 @@ | ||
| 46 | 46 | # Runs fossil with ARGS in directory DIR, with the NAME=VALUE settings of |
| 47 | 47 | # the list ENV added to its environment, and returns a list of its exit |
| 48 | 48 | # status and its output. A stopped command exits with status 77. |
| 49 | 49 | # |
| 50 | 50 | proc pl_exec {env dir args} { |
| 51 | - protOut [list fossil {*}$args] | |
| 52 | 51 | set saved [pwd] |
| 53 | 52 | cd $dir |
| 54 | - set rc [catch { | |
| 55 | - exec env {*}$env $::fossilexe {*}$args << "" 2>@1 | |
| 56 | - } result options] | |
| 53 | + set names {} | |
| 54 | + foreach setting $env { | |
| 55 | + regexp {^([^=]+)=(.*)$} $setting all name value | |
| 56 | + set ::env($name) $value | |
| 57 | + lappend names $name | |
| 58 | + } | |
| 59 | + fossil_raw {*}$args | |
| 60 | + foreach name $names { | |
| 61 | + unset ::env($name) | |
| 62 | + } | |
| 57 | 63 | cd $saved |
| 58 | - set status 0 | |
| 59 | - if {$rc} { | |
| 60 | - set status [lindex [dict get $options -errorcode] 2] | |
| 61 | - } | |
| 62 | - return [list $status [string trim $result]] | |
| 64 | + return [list $::CODE [string trim $::RESULT]] | |
| 63 | 65 | } |
| 64 | 66 | |
| 65 | 67 | # Runs fossil without the power loss library, for set-up and checks. |
| 66 | 68 | # |
| 67 | 69 | proc pl_fossil {dir args} { |
| 68 | 70 |
| --- test/powerloss.test | |
| +++ test/powerloss.test | |
| @@ -46,22 +46,24 @@ | |
| 46 | # Runs fossil with ARGS in directory DIR, with the NAME=VALUE settings of |
| 47 | # the list ENV added to its environment, and returns a list of its exit |
| 48 | # status and its output. A stopped command exits with status 77. |
| 49 | # |
| 50 | proc pl_exec {env dir args} { |
| 51 | protOut [list fossil {*}$args] |
| 52 | set saved [pwd] |
| 53 | cd $dir |
| 54 | set rc [catch { |
| 55 | exec env {*}$env $::fossilexe {*}$args << "" 2>@1 |
| 56 | } result options] |
| 57 | cd $saved |
| 58 | set status 0 |
| 59 | if {$rc} { |
| 60 | set status [lindex [dict get $options -errorcode] 2] |
| 61 | } |
| 62 | return [list $status [string trim $result]] |
| 63 | } |
| 64 | |
| 65 | # Runs fossil without the power loss library, for set-up and checks. |
| 66 | # |
| 67 | proc pl_fossil {dir args} { |
| 68 |
| --- test/powerloss.test | |
| +++ test/powerloss.test | |
| @@ -46,22 +46,24 @@ | |
| 46 | # Runs fossil with ARGS in directory DIR, with the NAME=VALUE settings of |
| 47 | # the list ENV added to its environment, and returns a list of its exit |
| 48 | # status and its output. A stopped command exits with status 77. |
| 49 | # |
| 50 | proc pl_exec {env dir args} { |
| 51 | set saved [pwd] |
| 52 | cd $dir |
| 53 | set names {} |
| 54 | foreach setting $env { |
| 55 | regexp {^([^=]+)=(.*)$} $setting all name value |
| 56 | set ::env($name) $value |
| 57 | lappend names $name |
| 58 | } |
| 59 | fossil_raw {*}$args |
| 60 | foreach name $names { |
| 61 | unset ::env($name) |
| 62 | } |
| 63 | cd $saved |
| 64 | return [list $::CODE [string trim $::RESULT]] |
| 65 | } |
| 66 | |
| 67 | # Runs fossil without the power loss library, for set-up and checks. |
| 68 | # |
| 69 | proc pl_fossil {dir args} { |
| 70 |
+4
-4
| --- test/roundtrip.test | ||
| +++ test/roundtrip.test | ||
| @@ -120,13 +120,12 @@ | ||
| 120 | 120 | # |
| 121 | 121 | proc roundtrip_checkin_files {checkin} { |
| 122 | 122 | set files [dict create] |
| 123 | 123 | fossil ls -r $checkin |
| 124 | 124 | foreach name [split [string trim $::RESULT] \n] { |
| 125 | - set fd [open "|[list $::fossilexe cat -r $checkin $name]" rb] | |
| 126 | - dict set files $name [read $fd] | |
| 127 | - close $fd | |
| 125 | + fossil_raw cat -r $checkin $name | |
| 126 | + dict set files $name $::RESULT | |
| 128 | 127 | } |
| 129 | 128 | return $files |
| 130 | 129 | } |
| 131 | 130 | |
| 132 | 131 | # Returns a dictionary from the name of each file in the current |
| @@ -191,11 +190,12 @@ | ||
| 191 | 190 | ############################################################################### |
| 192 | 191 | # |
| 193 | 192 | # "fossil export --git" into "fossil import --git": each check-in keeps |
| 194 | 193 | # its comment, its branch and its files with their content. |
| 195 | 194 | # |
| 196 | -exec $::fossilexe export --git > export.git | |
| 195 | +fossil_raw export --git | |
| 196 | +write_file export.git $RESULT | |
| 197 | 197 | fossil import --git imported.fossil export.git |
| 198 | 198 | set imported [roundtrip_checkins imported.fossil] |
| 199 | 199 | |
| 200 | 200 | test_eq roundtrip-git-checkins [lsort [dict keys $imported]] \ |
| 201 | 201 | [lsort [dict keys $original]] |
| 202 | 202 |
| --- test/roundtrip.test | |
| +++ test/roundtrip.test | |
| @@ -120,13 +120,12 @@ | |
| 120 | # |
| 121 | proc roundtrip_checkin_files {checkin} { |
| 122 | set files [dict create] |
| 123 | fossil ls -r $checkin |
| 124 | foreach name [split [string trim $::RESULT] \n] { |
| 125 | set fd [open "|[list $::fossilexe cat -r $checkin $name]" rb] |
| 126 | dict set files $name [read $fd] |
| 127 | close $fd |
| 128 | } |
| 129 | return $files |
| 130 | } |
| 131 | |
| 132 | # Returns a dictionary from the name of each file in the current |
| @@ -191,11 +190,12 @@ | |
| 191 | ############################################################################### |
| 192 | # |
| 193 | # "fossil export --git" into "fossil import --git": each check-in keeps |
| 194 | # its comment, its branch and its files with their content. |
| 195 | # |
| 196 | exec $::fossilexe export --git > export.git |
| 197 | fossil import --git imported.fossil export.git |
| 198 | set imported [roundtrip_checkins imported.fossil] |
| 199 | |
| 200 | test_eq roundtrip-git-checkins [lsort [dict keys $imported]] \ |
| 201 | [lsort [dict keys $original]] |
| 202 |
| --- test/roundtrip.test | |
| +++ test/roundtrip.test | |
| @@ -120,13 +120,12 @@ | |
| 120 | # |
| 121 | proc roundtrip_checkin_files {checkin} { |
| 122 | set files [dict create] |
| 123 | fossil ls -r $checkin |
| 124 | foreach name [split [string trim $::RESULT] \n] { |
| 125 | fossil_raw cat -r $checkin $name |
| 126 | dict set files $name $::RESULT |
| 127 | } |
| 128 | return $files |
| 129 | } |
| 130 | |
| 131 | # Returns a dictionary from the name of each file in the current |
| @@ -191,11 +190,12 @@ | |
| 190 | ############################################################################### |
| 191 | # |
| 192 | # "fossil export --git" into "fossil import --git": each check-in keeps |
| 193 | # its comment, its branch and its files with their content. |
| 194 | # |
| 195 | fossil_raw export --git |
| 196 | write_file export.git $RESULT |
| 197 | fossil import --git imported.fossil export.git |
| 198 | set imported [roundtrip_checkins imported.fossil] |
| 199 | |
| 200 | test_eq roundtrip-git-checkins [lsort [dict keys $imported]] \ |
| 201 | [lsort [dict keys $original]] |
| 202 |
+2
-14
| --- test/th1-taint.test | ||
| +++ test/th1-taint.test | ||
| @@ -19,24 +19,12 @@ | ||
| 19 | 19 | # |
| 20 | 20 | |
| 21 | 21 | set path [file dirname [info script]]; test_setup |
| 22 | 22 | |
| 23 | 23 | proc taint-test {testnum th1script expected} { |
| 24 | - global fossilexe | |
| 25 | - set rc [catch {exec $fossilexe test-th-eval $th1script} got] | |
| 26 | - if {$rc} { | |
| 27 | - test th1-taint-$testnum 0 | |
| 28 | - puts $got | |
| 29 | - return | |
| 30 | - } | |
| 31 | - if {$got ne $expected} { | |
| 32 | - test th1-taint-$testnum 0 | |
| 33 | - puts " Expected: $expected" | |
| 34 | - puts " Got: $got" | |
| 35 | - } else { | |
| 36 | - test th1-taint-$testnum 1 | |
| 37 | - } | |
| 24 | + fossil test-th-eval $th1script | |
| 25 | + test_eq th1-taint-$testnum $::RESULT $expected | |
| 38 | 26 | } |
| 39 | 27 | |
| 40 | 28 | taint-test 10 {string is tainted abcd} 0 |
| 41 | 29 | taint-test 20 {string is tainted [taint abcd]} 1 |
| 42 | 30 | taint-test 30 {string is tainted [untaint [taint abcd]]} 0 |
| 43 | 31 |
| --- test/th1-taint.test | |
| +++ test/th1-taint.test | |
| @@ -19,24 +19,12 @@ | |
| 19 | # |
| 20 | |
| 21 | set path [file dirname [info script]]; test_setup |
| 22 | |
| 23 | proc taint-test {testnum th1script expected} { |
| 24 | global fossilexe |
| 25 | set rc [catch {exec $fossilexe test-th-eval $th1script} got] |
| 26 | if {$rc} { |
| 27 | test th1-taint-$testnum 0 |
| 28 | puts $got |
| 29 | return |
| 30 | } |
| 31 | if {$got ne $expected} { |
| 32 | test th1-taint-$testnum 0 |
| 33 | puts " Expected: $expected" |
| 34 | puts " Got: $got" |
| 35 | } else { |
| 36 | test th1-taint-$testnum 1 |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | taint-test 10 {string is tainted abcd} 0 |
| 41 | taint-test 20 {string is tainted [taint abcd]} 1 |
| 42 | taint-test 30 {string is tainted [untaint [taint abcd]]} 0 |
| 43 |
| --- test/th1-taint.test | |
| +++ test/th1-taint.test | |
| @@ -19,24 +19,12 @@ | |
| 19 | # |
| 20 | |
| 21 | set path [file dirname [info script]]; test_setup |
| 22 | |
| 23 | proc taint-test {testnum th1script expected} { |
| 24 | fossil test-th-eval $th1script |
| 25 | test_eq th1-taint-$testnum $::RESULT $expected |
| 26 | } |
| 27 | |
| 28 | taint-test 10 {string is tainted abcd} 0 |
| 29 | taint-test 20 {string is tainted [taint abcd]} 1 |
| 30 | taint-test 30 {string is tainted [untaint [taint abcd]]} 0 |
| 31 |