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.
Commit
95080f47e265f34e17bea66f534176d543aacfec
Parent
50891558215f562…
2 files changed
+159
+7
-2
+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 | +# |
| --- 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 @@ | ||
| 113 | 113 | # test expressions. |
| 114 | 114 | # |
| 115 | 115 | proc fossil_maybe_answer {answer args} { |
| 116 | 116 | global fossilexe |
| 117 | 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 | + } | |
| 118 | 123 | foreach a $args { |
| 119 | 124 | lappend cmd $a |
| 120 | 125 | } |
| 121 | 126 | protOut $cmd |
| 122 | 127 | |
| @@ -129,12 +134,12 @@ | ||
| 129 | 134 | } else { |
| 130 | 135 | set rc [catch {eval exec $cmd} result] |
| 131 | 136 | } |
| 132 | 137 | global RESULT CODE |
| 133 | 138 | set CODE $rc |
| 134 | - if {$rc} { | |
| 135 | - protOut "ERROR: $result" 1 | |
| 139 | + if {($rc && !$expectError) || (!$rc && $expectError)} { | |
| 140 | + protOut "ERROR: $result" 1 | |
| 136 | 141 | } elseif {$::VERBOSE} { |
| 137 | 142 | protOut "RESULT: $result" |
| 138 | 143 | } |
| 139 | 144 | set RESULT $result |
| 140 | 145 | } |
| 141 | 146 |
| --- 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 |