Fossil SCM

Handle missing 'json' Tcl package gracefully.

mistachkin 2020-06-12 21:07 jsonTestsPass
Commit e3297200e569702739c2b93c72eeb2793c3ad61440b4e428b609ba63bec32ed0
1 file changed +4 -1
+4 -1
--- test/json.test
+++ test/json.test
@@ -33,11 +33,14 @@
3333
# We need a JSON parser to effectively test the JSON produced by
3434
# fossil. It looks like the one from tcllib is exactly what we need.
3535
# On ActiveTcl, add it with teacup. On other platforms, YMMV.
3636
# teacup install json
3737
# teacup install json::write
38
-package require json
38
+if {[catch {package require json}] != 0} then {
39
+ puts "The \"json\" package is not available."
40
+ test_cleanup_then_return
41
+}
3942
4043
proc json2dict {txt} {
4144
set rc [catch {::json::json2dict $txt} result options]
4245
if {$rc != 0} {
4346
protOut "JSON ERROR: $result"
4447
--- test/json.test
+++ test/json.test
@@ -33,11 +33,14 @@
33 # We need a JSON parser to effectively test the JSON produced by
34 # fossil. It looks like the one from tcllib is exactly what we need.
35 # On ActiveTcl, add it with teacup. On other platforms, YMMV.
36 # teacup install json
37 # teacup install json::write
38 package require json
 
 
 
39
40 proc json2dict {txt} {
41 set rc [catch {::json::json2dict $txt} result options]
42 if {$rc != 0} {
43 protOut "JSON ERROR: $result"
44
--- test/json.test
+++ test/json.test
@@ -33,11 +33,14 @@
33 # We need a JSON parser to effectively test the JSON produced by
34 # fossil. It looks like the one from tcllib is exactly what we need.
35 # On ActiveTcl, add it with teacup. On other platforms, YMMV.
36 # teacup install json
37 # teacup install json::write
38 if {[catch {package require json}] != 0} then {
39 puts "The \"json\" package is not available."
40 test_cleanup_then_return
41 }
42
43 proc json2dict {txt} {
44 set rc [catch {::json::json2dict $txt} result options]
45 if {$rc != 0} {
46 protOut "JSON ERROR: $result"
47

Keyboard Shortcuts

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