Fossil SCM

Update 5 tests to use new test runner procedures especially fossil_raw

danshearer 2026-11-24 09:52 UTC test-suite-new
Commit 2ef9a4868e8e89f3f5662c3320df7f89fe5dc99c9481c4061688708da082f502
+1 -4
--- test/amend.test
+++ test/amend.test
@@ -121,14 +121,11 @@
121121
}
122122
}
123123
fossil amend $HASH -bgcolor {}
124124
test amend-bgcolor-2.1 {[string match "*hash:*$HASH*" $RESULT]}
125125
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}]}
130127
fossil timeline -n 1
131128
test amend-bgcolor-2.3 {[string match "*Cancel*background*color.*" $RESULT]}
132129
if {[artifact_from_timeline $RESULT artid]} {
133130
fossil artifact $artid
134131
test amend-bgcolor-2.4 {[string match "*T -bgcolor $HASH*" $RESULT]}
135132
--- 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 @@
792792
793793
794794
# FOSSIL-1103 FSL_JSON_E_UNKNOWN
795795
# Unknown error
796796
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
801799
fossil_json HAI -R bad.fossil -expectError
802800
test json-env-RC-1103-CLI-exit {$CODE != 0}
803801
if { $JR ne "" } {
804802
test_json_envelope json-env-RC-1103-env {fossil timestamp command procTimeUs \
805803
procTimeMs resultCode resultText} {payload}
806804
--- 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
--- test/powerloss.test
+++ test/powerloss.test
@@ -46,22 +46,24 @@
4646
# Runs fossil with ARGS in directory DIR, with the NAME=VALUE settings of
4747
# the list ENV added to its environment, and returns a list of its exit
4848
# status and its output. A stopped command exits with status 77.
4949
#
5050
proc pl_exec {env dir args} {
51
- protOut [list fossil {*}$args]
5251
set saved [pwd]
5352
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
+ }
5763
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]]
6365
}
6466
6567
# Runs fossil without the power loss library, for set-up and checks.
6668
#
6769
proc pl_fossil {dir args} {
6870
--- 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
--- test/roundtrip.test
+++ test/roundtrip.test
@@ -120,13 +120,12 @@
120120
#
121121
proc roundtrip_checkin_files {checkin} {
122122
set files [dict create]
123123
fossil ls -r $checkin
124124
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
128127
}
129128
return $files
130129
}
131130
132131
# Returns a dictionary from the name of each file in the current
@@ -191,11 +190,12 @@
191190
###############################################################################
192191
#
193192
# "fossil export --git" into "fossil import --git": each check-in keeps
194193
# its comment, its branch and its files with their content.
195194
#
196
-exec $::fossilexe export --git > export.git
195
+fossil_raw export --git
196
+write_file export.git $RESULT
197197
fossil import --git imported.fossil export.git
198198
set imported [roundtrip_checkins imported.fossil]
199199
200200
test_eq roundtrip-git-checkins [lsort [dict keys $imported]] \
201201
[lsort [dict keys $original]]
202202
--- 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
--- test/th1-taint.test
+++ test/th1-taint.test
@@ -19,24 +19,12 @@
1919
#
2020
2121
set path [file dirname [info script]]; test_setup
2222
2323
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
3826
}
3927
4028
taint-test 10 {string is tainted abcd} 0
4129
taint-test 20 {string is tainted [taint abcd]} 1
4230
taint-test 30 {string is tainted [untaint [taint abcd]]} 0
4331
--- 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

Keyboard Shortcuts

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