Fossil SCM

Add the 'th-force-cgi' and 'th-full-http' options to several test commands.

mistachkin 2014-06-15 01:22 trunk
Commit c1915c33470a2c7f8694930fa208029e7b590f80
2 files changed +27 +1 -1
--- src/th_main.c
+++ src/th_main.c
@@ -102,10 +102,22 @@
102102
va_list ap;
103103
va_start(ap, zFormat);
104104
blob_vappendf(&g.thLog, zFormat, ap);
105105
va_end(ap);
106106
}
107
+
108
+/*
109
+** Forces input and output to be done via the CGI subsystem.
110
+*/
111
+void Th_ForceCgi(int fullHttpReply){
112
+ g.httpOut = stdout;
113
+ g.httpIn = stdin;
114
+ fossil_binary_mode(g.httpOut);
115
+ fossil_binary_mode(g.httpIn);
116
+ g.cgiOutput = 1;
117
+ g.fullHttpReply = fullHttpReply;
118
+}
107119
108120
/*
109121
** Checks if the TH1 trace log needs to be enabled. If so, prepares
110122
** it for use.
111123
*/
@@ -1676,12 +1688,16 @@
16761688
16771689
/*
16781690
** COMMAND: test-th-render
16791691
*/
16801692
void test_th_render(void){
1693
+ int forceCgi, fullHttpReply;
16811694
Blob in;
16821695
Th_InitTraceLog();
1696
+ forceCgi = find_option("th-force-cgi", 0, 0)!=0;
1697
+ fullHttpReply = find_option("th-full-http", 0, 0)!=0;
1698
+ if( forceCgi ) Th_ForceCgi(fullHttpReply);
16831699
if( find_option("th-open-config", 0, 0)!=0 ){
16841700
Th_OpenConfig(1);
16851701
}
16861702
if( g.argc<3 ){
16871703
usage("FILE");
@@ -1688,19 +1704,24 @@
16881704
}
16891705
blob_zero(&in);
16901706
blob_read_from_file(&in, g.argv[2]);
16911707
Th_Render(blob_str(&in));
16921708
Th_PrintTraceLog();
1709
+ if( forceCgi ) cgi_reply();
16931710
}
16941711
16951712
/*
16961713
** COMMAND: test-th-eval
16971714
*/
16981715
void test_th_eval(void){
16991716
int rc;
17001717
const char *zRc;
1718
+ int forceCgi, fullHttpReply;
17011719
Th_InitTraceLog();
1720
+ forceCgi = find_option("th-force-cgi", 0, 0)!=0;
1721
+ fullHttpReply = find_option("th-full-http", 0, 0)!=0;
1722
+ if( forceCgi ) Th_ForceCgi(fullHttpReply);
17021723
if( find_option("th-open-config", 0, 0)!=0 ){
17031724
Th_OpenConfig(1);
17041725
}
17051726
if( g.argc!=3 ){
17061727
usage("script");
@@ -1708,10 +1729,11 @@
17081729
Th_FossilInit(TH_INIT_DEFAULT);
17091730
rc = Th_Eval(g.interp, 0, g.argv[2], -1);
17101731
zRc = Th_ReturnCodeName(rc, 1);
17111732
fossil_print("%s%s%s\n", zRc, zRc ? ": " : "", Th_GetResult(g.interp, 0));
17121733
Th_PrintTraceLog();
1734
+ if( forceCgi ) cgi_reply();
17131735
}
17141736
17151737
#ifdef FOSSIL_ENABLE_TH1_HOOKS
17161738
/*
17171739
** COMMAND: test-th-hook
@@ -1718,11 +1740,15 @@
17181740
*/
17191741
void test_th_hook(void){
17201742
int rc = TH_OK;
17211743
int nResult = 0;
17221744
char *zResult;
1745
+ int forceCgi, fullHttpReply;
17231746
Th_InitTraceLog();
1747
+ forceCgi = find_option("th-force-cgi", 0, 0)!=0;
1748
+ fullHttpReply = find_option("th-full-http", 0, 0)!=0;
1749
+ if( forceCgi ) Th_ForceCgi(fullHttpReply);
17241750
if( g.argc<5 ){
17251751
usage("TYPE NAME FLAGS");
17261752
}
17271753
if( fossil_stricmp(g.argv[2], "cmdhook")==0 ){
17281754
rc = Th_CommandHook(g.argv[3], (char)atoi(g.argv[4]));
@@ -1740,7 +1766,8 @@
17401766
sendText(Th_ReturnCodeName(rc, 0), -1, 0);
17411767
sendText("): ", -1, 0);
17421768
sendText(zResult, nResult, 0);
17431769
sendText("\n", -1, 0);
17441770
Th_PrintTraceLog();
1771
+ if( forceCgi ) cgi_reply();
17451772
}
17461773
#endif
17471774
--- src/th_main.c
+++ src/th_main.c
@@ -102,10 +102,22 @@
102 va_list ap;
103 va_start(ap, zFormat);
104 blob_vappendf(&g.thLog, zFormat, ap);
105 va_end(ap);
106 }
 
 
 
 
 
 
 
 
 
 
 
 
107
108 /*
109 ** Checks if the TH1 trace log needs to be enabled. If so, prepares
110 ** it for use.
111 */
@@ -1676,12 +1688,16 @@
1676
1677 /*
1678 ** COMMAND: test-th-render
1679 */
1680 void test_th_render(void){
 
1681 Blob in;
1682 Th_InitTraceLog();
 
 
 
1683 if( find_option("th-open-config", 0, 0)!=0 ){
1684 Th_OpenConfig(1);
1685 }
1686 if( g.argc<3 ){
1687 usage("FILE");
@@ -1688,19 +1704,24 @@
1688 }
1689 blob_zero(&in);
1690 blob_read_from_file(&in, g.argv[2]);
1691 Th_Render(blob_str(&in));
1692 Th_PrintTraceLog();
 
1693 }
1694
1695 /*
1696 ** COMMAND: test-th-eval
1697 */
1698 void test_th_eval(void){
1699 int rc;
1700 const char *zRc;
 
1701 Th_InitTraceLog();
 
 
 
1702 if( find_option("th-open-config", 0, 0)!=0 ){
1703 Th_OpenConfig(1);
1704 }
1705 if( g.argc!=3 ){
1706 usage("script");
@@ -1708,10 +1729,11 @@
1708 Th_FossilInit(TH_INIT_DEFAULT);
1709 rc = Th_Eval(g.interp, 0, g.argv[2], -1);
1710 zRc = Th_ReturnCodeName(rc, 1);
1711 fossil_print("%s%s%s\n", zRc, zRc ? ": " : "", Th_GetResult(g.interp, 0));
1712 Th_PrintTraceLog();
 
1713 }
1714
1715 #ifdef FOSSIL_ENABLE_TH1_HOOKS
1716 /*
1717 ** COMMAND: test-th-hook
@@ -1718,11 +1740,15 @@
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]));
@@ -1740,7 +1766,8 @@
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
--- src/th_main.c
+++ src/th_main.c
@@ -102,10 +102,22 @@
102 va_list ap;
103 va_start(ap, zFormat);
104 blob_vappendf(&g.thLog, zFormat, ap);
105 va_end(ap);
106 }
107
108 /*
109 ** Forces input and output to be done via the CGI subsystem.
110 */
111 void Th_ForceCgi(int fullHttpReply){
112 g.httpOut = stdout;
113 g.httpIn = stdin;
114 fossil_binary_mode(g.httpOut);
115 fossil_binary_mode(g.httpIn);
116 g.cgiOutput = 1;
117 g.fullHttpReply = fullHttpReply;
118 }
119
120 /*
121 ** Checks if the TH1 trace log needs to be enabled. If so, prepares
122 ** it for use.
123 */
@@ -1676,12 +1688,16 @@
1688
1689 /*
1690 ** COMMAND: test-th-render
1691 */
1692 void test_th_render(void){
1693 int forceCgi, fullHttpReply;
1694 Blob in;
1695 Th_InitTraceLog();
1696 forceCgi = find_option("th-force-cgi", 0, 0)!=0;
1697 fullHttpReply = find_option("th-full-http", 0, 0)!=0;
1698 if( forceCgi ) Th_ForceCgi(fullHttpReply);
1699 if( find_option("th-open-config", 0, 0)!=0 ){
1700 Th_OpenConfig(1);
1701 }
1702 if( g.argc<3 ){
1703 usage("FILE");
@@ -1688,19 +1704,24 @@
1704 }
1705 blob_zero(&in);
1706 blob_read_from_file(&in, g.argv[2]);
1707 Th_Render(blob_str(&in));
1708 Th_PrintTraceLog();
1709 if( forceCgi ) cgi_reply();
1710 }
1711
1712 /*
1713 ** COMMAND: test-th-eval
1714 */
1715 void test_th_eval(void){
1716 int rc;
1717 const char *zRc;
1718 int forceCgi, fullHttpReply;
1719 Th_InitTraceLog();
1720 forceCgi = find_option("th-force-cgi", 0, 0)!=0;
1721 fullHttpReply = find_option("th-full-http", 0, 0)!=0;
1722 if( forceCgi ) Th_ForceCgi(fullHttpReply);
1723 if( find_option("th-open-config", 0, 0)!=0 ){
1724 Th_OpenConfig(1);
1725 }
1726 if( g.argc!=3 ){
1727 usage("script");
@@ -1708,10 +1729,11 @@
1729 Th_FossilInit(TH_INIT_DEFAULT);
1730 rc = Th_Eval(g.interp, 0, g.argv[2], -1);
1731 zRc = Th_ReturnCodeName(rc, 1);
1732 fossil_print("%s%s%s\n", zRc, zRc ? ": " : "", Th_GetResult(g.interp, 0));
1733 Th_PrintTraceLog();
1734 if( forceCgi ) cgi_reply();
1735 }
1736
1737 #ifdef FOSSIL_ENABLE_TH1_HOOKS
1738 /*
1739 ** COMMAND: test-th-hook
@@ -1718,11 +1740,15 @@
1740 */
1741 void test_th_hook(void){
1742 int rc = TH_OK;
1743 int nResult = 0;
1744 char *zResult;
1745 int forceCgi, fullHttpReply;
1746 Th_InitTraceLog();
1747 forceCgi = find_option("th-force-cgi", 0, 0)!=0;
1748 fullHttpReply = find_option("th-full-http", 0, 0)!=0;
1749 if( forceCgi ) Th_ForceCgi(fullHttpReply);
1750 if( g.argc<5 ){
1751 usage("TYPE NAME FLAGS");
1752 }
1753 if( fossil_stricmp(g.argv[2], "cmdhook")==0 ){
1754 rc = Th_CommandHook(g.argv[3], (char)atoi(g.argv[4]));
@@ -1740,7 +1766,8 @@
1766 sendText(Th_ReturnCodeName(rc, 0), -1, 0);
1767 sendText("): ", -1, 0);
1768 sendText(zResult, nResult, 0);
1769 sendText("\n", -1, 0);
1770 Th_PrintTraceLog();
1771 if( forceCgi ) cgi_reply();
1772 }
1773 #endif
1774
+1 -1
--- test/th1.test
+++ test/th1.test
@@ -576,11 +576,11 @@
576576
fossil test-th-eval --th-open-config "styleFooter"
577577
test th1-footer-2 {$RESULT eq {}}
578578
579579
###############################################################################
580580
581
-fossil test-th-eval --th-open-config "styleHeader {}; styleFooter"
581
+fossil test-th-eval --th-open-config --th-force-cgi "styleHeader {}; styleFooter"
582582
test th1-footer-3 {[regexp -- {</body></html>} $RESULT]}
583583
584584
###############################################################################
585585
586586
fossil test-th-eval "getParameter"
587587
--- test/th1.test
+++ test/th1.test
@@ -576,11 +576,11 @@
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.test
+++ test/th1.test
@@ -576,11 +576,11 @@
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 --th-force-cgi "styleHeader {}; styleFooter"
582 test th1-footer-3 {[regexp -- {</body></html>} $RESULT]}
583
584 ###############################################################################
585
586 fossil test-th-eval "getParameter"
587

Keyboard Shortcuts

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