Fossil SCM

Corrections to the new 'styleHeader' and 'styleFooter' TH1 commands. Modify TH1 integration code to keep track of when it opens databases. Modify 'test-th-hook' command to permit TH1 tracing. Corrections to new TH1 command test results.

mistachkin 2014-06-15 00:38 trunk
Commit 142200b90adb5cdc0c0a51f56887198458e98df8
+1
--- src/main.c
+++ src/main.c
@@ -155,10 +155,11 @@
155155
int cgiOutput; /* Write error and status messages to CGI */
156156
int xferPanic; /* Write error messages in XFER protocol */
157157
int fullHttpReply; /* True for full HTTP reply. False for CGI reply */
158158
Th_Interp *interp; /* The TH1 interpreter */
159159
char *th1Setup; /* The TH1 post-creation setup script, if any */
160
+ int th1Flags; /* The TH1 integration state flags */
160161
FILE *httpIn; /* Accept HTTP input from here */
161162
FILE *httpOut; /* Send HTTP output here */
162163
int xlinkClusterOnly; /* Set when cloning. Only process clusters */
163164
int fTimeFormat; /* 1 for UTC. 2 for localtime. 0 not yet selected */
164165
int *aCommitFile; /* Array of files to be committed */
165166
--- src/main.c
+++ src/main.c
@@ -155,10 +155,11 @@
155 int cgiOutput; /* Write error and status messages to CGI */
156 int xferPanic; /* Write error messages in XFER protocol */
157 int fullHttpReply; /* True for full HTTP reply. False for CGI reply */
158 Th_Interp *interp; /* The TH1 interpreter */
159 char *th1Setup; /* The TH1 post-creation setup script, if any */
 
