Fossil SCM

Place a cornerstone for scaffolding of the test cases for the fossil json command and related REST API. This begins with an extension to fossil_maybe_answer in tester.tcl that adds a -expectError option to flag invocations of fossil that are expected to exit with error status and not log it when -quiet is in effect. The new file json.test has the first few test cases for fossil json, all of which are currently passing.

Ross 2016-01-26 01:46 rberteig-json-test
Commit 95080f47e265f34e17bea66f534176d543aacfec
2 files changed +159 +7 -2
--- a/test/json.test
+++ b/test/json.test
@@ -0,0 +1,159 @@
1
+#
2
+env-RC-1102env#writ1_file bad.sql {
3
+##}
4
+##1102#
5
+# Co#. What about Win?timeline/checkin $U1Cookie1 {$CODE =11http-timeline#
6
+# Cotimeline/checkin $U1Cookie knownBughttp-timeline2
7
+#
8
+# Co
9
+env-RC-1102env#write_file bad.sql {
10
+##}
11
+##1102#
12
+# Co#. What about Win?timeline/checkin $U1Cookie1 {$CODE =11http-timeline#
13
+# Cotimeline/checkin $U1Cookie knownBughttp-timeline2
14
+#
15
+# CoC}
16
+$::RESULT; ; repo_initrepo_initsqlite3 bad.fossil <bad.sql
17
+#. What about Win?help -a
18
+if {[stri (fossil help -a)
19
+ v-RC-1102env#write_file bad.e_file bad.sql {
20
+##}
21
+##1102#
22
+# Co#. What about Win?timeline/checkin $U1Cookie1 {$CODE =11http-timeline#
23
+# Cotimeline/checkin $U1Cookie knownBughttp-timeline2
24
+#
25
+# Co
26
+env-RC-1102env#write_file bad.sql {
27
+##}
28
+##1102#
29
+# Co#. What about Win?timeline/checkin $U1Cookie1 {$COE # No point checking any other flags, setup implies all, and all are
30
+# moot from CLI.test TODO-json-post-authentication false knownBug
31
+#TOttp-timeline#
32
+# Cotimeline/checkin $U1Cookie knownBughttp-timeline2
33
+#
34
+# Co
35
+env-RC-1102env#write_file bad.sql {
36
+##}
37
+##1102#
38
+# Co#. What about Win?timeline/checkin $U1Cookie1 {$CODE =11http-timeline#
39
+# Cotimeline/checkin $U1Cookie knownBughttp-timeline2
40
+#
41
+# CoC}
42
+$::RESULT; ; repo_initrepo_initsqlite3 bad.fossil <bad.sql
43
+#. What about Win?help -a
44
+if {[stri (fossil help -a)
45
+ v-RC-1102env#write_file bad.e_file bad.sql {
46
+##}
47
+##1102#
48
+# Co#. What about Win?timeline/checkin $U1Cookie1 {$CODE =11http-timeline#
49
+# Cotimeline/checkin $U1Cookie knownBughttp-timeline2
50
+#
51
+# Co
52
+env-RC-1102env#write_file bad.sql {
53
+##}
54
+##1102#
55
+# Co#. What ababout Win?timeline/ch#. What about Win?timeline/checkin sil <bad.sql
56
+#. What about Win?help g any other flags, setup implies all, and all are
57
+# moot from CLI.test TODO-json-post-authentication false knownBug
58
+#TODO: implement support for POST with JSONfrom file
59
+#fossil_htcap-http-env
60
+#test json-cap-http {!test TODO-json-diff false knownBug#
61
+102env#wriabout Win?timeline/chbout Win?timeline/checkin $U1Cookie1 {$CODE =11http-timeline#
62
+# Cotimeline/chcheckin $U1Cookie knownBnv-RC-1102env#write_file badad.sql {
63
+##}
64
+##1102#
65
+# Co#. What about Win?timeline/checkin $U1U1Cookie1 {$CODE =11http-t sil <bad.sql
66
+#. What about body]
67
+ }
68
+ nownBughttp-timeline2
69
+#
70
+# CoC}n-diff false knownBug#
71
+fetch#
72
+env-RC-1102env#write_file bad.sql {
73
+##}
74
+##1102#
75
+# Co#. What about Win?timeline/checkin $U1Cookie1 {$CODE =11http-timeline#
76
+global JRenv#write_file bad global JR
77
+ set i 1
78
+ -1102env#write_file bad. heckin $U1Cookie incr i
79
+ }
80
+ line#
81
+# Cotimeline/checki heckin $U1Cookie1 {$C!2#
82
+# Co#. What ab$f]}
83
+ incr i
84
+ false knownBug
85
+#TOttp-timeline#
86
+# Cotimeline/checkin $U1Cookie knownBughtt -ticketsl {
87
+##}
88
+#bad.sql {
89
+##}
90
+##1102#
91
+# Co#. in $U1Cookie1 {$CODE =11http-timeline#
92
+# Cotimeline/checkin $U1Cookie knownBughttp-timeline2
93
+#
94
+# CoC}
95
+$::RESULT; ; repo_initrepo_initsqlite3 bad.fossil <bad.sql
96
+#. What about Win?help -a
97
+if {[stri (fossil global JR
98
+ set i 1
99
+ -1102env#write_file bad. heckin $U1CookiePe1 {$COE # No point chepayload $f]}
100
+ incr i
101
+ }
102
+ line#
103
+# Cotimeline/checki heckin $U1Cookiehttp-timeli incr i
104
+ }
105
+}. What about Win?timeline/checkin $U1Cookie1 {$COE # No point checking any other flags, setup implies all, and all are
106
+# moot from CLI.test TODO-json-post-authentication false knownBug
107
+#TODO: implement support for POST _htcap-http-env
108
+#test json-cap-http {!test TODO-json-diff false knownBug#
109
+102env#write_file bad.sql {
110
+##}
111
+##1102#
112
+# Co#. What about Win?timeline/checkin $U1Cookie1 {$CODE =11http-timeline#
113
+# Cotimeline/checkin $U1Cookie knownBughttp-timeline2
114
+#
115
+# Co
116
+env-R C-1102env#write_file bad .sql {
117
+##}
118
+##1102#
119
+# Co#. What about Win?timeline/checkin $U1Cookie1 {$CODE =11http-timeline#
120
+# Cotimeline/checkin $U1Cookie kno checking a#
121
+env-RC-1102env#write_file bad.sql {
122
+##}
123
+##1102#
124
+# Co#. What about Win?timeline/checkin $U1Cookie1 {$CODE =11http-timeline#
125
+# Cotimeline/checkin $U1C#write_file bad.sql {
126
+##}
127
+##1102#
128
+# Co#. What about Win?timeline/checkin $U1Cookie1 {$CODE =11http-timeline#
129
+# Cotimeline/checkin $U1Cookie knownBughttp-timeline2
130
+#
131
+# Co
132
+env-RC-1102env#write_file bad.sql {
133
+##}
134
+##1102#
135
+# Co#. What about Win?timeline/checkin $U1Cookie1 {$CODE =11http-timeline#
136
+# Cotimeline/checkin $U1Cookie knownBughttp-timeline2
137
+#
138
+# CoC}
139
+$::RESULT; ; repo_initrepo_i meline/checkin $U1Cookie1 {$CODE =11http-timeline#
140
+# Cotimeline/checkin $U1Cookie knownBughttp-timeline2
141
+#
142
+# Co
143
+env-RC-1102env#write_file bad.sql {
144
+##}
145
+##1102#
146
+# Co#. What about Win?timeline/checkin $U1Cookie1 {$CODE =11http-timeline#
147
+# Cotimeline/checkin $U1Cookie knownBughttp-timeline2
148
+#
149
+# CoC}
150
+$::RESULT; ; repo_initrepo_initsqlite3 bad.fossil <bad.sql
151
+#. What about Win?help -a
152
+if {[stri (fossil help -a)
153
+ v-RC-1102env#write_file bad.e_file bad.sql {
154
+##}
155
+##1102#
156
+# Co#. What about Win?timeline/checkin $U1Cookie1 {$CODE =11http-timeline#
157
+# Cotimeline/checkin $U1Cookie knownBughttp-ti#
158
+env-RC-1102enap-env
159
+#
--- a/test/json.test
+++ b/test/json.test
@@ -0,0 +1,159 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
--- a/test/json.test
+++ b/test/json.test
@@ -0,0 +1,159 @@
1 #
2 env-RC-1102env#writ1_file bad.sql {
3 ##}
4 ##1102#
5 # Co#. What about Win?timeline/checkin $U1Cookie1 {$CODE =11http-timeline#
6 # Cotimeline/checkin $U1Cookie knownBughttp-timeline2
7 #
8 # Co
9 env-RC-1102env#write_file bad.sql {
10 ##}
11 ##1102#
12 # Co#. What about Win?timeline/checkin $U1Cookie1 {$CODE =11http-timeline#
13 # Cotimeline/checkin $U1Cookie knownBughttp-timeline2
14 #
15 # CoC}
16 $::RESULT; ; repo_initrepo_initsqlite3 bad.fossil <bad.sql
17 #. What about Win?help -a
18 if {[stri (fossil help -a)
19 v-RC-1102env#write_file bad.e_file bad.sql {
20 ##}
21 ##1102#
22 # Co#. What about Win?timeline/checkin $U1Cookie1 {$CODE =11http-timeline#
23 # Cotimeline/checkin $U1Cookie knownBughttp-timeline2
24 #
25 # Co
26 env-RC-1102env#write_file bad.sql {
27 ##}
28 ##1102#
29 # Co#. What about Win?timeline/checkin $U1Cookie1 {$COE # No point checking any other flags, setup implies all, and all are
30 # moot from CLI.test TODO-json-post-authentication false knownBug
31 #TOttp-timeline#
32 # Cotimeline/checkin $U1Cookie knownBughttp-timeline2
33 #
34 # Co
35 env-RC-1102env#write_file bad.sql {
36 ##}
37 ##1102#
38 # Co#. What about Win?timeline/checkin $U1Cookie1 {$CODE =11http-timeline#
39 # Cotimeline/checkin $U1Cookie knownBughttp-timeline2
40 #
41 # CoC}
42 $::RESULT; ; repo_initrepo_initsqlite3 bad.fossil <bad.sql
43 #. What about Win?help -a
44 if {[stri (fossil help -a)
45 v-RC-1102env#write_file bad.e_file bad.sql {
46 ##}
47 ##1102#
48 # Co#. What about Win?timeline/checkin $U1Cookie1 {$CODE =11http-timeline#
49 # Cotimeline/checkin $U1Cookie knownBughttp-timeline2
50 #
51 # Co
52 env-RC-1102env#write_file bad.sql {
53 ##}
54 ##1102#
55 # Co#. What ababout Win?timeline/ch#. What about Win?timeline/checkin sil <bad.sql
56 #. What about Win?help g any other flags, setup implies all, and all are
57 # moot from CLI.test TODO-json-post-authentication false knownBug
58 #TODO: implement support for POST with JSONfrom file
59 #fossil_htcap-http-env
60 #test json-cap-http {!test TODO-json-diff false knownBug#
61 102env#wriabout Win?timeline/chbout Win?timeline/checkin $U1Cookie1 {$CODE =11http-timeline#
62 # Cotimeline/chcheckin $U1Cookie knownBnv-RC-1102env#write_file badad.sql {
63 ##}
64 ##1102#
65 # Co#. What about Win?timeline/checkin $U1U1Cookie1 {$CODE =11http-t sil <bad.sql
66 #. What about body]
67 }
68 nownBughttp-timeline2
69 #
70 # CoC}n-diff false knownBug#
71 fetch#
72 env-RC-1102env#write_file bad.sql {
73 ##}
74 ##1102#
75 # Co#. What about Win?timeline/checkin $U1Cookie1 {$CODE =11http-timeline#
76 global JRenv#write_file bad global JR
77 set i 1
78 -1102env#write_file bad. heckin $U1Cookie incr i
79 }
80 line#
81 # Cotimeline/checki heckin $U1Cookie1 {$C!2#
82 # Co#. What ab$f]}
83 incr i
84 false knownBug
85 #TOttp-timeline#
86 # Cotimeline/checkin $U1Cookie knownBughtt -ticketsl {
87 ##}
88 #bad.sql {
89 ##}
90 ##1102#
91 # Co#. in $U1Cookie1 {$CODE =11http-timeline#
92 # Cotimeline/checkin $U1Cookie knownBughttp-timeline2
93 #
94 # CoC}
95 $::RESULT; ; repo_initrepo_initsqlite3 bad.fossil <bad.sql
96 #. What about Win?help -a
97 if {[stri (fossil global JR
98 set i 1
99 -1102env#write_file bad. heckin $U1CookiePe1 {$COE # No point chepayload $f]}
100 incr i
101 }
102 line#
103 # Cotimeline/checki heckin $U1Cookiehttp-timeli incr i
104 }
105 }. What about Win?timeline/checkin $U1Cookie1 {$COE # No point checking any other flags, setup implies all, and all are
106 # moot from CLI.test TODO-json-post-authentication false knownBug
107 #TODO: implement support for POST _htcap-http-env
108 #test json-cap-http {!test TODO-json-diff false knownBug#
109 102env#write_file bad.sql {
110 ##}
111 ##1102#
112 # Co#. What about Win?timeline/checkin $U1Cookie1 {$CODE =11http-timeline#
113 # Cotimeline/checkin $U1Cookie knownBughttp-timeline2
114 #
115 # Co
116 env-R C-1102env#write_file bad .sql {
117 ##}
118 ##1102#
119 # Co#. What about Win?timeline/checkin $U1Cookie1 {$CODE =11http-timeline#
120 # Cotimeline/checkin $U1Cookie kno checking a#
121 env-RC-1102env#write_file bad.sql {
122 ##}
123 ##1102#
124 # Co#. What about Win?timeline/checkin $U1Cookie1 {$CODE =11http-timeline#
125 # Cotimeline/checkin $U1C#write_file bad.sql {
126 ##}
127 ##1102#
128 # Co#. What about Win?timeline/checkin $U1Cookie1 {$CODE =11http-timeline#
129 # Cotimeline/checkin $U1Cookie knownBughttp-timeline2
130 #
131 # Co
132 env-RC-1102env#write_file bad.sql {
133 ##}
134 ##1102#
135 # Co#. What about Win?timeline/checkin $U1Cookie1 {$CODE =11http-timeline#
136 # Cotimeline/checkin $U1Cookie knownBughttp-timeline2
137 #
138 # CoC}
139 $::RESULT; ; repo_initrepo_i meline/checkin $U1Cookie1 {$CODE =11http-timeline#
140 # Cotimeline/checkin $U1Cookie knownBughttp-timeline2
141 #
142 # Co
143 env-RC-1102env#write_file bad.sql {
144 ##}
145 ##1102#
146 # Co#. What about Win?timeline/checkin $U1Cookie1 {$CODE =11http-timeline#
147 # Cotimeline/checkin $U1Cookie knownBughttp-timeline2
148 #
149 # CoC}
150 $::RESULT; ; repo_initrepo_initsqlite3 bad.fossil <bad.sql
151 #. What about Win?help -a
152 if {[stri (fossil help -a)
153 v-RC-1102env#write_file bad.e_file bad.sql {
154 ##}
155 ##1102#
156 # Co#. What about Win?timeline/checkin $U1Cookie1 {$CODE =11http-timeline#
157 # Cotimeline/checkin $U1Cookie knownBughttp-ti#
158 env-RC-1102enap-env
159 #
+7 -2
--- test/tester.tcl
+++ test/tester.tcl
@@ -113,10 +113,15 @@
113113
# test expressions.
114114
#
115115
proc fossil_maybe_answer {answer args} {
116116
global fossilexe
117117
set cmd $fossilexe
118
+ set expectError 0
119
+ if {[lindex $args end] eq "-expectError"} {
120
+ set expectError 1
121
+ set args [lrange $args 0 end-1]
122
+ }
118123
foreach a $args {
119124
lappend cmd $a
120125
}
121126
protOut $cmd
122127
@@ -129,12 +134,12 @@
129134
} else {
130135
set rc [catch {eval exec $cmd} result]
131136
}
132137
global RESULT CODE
133138
set CODE $rc
134
- if {$rc} {
135
- protOut "ERROR: $result" 1
139
+ if {($rc && !$expectError) || (!$rc && $expectError)} {
140
+ protOut "ERROR: $result" 1
136141
} elseif {$::VERBOSE} {
137142
protOut "RESULT: $result"
138143
}
139144
set RESULT $result
140145
}
141146
--- test/tester.tcl
+++ test/tester.tcl
@@ -113,10 +113,15 @@
113 # test expressions.
114 #
115 proc fossil_maybe_answer {answer args} {
116 global fossilexe
117 set cmd $fossilexe
 
 
 
 
 
118 foreach a $args {
119 lappend cmd $a
120 }
121 protOut $cmd
122
@@ -129,12 +134,12 @@
129 } else {
130 set rc [catch {eval exec $cmd} result]
131 }
132 global RESULT CODE
133 set CODE $rc
134 if {$rc} {
135 protOut "ERROR: $result" 1
136 } elseif {$::VERBOSE} {
137 protOut "RESULT: $result"
138 }
139 set RESULT $result
140 }
141
--- test/tester.tcl
+++ test/tester.tcl
@@ -113,10 +113,15 @@
113 # test expressions.
114 #
115 proc fossil_maybe_answer {answer args} {
116 global fossilexe
117 set cmd $fossilexe
118 set expectError 0
119 if {[lindex $args end] eq "-expectError"} {
120 set expectError 1
121 set args [lrange $args 0 end-1]
122 }
123 foreach a $args {
124 lappend cmd $a
125 }
126 protOut $cmd
127
@@ -129,12 +134,12 @@
134 } else {
135 set rc [catch {eval exec $cmd} result]
136 }
137 global RESULT CODE
138 set CODE $rc
139 if {($rc && !$expectError) || (!$rc && $expectError)} {
140 protOut "ERROR: $result" 1
141 } elseif {$::VERBOSE} {
142 protOut "RESULT: $result"
143 }
144 set RESULT $result
145 }
146

Keyboard Shortcuts

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