Fossil SCM
Skip running the Tcl integration tests if Fossil was not compiled with Tcl integration support.
Commit
6c47a16e5def3b50b0d326718fa44be39acc3fc4
Parent
c58b815f2b24f0a…
2 files changed
+19
-3
+8
+19
-3
| --- src/th_main.c | ||
| +++ src/th_main.c | ||
| @@ -87,14 +87,14 @@ | ||
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | /* |
| 90 | 90 | ** Return a name for a TH1 return code. |
| 91 | 91 | */ |
| 92 | -const char *Th_ReturnCodeName(int rc){ | |
| 92 | +const char *Th_ReturnCodeName(int rc, int nullIfOk){ | |
| 93 | 93 | static char zRc[32]; |
| 94 | 94 | switch( rc ){ |
| 95 | - case TH_OK: return "TH_OK"; | |
| 95 | + case TH_OK: return nullIfOk ? 0 : "TH_OK"; | |
| 96 | 96 | case TH_ERROR: return "TH_ERROR"; |
| 97 | 97 | case TH_BREAK: return "TH_BREAK"; |
| 98 | 98 | case TH_RETURN: return "TH_RETURN"; |
| 99 | 99 | case TH_CONTINUE: return "TH_CONTINUE"; |
| 100 | 100 | default: { |
| @@ -742,11 +742,11 @@ | ||
| 742 | 742 | sendError(zResult, nResult, 0); |
| 743 | 743 | } |
| 744 | 744 | } |
| 745 | 745 | if( g.thTrace ){ |
| 746 | 746 | Th_Trace("th1-setup {%h} => %h<br />\n", g.th1Setup, |
| 747 | - Th_ReturnCodeName(rc)); | |
| 747 | + Th_ReturnCodeName(rc, 0)); | |
| 748 | 748 | } |
| 749 | 749 | } |
| 750 | 750 | } |
| 751 | 751 | |
| 752 | 752 | /* |
| @@ -932,5 +932,21 @@ | ||
| 932 | 932 | db_open_config(0); /* Needed for global "tcl" setting. */ |
| 933 | 933 | blob_zero(&in); |
| 934 | 934 | blob_read_from_file(&in, g.argv[2]); |
| 935 | 935 | Th_Render(blob_str(&in)); |
| 936 | 936 | } |
| 937 | + | |
| 938 | +/* | |
| 939 | +** COMMAND: test-th-eval | |
| 940 | +*/ | |
| 941 | +void test_th_eval(void){ | |
| 942 | + int rc; | |
| 943 | + const char *zRc; | |
| 944 | + if( g.argc!=3 ){ | |
| 945 | + usage("script"); | |
| 946 | + } | |
| 947 | + Th_FossilInit(0, 0); | |
| 948 | + rc = Th_Eval(g.interp, 0, g.argv[2], -1); | |
| 949 | + zRc = Th_ReturnCodeName(rc, 1); | |
| 950 | + fossil_print("%s%s%s\n", zRc, zRc ? ": " : "", | |
| 951 | + Th_GetResult(g.interp, 0)); | |
| 952 | +} | |
| 937 | 953 |
| --- src/th_main.c | |
| +++ src/th_main.c | |
| @@ -87,14 +87,14 @@ | |
| 87 | } |
| 88 | |
| 89 | /* |
| 90 | ** Return a name for a TH1 return code. |
| 91 | */ |
| 92 | const char *Th_ReturnCodeName(int rc){ |
| 93 | static char zRc[32]; |
| 94 | switch( rc ){ |
| 95 | case TH_OK: return "TH_OK"; |
| 96 | case TH_ERROR: return "TH_ERROR"; |
| 97 | case TH_BREAK: return "TH_BREAK"; |
| 98 | case TH_RETURN: return "TH_RETURN"; |
| 99 | case TH_CONTINUE: return "TH_CONTINUE"; |
| 100 | default: { |
| @@ -742,11 +742,11 @@ | |
| 742 | sendError(zResult, nResult, 0); |
| 743 | } |
| 744 | } |
| 745 | if( g.thTrace ){ |
| 746 | Th_Trace("th1-setup {%h} => %h<br />\n", g.th1Setup, |
| 747 | Th_ReturnCodeName(rc)); |
| 748 | } |
| 749 | } |
| 750 | } |
| 751 | |
| 752 | /* |
| @@ -932,5 +932,21 @@ | |
| 932 | db_open_config(0); /* Needed for global "tcl" setting. */ |
| 933 | blob_zero(&in); |
| 934 | blob_read_from_file(&in, g.argv[2]); |
| 935 | Th_Render(blob_str(&in)); |
| 936 | } |
| 937 |
| --- src/th_main.c | |
| +++ src/th_main.c | |
| @@ -87,14 +87,14 @@ | |
| 87 | } |
| 88 | |
| 89 | /* |
| 90 | ** Return a name for a TH1 return code. |
| 91 | */ |
| 92 | const char *Th_ReturnCodeName(int rc, int nullIfOk){ |
| 93 | static char zRc[32]; |
| 94 | switch( rc ){ |
| 95 | case TH_OK: return nullIfOk ? 0 : "TH_OK"; |
| 96 | case TH_ERROR: return "TH_ERROR"; |
| 97 | case TH_BREAK: return "TH_BREAK"; |
| 98 | case TH_RETURN: return "TH_RETURN"; |
| 99 | case TH_CONTINUE: return "TH_CONTINUE"; |
| 100 | default: { |
| @@ -742,11 +742,11 @@ | |
| 742 | sendError(zResult, nResult, 0); |
| 743 | } |
| 744 | } |
| 745 | if( g.thTrace ){ |
| 746 | Th_Trace("th1-setup {%h} => %h<br />\n", g.th1Setup, |
| 747 | Th_ReturnCodeName(rc, 0)); |
| 748 | } |
| 749 | } |
| 750 | } |
| 751 | |
| 752 | /* |
| @@ -932,5 +932,21 @@ | |
| 932 | db_open_config(0); /* Needed for global "tcl" setting. */ |
| 933 | blob_zero(&in); |
| 934 | blob_read_from_file(&in, g.argv[2]); |
| 935 | Th_Render(blob_str(&in)); |
| 936 | } |
| 937 | |
| 938 | /* |
| 939 | ** COMMAND: test-th-eval |
| 940 | */ |
| 941 | void test_th_eval(void){ |
| 942 | int rc; |
| 943 | const char *zRc; |
| 944 | if( g.argc!=3 ){ |
| 945 | usage("script"); |
| 946 | } |
| 947 | Th_FossilInit(0, 0); |
| 948 | rc = Th_Eval(g.interp, 0, g.argv[2], -1); |
| 949 | zRc = Th_ReturnCodeName(rc, 1); |
| 950 | fossil_print("%s%s%s\n", zRc, zRc ? ": " : "", |
| 951 | Th_GetResult(g.interp, 0)); |
| 952 | } |
| 953 |
+8
| --- test/th1-tcl.test | ||
| +++ test/th1-tcl.test | ||
| @@ -17,10 +17,18 @@ | ||
| 17 | 17 | # |
| 18 | 18 | # TH1/Tcl integration |
| 19 | 19 | # |
| 20 | 20 | |
| 21 | 21 | set dir [file dirname [info script]] |
| 22 | + | |
| 23 | +############################################################################### | |
| 24 | + | |
| 25 | +fossil test-th-eval "hasfeature tcl" | |
| 26 | + | |
| 27 | +if {$::RESULT ne "1"} then { | |
| 28 | + puts "Fossil was not compiled with Tcl support."; return | |
| 29 | +} | |
| 22 | 30 | |
| 23 | 31 | ############################################################################### |
| 24 | 32 | |
| 25 | 33 | set env(TH1_ENABLE_TCL) 1; # Tcl integration must be enabled for this test. |
| 26 | 34 | |
| 27 | 35 |
| --- test/th1-tcl.test | |
| +++ test/th1-tcl.test | |
| @@ -17,10 +17,18 @@ | |
| 17 | # |
| 18 | # TH1/Tcl integration |
| 19 | # |
| 20 | |
| 21 | set dir [file dirname [info script]] |
| 22 | |
| 23 | ############################################################################### |
| 24 | |
| 25 | set env(TH1_ENABLE_TCL) 1; # Tcl integration must be enabled for this test. |
| 26 | |
| 27 |
| --- test/th1-tcl.test | |
| +++ test/th1-tcl.test | |
| @@ -17,10 +17,18 @@ | |
| 17 | # |
| 18 | # TH1/Tcl integration |
| 19 | # |
| 20 | |
| 21 | set dir [file dirname [info script]] |
| 22 | |
| 23 | ############################################################################### |
| 24 | |
| 25 | fossil test-th-eval "hasfeature tcl" |
| 26 | |
| 27 | if {$::RESULT ne "1"} then { |
| 28 | puts "Fossil was not compiled with Tcl support."; return |
| 29 | } |
| 30 | |
| 31 | ############################################################################### |
| 32 | |
| 33 | set env(TH1_ENABLE_TCL) 1; # Tcl integration must be enabled for this test. |
| 34 | |
| 35 |