160 FILE *httpIn; /* Accept HTTP input from here */
161 FILE *httpOut; /* Send HTTP output here */
162 int xlinkClusterOnly; /* Set when cloning. Only process clusters */
163 int fTimeFormat; /* 1 for UTC. 2 for localtime. 0 not yet selected */
164 int *aCommitFile; /* Array of files to be committed */
165
--- src/main.c
+++ src/main.c
@@ -155,10 +155,11 @@
155 int cgiOutput; /* Write error and status messages to CGI */
156 int xferPanic; /* Write error messages in XFER protocol */
157 int fullHttpReply; /* True for full HTTP reply. False for CGI reply */
158 Th_Interp *interp; /* The TH1 interpreter */
159 char *th1Setup; /* The TH1 post-creation setup script, if any */
160 int th1Flags; /* The TH1 integration state flags */
161 FILE *httpIn; /* Accept HTTP input from here */
162 FILE *httpOut; /* Send HTTP output here */
163 int xlinkClusterOnly; /* Set when cloning. Only process clusters */
164 int fTimeFormat; /* 1 for UTC. 2 for localtime. 0 not yet selected */
165 int *aCommitFile; /* Array of files to be committed */
166
+48 -8
--- src/th_main.c
+++ src/th_main.c
@@ -30,14 +30,23 @@
3030
#define TH_INIT_NONE ((u32)0x00000000) /* No flags. */
3131
#define TH_INIT_NEED_CONFIG ((u32)0x00000001) /* Open configuration first? */
3232
#define TH_INIT_FORCE_TCL ((u32)0x00000002) /* Force Tcl to be enabled? */
3333
#define TH_INIT_FORCE_RESET ((u32)0x00000004) /* Force TH1 commands re-added? */
3434
#define TH_INIT_FORCE_SETUP ((u32)0x00000008) /* Force eval of setup script? */
35
+#define TH_INIT_MASK ((u32)0x0000000F) /* All possible init flags. */
3536
#define TH_INIT_DEFAULT (TH_INIT_NONE) /* Default flags. */
3637
#define TH_INIT_HOOK (TH_INIT_NEED_CONFIG | TH_INIT_FORCE_SETUP)
3738
#endif
3839
40
+/*
41
+** Flags set by functions in this file to keep track of integration state
42
+** information. These flags should not be used outside of this file.
43
+*/
44
+#define TH_STATE_CONFIG ((u32)0x00000010) /* We opened the config. */
45
+#define TH_STATE_REPOSITORY ((u32)0x00000020) /* We opened the repository. */
46
+#define TH_STATE_MASK ((u32)0x00000030) /* All possible state flags. */
47
+
3948
#ifdef FOSSIL_ENABLE_TH1_HOOKS
4049
/*
4150
** These are the "well-known" TH1 error messages that occur when no hook is
4251
** registered to be called prior to executing a command or processing a web
4352
** page, respectively. If one of these errors is seen, it will not be sent
@@ -45,10 +54,17 @@
4554
*/
4655
#define NO_COMMAND_HOOK_ERROR "no such command: command_hook"
4756
#define NO_WEBPAGE_HOOK_ERROR "no such command: webpage_hook"
4857
#endif
4958
59
+/*
60
+** These macros are used within this file to detect if the repository and
61
+** configuration ("user") database are currently open.
62
+*/
63
+#define Th_IsRepositoryOpen() (g.repositoryOpen)
64
+#define Th_IsConfigOpen() (g.zConfigDbName!=0)
65
+
5066
/*
5167
** Global variable counting the number of outstanding calls to malloc()
5268
** made by the th1 implementation. This is used to catch memory leaks
5369
** in the interpreter. Obviously, it also means th1 is not threadsafe.
5470
*/
@@ -721,16 +737,16 @@
721737
int *argl
722738
){
723739
if( argc!=2 ){
724740
return Th_WrongNumArgs(interp, "styleHeader TITLE");
725741
}
726
- if( g.zConfigDbName ){
742
+ if( Th_IsRepositoryOpen() ){
727743
style_header("%s", argv[1]);
728744
Th_SetResult(interp, 0, 0);
729745
return TH_OK;
730746
}else{
731
- Th_SetResult(interp, "configuration unavailable", -1);
747
+ Th_SetResult(interp, "repository unavailable", -1);
732748
return TH_ERROR;
733749
}
734750
}
735751
736752
/*
@@ -746,16 +762,16 @@
746762
int *argl
747763
){
748764
if( argc!=1 ){
749765
return Th_WrongNumArgs(interp, "styleFooter");
750766
}
751
- if( g.zConfigDbName ){
767
+ if( Th_IsRepositoryOpen() ){
752768
style_footer();
753769
Th_SetResult(interp, 0, 0);
754770
return TH_OK;
755771
}else{
756
- Th_SetResult(interp, "configuration unavailable", -1);
772
+ Th_SetResult(interp, "repository unavailable", -1);
757773
return TH_ERROR;
758774
}
759775
}
760776
761777
#ifdef _WIN32
@@ -1162,26 +1178,42 @@
11621178
** attempts to try to find the repository and open it.
11631179
*/
11641180
void Th_OpenConfig(
11651181
int openRepository
11661182
){
1167
- if( openRepository ){
1183
+ if( openRepository && !Th_IsRepositoryOpen() ){
11681184
db_find_and_open_repository(OPEN_ANY_SCHEMA | OPEN_OK_NOT_FOUND, 0);
1185
+ if( Th_IsRepositoryOpen() ){
1186
+ g.th1Flags |= TH_STATE_REPOSITORY;
1187
+ }else{
1188
+ g.th1Flags &= ~TH_STATE_REPOSITORY;
1189
+ }
11691190
}
1170
- db_open_config(0);
1191
+ if( !Th_IsConfigOpen() ){
1192
+ db_open_config(0);
1193
+ if( Th_IsConfigOpen() ){
1194
+ g.th1Flags |= TH_STATE_CONFIG;
1195
+ }else{
1196
+ g.th1Flags &= ~TH_STATE_CONFIG;
1197
+ }
1198
+ }
11711199
}
11721200
11731201
/*
11741202
** Attempts to close the configuration ("user") database. Optionally, also
11751203
** attempts to close the repository.
11761204
*/
11771205
void Th_CloseConfig(
11781206
int closeRepository
11791207
){
1180
- db_close_config();
1181
- if( closeRepository ){
1208
+ if( g.th1Flags & TH_STATE_CONFIG ){
1209
+ db_close_config();
1210
+ g.th1Flags &= ~TH_STATE_CONFIG;
1211
+ }
1212
+ if( closeRepository && (g.th1Flags & TH_STATE_REPOSITORY) ){
11821213
db_close(1);
1214
+ g.th1Flags &= ~TH_STATE_REPOSITORY;
11831215
}
11841216
}
11851217
11861218
/*
11871219
** Make sure the interpreter has been initialized. Initialize it if
@@ -1284,10 +1316,12 @@
12841316
if( g.thTrace ){
12851317
Th_Trace("th1-setup {%h} => %h<br />\n", g.th1Setup,
12861318
Th_ReturnCodeName(rc, 0));
12871319
}
12881320
}
1321
+ g.th1Flags &= ~TH_INIT_MASK;
1322
+ g.th1Flags |= (flags & TH_INIT_MASK);
12891323
}
12901324
12911325
/*
12921326
** Store a string value in a variable in the interpreter.
12931327
*/
@@ -1434,10 +1468,11 @@
14341468
char cmdFlags
14351469
){
14361470
int rc = TH_OK;
14371471
Th_OpenConfig(1);
14381472
if( fossil_getenv("TH1_ENABLE_HOOKS")==0 && !db_get_boolean("th1-hooks", 0) ){
1473
+ Th_CloseConfig(1);
14391474
return rc;
14401475
}
14411476
Th_CloseConfig(1);
14421477
Th_FossilInit(TH_INIT_HOOK);
14431478
Th_Store("cmd_name", zName);
@@ -1481,10 +1516,11 @@
14811516
char cmdFlags
14821517
){
14831518
int rc = TH_OK;
14841519
Th_OpenConfig(1);
14851520
if( fossil_getenv("TH1_ENABLE_HOOKS")==0 && !db_get_boolean("th1-hooks", 0) ){
1521
+ Th_CloseConfig(1);
14861522
return rc;
14871523
}
14881524
Th_CloseConfig(1);
14891525
Th_FossilInit(TH_INIT_HOOK);
14901526
Th_Store("cmd_name", zName);
@@ -1509,10 +1545,11 @@
15091545
char cmdFlags
15101546
){
15111547
int rc = TH_OK;
15121548
Th_OpenConfig(1);
15131549
if( fossil_getenv("TH1_ENABLE_HOOKS")==0 && !db_get_boolean("th1-hooks", 0) ){
1550
+ Th_CloseConfig(1);
15141551
return rc;
15151552
}
15161553
Th_CloseConfig(1);
15171554
Th_FossilInit(TH_INIT_HOOK);
15181555
Th_Store("web_name", zName);
@@ -1556,10 +1593,11 @@
15561593
char cmdFlags
15571594
){
15581595
int rc = TH_OK;
15591596
Th_OpenConfig(1);
15601597
if( fossil_getenv("TH1_ENABLE_HOOKS")==0 && !db_get_boolean("th1-hooks", 0) ){
1598
+ Th_CloseConfig(1);
15611599
return rc;
15621600
}
15631601
Th_CloseConfig(1);
15641602
Th_FossilInit(TH_INIT_HOOK);
15651603
Th_Store("web_name", zName);
@@ -1680,10 +1718,11 @@
16801718
*/
16811719
void test_th_hook(void){
16821720
int rc = TH_OK;
16831721
int nResult = 0;
16841722
char *zResult;
1723
+ Th_InitTraceLog();
16851724
if( g.argc<5 ){
16861725
usage("TYPE NAME FLAGS");
16871726
}
16881727
if( fossil_stricmp(g.argv[2], "cmdhook")==0 ){
16891728
rc = Th_CommandHook(g.argv[3], (char)atoi(g.argv[4]));
@@ -1700,7 +1739,8 @@
17001739
sendText("RESULT (", -1, 0);
17011740
sendText(Th_ReturnCodeName(rc, 0), -1, 0);
17021741
sendText("): ", -1, 0);
17031742
sendText(zResult, nResult, 0);
17041743
sendText("\n", -1, 0);
1744
+ Th_PrintTraceLog();
17051745
}
17061746
#endif
17071747
--- src/th_main.c
+++ src/th_main.c
@@ -30,14 +30,23 @@
30 #define TH_INIT_NONE ((u32)0x00000000) /* No flags. */
31 #define TH_INIT_NEED_CONFIG ((u32)0x00000001) /* Open configuration first? */
32 #define TH_INIT_FORCE_TCL ((u32)0x00000002) /* Force Tcl to be enabled? */
33 #define TH_INIT_FORCE_RESET ((u32)0x00000004) /* Force TH1 commands re-added? */
34 #define TH_INIT_FORCE_SETUP ((u32)0x00000008) /* Force eval of setup script? */
 
35 #define TH_INIT_DEFAULT (TH_INIT_NONE) /* Default flags. */
36 #define TH_INIT_HOOK (TH_INIT_NEED_CONFIG | TH_INIT_FORCE_SETUP)
37 #endif
38
 
 
 
 
 
 
 
 
39 #ifdef FOSSIL_ENABLE_TH1_HOOKS
40 /*
41 ** These are the "well-known" TH1 error messages that occur when no hook is
42 ** registered to be called prior to executing a command or processing a web
43 ** page, respectively. If one of these errors is seen, it will not be sent
@@ -45,10 +54,17 @@
45 */
46 #define NO_COMMAND_HOOK_ERROR "no such command: command_hook"
47 #define NO_WEBPAGE_HOOK_ERROR "no such command: webpage_hook"
48 #endif
49
 
 
 
 
 
 
 
50 /*
51 ** Global variable counting the number of outstanding calls to malloc()
52 ** made by the th1 implementation. This is used to catch memory leaks
53 ** in the interpreter. Obviously, it also means th1 is not threadsafe.
54 */
@@ -721,16 +737,16 @@
721 int *argl
722 ){
723 if( argc!=2 ){
724 return Th_WrongNumArgs(interp, "styleHeader TITLE");
725 }
726 if( g.zConfigDbName ){
727 style_header("%s", argv[1]);
728 Th_SetResult(interp, 0, 0);
729 return TH_OK;
730 }else{
731 Th_SetResult(interp, "configuration unavailable", -1);
732 return TH_ERROR;
733 }
734 }
735
736 /*
@@ -746,16 +762,16 @@
746 int *argl
747 ){
748 if( argc!=1 ){
749 return Th_WrongNumArgs(interp, "styleFooter");
750 }
751 if( g.zConfigDbName ){
752 style_footer();
753 Th_SetResult(interp, 0, 0);
754 return TH_OK;
755 }else{
756 Th_SetResult(interp, "configuration unavailable", -1);
757 return TH_ERROR;
758 }
759 }
760
761 #ifdef _WIN32
@@ -1162,26 +1178,42 @@
1162 ** attempts to try to find the repository and open it.
1163 */
1164 void Th_OpenConfig(
1165 int openRepository
1166 ){
1167 if( openRepository ){
1168 db_find_and_open_repository(OPEN_ANY_SCHEMA | OPEN_OK_NOT_FOUND, 0);
 
 
 
 
 
1169 }
1170 db_open_config(0);
 
 
 
 
 
 
 
1171 }
1172
1173 /*
1174 ** Attempts to close the configuration ("user") database. Optionally, also
1175 ** attempts to close the repository.
1176 */
1177 void Th_CloseConfig(
1178 int closeRepository
1179 ){
1180 db_close_config();
1181 if( closeRepository ){
 
 
 
1182 db_close(1);
 
1183 }
1184 }
1185
1186 /*
1187 ** Make sure the interpreter has been initialized. Initialize it if
@@ -1284,10 +1316,12 @@
1284 if( g.thTrace ){
1285 Th_Trace("th1-setup {%h} => %h<br />\n", g.th1Setup,
1286 Th_ReturnCodeName(rc, 0));
1287 }
1288 }
 
 
1289 }
1290
1291 /*
1292 ** Store a string value in a variable in the interpreter.
1293 */
@@ -1434,10 +1468,11 @@
1434 char cmdFlags
1435 ){
1436 int rc = TH_OK;
1437 Th_OpenConfig(1);
1438 if( fossil_getenv("TH1_ENABLE_HOOKS")==0 && !db_get_boolean("th1-hooks", 0) ){
 
1439 return rc;
1440 }
1441 Th_CloseConfig(1);
1442 Th_FossilInit(TH_INIT_HOOK);
1443 Th_Store("cmd_name", zName);
@@ -1481,10 +1516,11 @@
1481 char cmdFlags
1482 ){
1483 int rc = TH_OK;
1484 Th_OpenConfig(1);
1485 if( fossil_getenv("TH1_ENABLE_HOOKS")==0 && !db_get_boolean("th1-hooks", 0) ){
 
1486 return rc;
1487 }
1488 Th_CloseConfig(1);
1489 Th_FossilInit(TH_INIT_HOOK);
1490 Th_Store("cmd_name", zName);
@@ -1509,10 +1545,11 @@
1509 char cmdFlags
1510 ){
1511 int rc = TH_OK;
1512 Th_OpenConfig(1);
1513 if( fossil_getenv("TH1_ENABLE_HOOKS")==0 && !db_get_boolean("th1-hooks", 0) ){
 
1514 return rc;
1515 }
1516 Th_CloseConfig(1);
1517 Th_FossilInit(TH_INIT_HOOK);
1518 Th_Store("web_name", zName);
@@ -1556,10 +1593,11 @@
1556 char cmdFlags
1557 ){
1558 int rc = TH_OK;
1559 Th_OpenConfig(1);
1560 if( fossil_getenv("TH1_ENABLE_HOOKS")==0 && !db_get_boolean("th1-hooks", 0) ){
 
1561 return rc;
1562 }
1563 Th_CloseConfig(1);
1564 Th_FossilInit(TH_INIT_HOOK);
1565 Th_Store("web_name", zName);
@@ -1680,10 +1718,11 @@
1680 */
1681 void test_th_hook(void){
1682 int rc = TH_OK;
1683 int nResult = 0;
1684 char *zResult;
 
1685 if( g.argc<5 ){
1686 usage("TYPE NAME FLAGS");
1687 }
1688 if( fossil_stricmp(g.argv[2], "cmdhook")==0 ){
1689 rc = Th_CommandHook(g.argv[3], (char)atoi(g.argv[4]));
@@ -1700,7 +1739,8 @@
1700 sendText("RESULT (", -1, 0);
1701 sendText(Th_ReturnCodeName(rc, 0), -1, 0);
1702 sendText("): ", -1, 0);
1703 sendText(zResult, nResult, 0);
1704 sendText("\n", -1, 0);
 
1705 }
1706 #endif
1707
--- src/th_main.c
+++ src/th_main.c
@@ -30,14 +30,23 @@
30 #define TH_INIT_NONE ((u32)0x00000000) /* No flags. */
31 #define TH_INIT_NEED_CONFIG ((u32)0x00000001) /* Open configuration first? */
32 #define TH_INIT_FORCE_TCL ((u32)0x00000002) /* Force Tcl to be enabled? */
33 #define TH_INIT_FORCE_RESET ((u32)0x00000004) /* Force TH1 commands re-added? */
34 #define TH_INIT_FORCE_SETUP ((u32)0x00000008) /* Force eval of setup script? */
35 #define TH_INIT_MASK ((u32)0x0000000F) /* All possible init flags. */
36 #define TH_INIT_DEFAULT (TH_INIT_NONE) /* Default flags. */
37 #define TH_INIT_HOOK (TH_INIT_NEED_CONFIG | TH_INIT_FORCE_SETUP)
38 #endif
39
40 /*
41 ** Flags set by functions in this file to keep track of integration state
42 ** information. These flags should not be used outside of this file.
43 */
44 #define TH_STATE_CONFIG ((u32)0x00000010) /* We opened the config. */
45 #define TH_STATE_REPOSITORY ((u32)0x00000020) /* We opened the repository. */
46 #define TH_STATE_MASK ((u32)0x00000030) /* All possible state flags. */
47
48 #ifdef FOSSIL_ENABLE_TH1_HOOKS
49 /*
50 ** These are the "well-known" TH1 error messages that occur when no hook is
51 ** registered to be called prior to executing a command or processing a web
52 ** page, respectively. If one of these errors is seen, it will not be sent
@@ -45,10 +54,17 @@
54 */
55 #define NO_COMMAND_HOOK_ERROR "no such command: command_hook"
56 #define NO_WEBPAGE_HOOK_ERROR "no such command: webpage_hook"
57 #endif
58
59 /*
60 ** These macros are used within this file to detect if the repository and
61 ** configuration ("user") database are currently open.
62 */
63 #define Th_IsRepositoryOpen() (g.repositoryOpen)
64 #define Th_IsConfigOpen() (g.zConfigDbName!=0)
65
66 /*
67 ** Global variable counting the number of outstanding calls to malloc()
68 ** made by the th1 implementation. This is used to catch memory leaks
69 ** in the interpreter. Obviously, it also means th1 is not threadsafe.
70 */
@@ -721,16 +737,16 @@
737 int *argl
738 ){
739 if( argc!=2 ){
740 return Th_WrongNumArgs(interp, "styleHeader TITLE");
741 }
742 if( Th_IsRepositoryOpen() ){
743 style_header("%s", argv[1]);
744 Th_SetResult(interp, 0, 0);
745 return TH_OK;
746 }else{
747 Th_SetResult(interp, "repository unavailable", -1);
748 return TH_ERROR;
749 }
750 }
751
752 /*
@@ -746,16 +762,16 @@
762 int *argl
763 ){
764 if( argc!=1 ){
765 return Th_WrongNumArgs(interp, "styleFooter");
766 }
767 if( Th_IsRepositoryOpen() ){
768 style_footer();
769 Th_SetResult(interp, 0, 0);
770 return TH_OK;
771 }else{
772 Th_SetResult(interp, "repository unavailable", -1);
773 return TH_ERROR;
774 }
775 }
776
777 #ifdef _WIN32
@@ -1162,26 +1178,42 @@
1178 ** attempts to try to find the repository and open it.
1179 */
1180 void Th_OpenConfig(
1181 int openRepository
1182 ){
1183 if( openRepository && !Th_IsRepositoryOpen() ){
1184 db_find_and_open_repository(OPEN_ANY_SCHEMA | OPEN_OK_NOT_FOUND, 0);
1185 if( Th_IsRepositoryOpen() ){
1186 g.th1Flags |= TH_STATE_REPOSITORY;
1187 }else{
1188 g.th1Flags &= ~TH_STATE_REPOSITORY;
1189 }
1190 }
1191 if( !Th_IsConfigOpen() ){
1192 db_open_config(0);
1193 if( Th_IsConfigOpen() ){
1194 g.th1Flags |= TH_STATE_CONFIG;
1195 }else{
1196 g.th1Flags &= ~TH_STATE_CONFIG;
1197 }
1198 }
1199 }
1200
1201 /*
1202 ** Attempts to close the configuration ("user") database. Optionally, also
1203 ** attempts to close the repository.
1204 */
1205 void Th_CloseConfig(
1206 int closeRepository
1207 ){
1208 if( g.th1Flags & TH_STATE_CONFIG ){
1209 db_close_config();
1210 g.th1Flags &= ~TH_STATE_CONFIG;
1211 }
1212 if( closeRepository && (g.th1Flags & TH_STATE_REPOSITORY) ){
1213 db_close(1);
1214 g.th1Flags &= ~TH_STATE_REPOSITORY;
1215 }
1216 }
1217
1218 /*
1219 ** Make sure the interpreter has been initialized. Initialize it if
@@ -1284,10 +1316,12 @@
1316 if( g.thTrace ){
1317 Th_Trace("th1-setup {%h} => %h<br />\n", g.th1Setup,
1318 Th_ReturnCodeName(rc, 0));
1319 }
1320 }
1321 g.th1Flags &= ~TH_INIT_MASK;
1322 g.th1Flags |= (flags & TH_INIT_MASK);
1323 }
1324
1325 /*
1326 ** Store a string value in a variable in the interpreter.
1327 */
@@ -1434,10 +1468,11 @@
1468 char cmdFlags
1469 ){
1470 int rc = TH_OK;
1471 Th_OpenConfig(1);
1472 if( fossil_getenv("TH1_ENABLE_HOOKS")==0 && !db_get_boolean("th1-hooks", 0) ){
1473 Th_CloseConfig(1);
1474 return rc;
1475 }
1476 Th_CloseConfig(1);
1477 Th_FossilInit(TH_INIT_HOOK);
1478 Th_Store("cmd_name", zName);
@@ -1481,10 +1516,11 @@
1516 char cmdFlags
1517 ){
1518 int rc = TH_OK;
1519 Th_OpenConfig(1);
1520 if( fossil_getenv("TH1_ENABLE_HOOKS")==0 && !db_get_boolean("th1-hooks", 0) ){
1521 Th_CloseConfig(1);
1522 return rc;
1523 }
1524 Th_CloseConfig(1);
1525 Th_FossilInit(TH_INIT_HOOK);
1526 Th_Store("cmd_name", zName);
@@ -1509,10 +1545,11 @@
1545 char cmdFlags
1546 ){
1547 int rc = TH_OK;
1548 Th_OpenConfig(1);
1549 if( fossil_getenv("TH1_ENABLE_HOOKS")==0 && !db_get_boolean("th1-hooks", 0) ){
1550 Th_CloseConfig(1);
1551 return rc;
1552 }
1553 Th_CloseConfig(1);
1554 Th_FossilInit(TH_INIT_HOOK);
1555 Th_Store("web_name", zName);
@@ -1556,10 +1593,11 @@
1593 char cmdFlags
1594 ){
1595 int rc = TH_OK;
1596 Th_OpenConfig(1);
1597 if( fossil_getenv("TH1_ENABLE_HOOKS")==0 && !db_get_boolean("th1-hooks", 0) ){
1598 Th_CloseConfig(1);
1599 return rc;
1600 }
1601 Th_CloseConfig(1);
1602 Th_FossilInit(TH_INIT_HOOK);
1603 Th_Store("web_name", zName);
@@ -1680,10 +1718,11 @@
1718 */
1719 void test_th_hook(void){
1720 int rc = TH_OK;
1721 int nResult = 0;
1722 char *zResult;
1723 Th_InitTraceLog();
1724 if( g.argc<5 ){
1725 usage("TYPE NAME FLAGS");
1726 }
1727 if( fossil_stricmp(g.argv[2], "cmdhook")==0 ){
1728 rc = Th_CommandHook(g.argv[3], (char)atoi(g.argv[4]));
@@ -1700,7 +1739,8 @@
1739 sendText("RESULT (", -1, 0);
1740 sendText(Th_ReturnCodeName(rc, 0), -1, 0);
1741 sendText("): ", -1, 0);
1742 sendText(zResult, nResult, 0);
1743 sendText("\n", -1, 0);
1744 Th_PrintTraceLog();
1745 }
1746 #endif
1747
+29 -5
--- test/th1.test
+++ test/th1.test
@@ -16,10 +16,15 @@
1616
############################################################################
1717
#
1818
# TH1 Commands
1919
#
2020
21
+fossil test-th-eval --th-open-config "setting th1-hooks"
22
+set th1Hooks [expr {$RESULT eq "1"}]
23
+
24
+###############################################################################
25
+
2126
fossil test-th-eval --th-open-config "setting abc"
2227
test th1-setting-1 {$RESULT eq ""}
2328
2429
###############################################################################
2530
@@ -515,49 +520,68 @@
515520
test th1-trace-1 {$RESULT eq {}}
516521
517522
###############################################################################
518523
519524
fossil test-th-eval --th-trace "trace {}"
520
-test th1-trace-2 {[string map [list \r\n \n] [string trim $RESULT]] eq \
525
+if {$th1Hooks} {
526
+ test th1-trace-2 {[string map [list \r\n \n] [string trim $RESULT]] eq \
521527
{------------------ BEGIN TRACE LOG ------------------
528
+
529
+------------------- END TRACE LOG -------------------}}
530
+} else {
531
+ test th1-trace-2 {[string map [list \r\n \n] [string trim $RESULT]] eq \
532
+ {------------------ BEGIN TRACE LOG ------------------
522533
th1-setup {} => TH_OK<br />
523534
524535
------------------- END TRACE LOG -------------------}}
536
+}
525537
526538
###############################################################################
527539
528540
fossil test-th-eval "trace {this is a trace message.}"
529541
test th1-trace-3 {$RESULT eq {}}
530542
531543
###############################################################################
532544
533545
fossil test-th-eval --th-trace "trace {this is a trace message.}"
534
-test th1-trace-4 {[string map [list \r\n \n] [string trim $RESULT]] eq \
535
-{------------------ BEGIN TRACE LOG ------------------
546
+if {$th1Hooks} {
547
+ test th1-trace-4 {[string map [list \r\n \n] [string trim $RESULT]] eq \
548
+ {------------------ BEGIN TRACE LOG ------------------
549
+this is a trace message.
550
+------------------- END TRACE LOG -------------------}}
551
+} else {
552
+ test th1-trace-4 {[string map [list \r\n \n] [string trim $RESULT]] eq \
553
+ {------------------ BEGIN TRACE LOG ------------------
536554
th1-setup {} => TH_OK<br />
537555
this is a trace message.
538556
------------------- END TRACE LOG -------------------}}
557
+}
539558
540559
###############################################################################
541560
542561
fossil test-th-eval "styleHeader {Page Title Here}"
543
-test th1-header-1 {$RESULT eq {TH_ERROR: configuration unavailable}}
562
+test th1-header-1 {$RESULT eq {TH_ERROR: repository unavailable}}
544563
545564
###############################################################################
546565
547566
fossil test-th-eval --th-open-config "styleHeader {Page Title Here}"
548567
test th1-header-2 {[regexp -- {<title>Fossil: Page Title Here</title>} $RESULT]}
549568
550569
###############################################################################
551570
552571
fossil test-th-eval "styleFooter"
553
-test th1-footer-1 {$RESULT eq {TH_ERROR: configuration unavailable}}
572
+test th1-footer-1 {$RESULT eq {TH_ERROR: repository unavailable}}
554573
555574
###############################################################################
556575
557576
fossil test-th-eval --th-open-config "styleFooter"
558577
test th1-footer-2 {$RESULT eq {}}
578
+
579
+###############################################################################
580
+
581
+fossil test-th-eval --th-open-config "styleHeader {}; styleFooter"
582
+test th1-footer-3 {[regexp -- {</body></html>} $RESULT]}
559583
560584
###############################################################################
561585
562586
fossil test-th-eval "getParameter"
563587
test th1-get-parameter-1 {$RESULT eq \
564588
--- test/th1.test
+++ test/th1.test
@@ -16,10 +16,15 @@
16 ############################################################################
17 #
18 # TH1 Commands
19 #
20
 
 
 
 
 
21 fossil test-th-eval --th-open-config "setting abc"
22 test th1-setting-1 {$RESULT eq ""}
23
24 ###############################################################################
25
@@ -515,49 +520,68 @@
515 test th1-trace-1 {$RESULT eq {}}
516
517 ###############################################################################
518
519 fossil test-th-eval --th-trace "trace {}"
520 test th1-trace-2 {[string map [list \r\n \n] [string trim $RESULT]] eq \
 
521 {------------------ BEGIN TRACE LOG ------------------
 
 
 
 
 
522 th1-setup {} => TH_OK<br />
523
524 ------------------- END TRACE LOG -------------------}}
 
525
526 ###############################################################################
527
528 fossil test-th-eval "trace {this is a trace message.}"
529 test th1-trace-3 {$RESULT eq {}}
530
531 ###############################################################################
532
533 fossil test-th-eval --th-trace "trace {this is a trace message.}"
534 test th1-trace-4 {[string map [list \r\n \n] [string trim $RESULT]] eq \
535 {------------------ BEGIN TRACE LOG ------------------
 
 
 
 
 
 
536 th1-setup {} => TH_OK<br />
537 this is a trace message.
538 ------------------- END TRACE LOG -------------------}}
 
539
540 ###############################################################################
541
542 fossil test-th-eval "styleHeader {Page Title Here}"
543 test th1-header-1 {$RESULT eq {TH_ERROR: configuration unavailable}}
544
545 ###############################################################################
546
547 fossil test-th-eval --th-open-config "styleHeader {Page Title Here}"
548 test th1-header-2 {[regexp -- {<title>Fossil: Page Title Here</title>} $RESULT]}
549
550 ###############################################################################
551
552 fossil test-th-eval "styleFooter"
553 test th1-footer-1 {$RESULT eq {TH_ERROR: configuration unavailable}}
554
555 ###############################################################################
556
557 fossil test-th-eval --th-open-config "styleFooter"
558 test th1-footer-2 {$RESULT eq {}}
 
 
 
 
 
559
560 ###############################################################################
561
562 fossil test-th-eval "getParameter"
563 test th1-get-parameter-1 {$RESULT eq \
564
--- test/th1.test
+++ test/th1.test
@@ -16,10 +16,15 @@
16 ############################################################################
17 #
18 # TH1 Commands
19 #
20
21 fossil test-th-eval --th-open-config "setting th1-hooks"
22 set th1Hooks [expr {$RESULT eq "1"}]
23
24 ###############################################################################
25
26 fossil test-th-eval --th-open-config "setting abc"
27 test th1-setting-1 {$RESULT eq ""}
28
29 ###############################################################################
30
@@ -515,49 +520,68 @@
520 test th1-trace-1 {$RESULT eq {}}
521
522 ###############################################################################
523
524 fossil test-th-eval --th-trace "trace {}"
525 if {$th1Hooks} {
526 test th1-trace-2 {[string map [list \r\n \n] [string trim $RESULT]] eq \
527 {------------------ BEGIN TRACE LOG ------------------
528
529 ------------------- END TRACE LOG -------------------}}
530 } else {
531 test th1-trace-2 {[string map [list \r\n \n] [string trim $RESULT]] eq \
532 {------------------ BEGIN TRACE LOG ------------------
533 th1-setup {} => TH_OK<br />
534
535 ------------------- END TRACE LOG -------------------}}
536 }
537
538 ###############################################################################
539
540 fossil test-th-eval "trace {this is a trace message.}"
541 test th1-trace-3 {$RESULT eq {}}
542
543 ###############################################################################
544
545 fossil test-th-eval --th-trace "trace {this is a trace message.}"
546 if {$th1Hooks} {
547 test th1-trace-4 {[string map [list \r\n \n] [string trim $RESULT]] eq \
548 {------------------ BEGIN TRACE LOG ------------------
549 this is a trace message.
550 ------------------- END TRACE LOG -------------------}}
551 } else {
552 test th1-trace-4 {[string map [list \r\n \n] [string trim $RESULT]] eq \
553 {------------------ BEGIN TRACE LOG ------------------
554 th1-setup {} => TH_OK<br />
555 this is a trace message.
556 ------------------- END TRACE LOG -------------------}}
557 }
558
559 ###############################################################################
560
561 fossil test-th-eval "styleHeader {Page Title Here}"
562 test th1-header-1 {$RESULT eq {TH_ERROR: repository unavailable}}
563
564 ###############################################################################
565
566 fossil test-th-eval --th-open-config "styleHeader {Page Title Here}"
567 test th1-header-2 {[regexp -- {<title>Fossil: Page Title Here</title>} $RESULT]}
568
569 ###############################################################################
570
571 fossil test-th-eval "styleFooter"
572 test th1-footer-1 {$RESULT eq {TH_ERROR: repository unavailable}}
573
574 ###############################################################################
575
576 fossil test-th-eval --th-open-config "styleFooter"
577 test th1-footer-2 {$RESULT eq {}}
578
579 ###############################################################################
580
581 fossil test-th-eval --th-open-config "styleHeader {}; styleFooter"
582 test th1-footer-3 {[regexp -- {</body></html>} $RESULT]}
583
584 ###############################################################################
585
586 fossil test-th-eval "getParameter"
587 test th1-get-parameter-1 {$RESULT eq \
588

Keyboard Shortcuts

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