Fossil SCM
Add the 'th-force-cgi' and 'th-full-http' options to several test commands.
Commit
c1915c33470a2c7f8694930fa208029e7b590f80
Parent
f83946c669ba83d…
2 files changed
+27
+1
-1
+27
| --- src/th_main.c | ||
| +++ src/th_main.c | ||
| @@ -102,10 +102,22 @@ | ||
| 102 | 102 | va_list ap; |
| 103 | 103 | va_start(ap, zFormat); |
| 104 | 104 | blob_vappendf(&g.thLog, zFormat, ap); |
| 105 | 105 | va_end(ap); |
| 106 | 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 | +} | |
| 107 | 119 | |
| 108 | 120 | /* |
| 109 | 121 | ** Checks if the TH1 trace log needs to be enabled. If so, prepares |
| 110 | 122 | ** it for use. |
| 111 | 123 | */ |
| @@ -1676,12 +1688,16 @@ | ||
| 1676 | 1688 | |
| 1677 | 1689 | /* |
| 1678 | 1690 | ** COMMAND: test-th-render |
| 1679 | 1691 | */ |
| 1680 | 1692 | void test_th_render(void){ |
| 1693 | + int forceCgi, fullHttpReply; | |
| 1681 | 1694 | Blob in; |
| 1682 | 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); | |
| 1683 | 1699 | if( find_option("th-open-config", 0, 0)!=0 ){ |
| 1684 | 1700 | Th_OpenConfig(1); |
| 1685 | 1701 | } |
| 1686 | 1702 | if( g.argc<3 ){ |
| 1687 | 1703 | usage("FILE"); |
| @@ -1688,19 +1704,24 @@ | ||
| 1688 | 1704 | } |
| 1689 | 1705 | blob_zero(&in); |
| 1690 | 1706 | blob_read_from_file(&in, g.argv[2]); |
| 1691 | 1707 | Th_Render(blob_str(&in)); |
| 1692 | 1708 | Th_PrintTraceLog(); |
| 1709 | + if( forceCgi ) cgi_reply(); | |
| 1693 | 1710 | } |
| 1694 | 1711 | |
| 1695 | 1712 | /* |
| 1696 | 1713 | ** COMMAND: test-th-eval |
| 1697 | 1714 | */ |
| 1698 | 1715 | void test_th_eval(void){ |
| 1699 | 1716 | int rc; |
| 1700 | 1717 | const char *zRc; |
| 1718 | + int forceCgi, fullHttpReply; | |
| 1701 | 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); | |
| 1702 | 1723 | if( find_option("th-open-config", 0, 0)!=0 ){ |
| 1703 | 1724 | Th_OpenConfig(1); |
| 1704 | 1725 | } |
| 1705 | 1726 | if( g.argc!=3 ){ |
| 1706 | 1727 | usage("script"); |
| @@ -1708,10 +1729,11 @@ | ||
| 1708 | 1729 | Th_FossilInit(TH_INIT_DEFAULT); |
| 1709 | 1730 | rc = Th_Eval(g.interp, 0, g.argv[2], -1); |
| 1710 | 1731 | zRc = Th_ReturnCodeName(rc, 1); |
| 1711 | 1732 | fossil_print("%s%s%s\n", zRc, zRc ? ": " : "", Th_GetResult(g.interp, 0)); |
| 1712 | 1733 | Th_PrintTraceLog(); |
| 1734 | + if( forceCgi ) cgi_reply(); | |
| 1713 | 1735 | } |
| 1714 | 1736 | |
| 1715 | 1737 | #ifdef FOSSIL_ENABLE_TH1_HOOKS |
| 1716 | 1738 | /* |
| 1717 | 1739 | ** COMMAND: test-th-hook |
| @@ -1718,11 +1740,15 @@ | ||
| 1718 | 1740 | */ |
| 1719 | 1741 | void test_th_hook(void){ |
| 1720 | 1742 | int rc = TH_OK; |
| 1721 | 1743 | int nResult = 0; |
| 1722 | 1744 | char *zResult; |
| 1745 | + int forceCgi, fullHttpReply; | |
| 1723 | 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); | |
| 1724 | 1750 | if( g.argc<5 ){ |
| 1725 | 1751 | usage("TYPE NAME FLAGS"); |
| 1726 | 1752 | } |
| 1727 | 1753 | if( fossil_stricmp(g.argv[2], "cmdhook")==0 ){ |
| 1728 | 1754 | rc = Th_CommandHook(g.argv[3], (char)atoi(g.argv[4])); |
| @@ -1740,7 +1766,8 @@ | ||
| 1740 | 1766 | sendText(Th_ReturnCodeName(rc, 0), -1, 0); |
| 1741 | 1767 | sendText("): ", -1, 0); |
| 1742 | 1768 | sendText(zResult, nResult, 0); |
| 1743 | 1769 | sendText("\n", -1, 0); |
| 1744 | 1770 | Th_PrintTraceLog(); |
| 1771 | + if( forceCgi ) cgi_reply(); | |
| 1745 | 1772 | } |
| 1746 | 1773 | #endif |
| 1747 | 1774 |
| --- 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 @@ | ||
| 576 | 576 | fossil test-th-eval --th-open-config "styleFooter" |
| 577 | 577 | test th1-footer-2 {$RESULT eq {}} |
| 578 | 578 | |
| 579 | 579 | ############################################################################### |
| 580 | 580 | |
| 581 | -fossil test-th-eval --th-open-config "styleHeader {}; styleFooter" | |
| 581 | +fossil test-th-eval --th-open-config --th-force-cgi "styleHeader {}; styleFooter" | |
| 582 | 582 | test th1-footer-3 {[regexp -- {</body></html>} $RESULT]} |
| 583 | 583 | |
| 584 | 584 | ############################################################################### |
| 585 | 585 | |
| 586 | 586 | fossil test-th-eval "getParameter" |
| 587 | 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 "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 |