Fossil SCM

Add tests for the TH1 docs feature.

mistachkin 2015-03-23 00:44 trunk
Commit 71536a285116c644bf9ad784b3dc0a347a4bbd8f
+1 -1
--- src/doc.c
+++ src/doc.c
@@ -640,11 +640,11 @@
640640
if( blob_size(&title)==0 ) blob_append(&title,zName,-1);
641641
style_header("%s", blob_str(&title));
642642
blob_append(cgi_output_blob(), blob_buffer(&filebody),blob_size(&filebody));
643643
style_footer();
644644
#ifdef FOSSIL_ENABLE_TH1_DOCS
645
- }else if( db_get_boolean("th1-docs", 0) &&
645
+ }else if( Th_AreDocsEnabled() &&
646646
fossil_strcmp(zMime, "application/x-th1")==0 ){
647647
style_header("%h", zName);
648648
Th_Render(blob_str(&filebody));
649649
style_footer();
650650
#endif
651651
--- src/doc.c
+++ src/doc.c
@@ -640,11 +640,11 @@
640 if( blob_size(&title)==0 ) blob_append(&title,zName,-1);
641 style_header("%s", blob_str(&title));
642 blob_append(cgi_output_blob(), blob_buffer(&filebody),blob_size(&filebody));
643 style_footer();
644 #ifdef FOSSIL_ENABLE_TH1_DOCS
645 }else if( db_get_boolean("th1-docs", 0) &&
646 fossil_strcmp(zMime, "application/x-th1")==0 ){
647 style_header("%h", zName);
648 Th_Render(blob_str(&filebody));
649 style_footer();
650 #endif
651
--- src/doc.c
+++ src/doc.c
@@ -640,11 +640,11 @@
640 if( blob_size(&title)==0 ) blob_append(&title,zName,-1);
641 style_header("%s", blob_str(&title));
642 blob_append(cgi_output_blob(), blob_buffer(&filebody),blob_size(&filebody));
643 style_footer();
644 #ifdef FOSSIL_ENABLE_TH1_DOCS
645 }else if( Th_AreDocsEnabled() &&
646 fossil_strcmp(zMime, "application/x-th1")==0 ){
647 style_header("%h", zName);
648 Th_Render(blob_str(&filebody));
649 style_footer();
650 #endif
651
--- src/th_main.c
+++ src/th_main.c
@@ -1981,10 +1981,24 @@
19811981
*/
19821982
if( TH_INIT_HOOK & TH_INIT_NEED_CONFIG ) Th_CloseConfig(1);
19831983
return rc;
19841984
}
19851985
#endif
1986
+
1987
+
1988
+#ifdef FOSSIL_ENABLE_TH1_DOCS
1989
+/*
1990
+** This function determines if TH1 docs are enabled for the repository.
1991
+*/
1992
+int Th_AreDocsEnabled(void){
1993
+ if( fossil_getenv("TH1_ENABLE_DOCS")!=0 ){
1994
+ return 1;
1995
+ }
1996
+ return db_get_boolean("th1-docs", 0);
1997
+}
1998
+#endif
1999
+
19862000
19872001
/*
19882002
** The z[] input contains text mixed with TH1 scripts.
19892003
** The TH1 scripts are contained within <th1>...</th1>.
19902004
** TH1 variables are $aaa or $<aaa>. The first form of
19912005
19922006
ADDED test/fileStat.th1
--- src/th_main.c
+++ src/th_main.c
@@ -1981,10 +1981,24 @@
1981 */
1982 if( TH_INIT_HOOK & TH_INIT_NEED_CONFIG ) Th_CloseConfig(1);
1983 return rc;
1984 }
1985 #endif
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1986
1987 /*
1988 ** The z[] input contains text mixed with TH1 scripts.
1989 ** The TH1 scripts are contained within <th1>...</th1>.
1990 ** TH1 variables are $aaa or $<aaa>. The first form of
1991
1992 DDED test/fileStat.th1
--- src/th_main.c
+++ src/th_main.c
@@ -1981,10 +1981,24 @@
1981 */
1982 if( TH_INIT_HOOK & TH_INIT_NEED_CONFIG ) Th_CloseConfig(1);
1983 return rc;
1984 }
1985 #endif
1986
1987
1988 #ifdef FOSSIL_ENABLE_TH1_DOCS
1989 /*
1990 ** This function determines if TH1 docs are enabled for the repository.
1991 */
1992 int Th_AreDocsEnabled(void){
1993 if( fossil_getenv("TH1_ENABLE_DOCS")!=0 ){
1994 return 1;
1995 }
1996 return db_get_boolean("th1-docs", 0);
1997 }
1998 #endif
1999
2000
2001 /*
2002 ** The z[] input contains text mixed with TH1 scripts.
2003 ** The TH1 scripts are contained within <th1>...</th1>.
2004 ** TH1 variables are $aaa or $<aaa>. The first form of
2005
2006 DDED test/fileStat.th1
--- a/test/fileStat.th1
+++ b/test/fileStat.th1
@@ -0,0 +1,29 @@
1
+<th1>
2
+ proc doSomeTclSetup {} {
3
+ #
4
+ # NOTE: Copy repository file name to the Tcl interpreter. This is
5
+ # done first (once) because it will be necessary for almost
6
+ # everything else later on.
7
+ #
8
+ tclInvoke set repository [repository]
9
+
10
+ #
11
+ # NOTE: Create some procedures in the Tcl interpreter to perform
12
+ # useful operations. This could also do things like load
13
+ # packages, etc.
14
+ #
15
+ tclEval {
16
+ #
17
+ # NOTE: Returns an [exec] command for Fossil, using the provided
18
+ # sub-command and arguments, suitable for use with [eval]
19
+ # or [catch].
20
+ #
21
+ proc getFossilCommand { repository user args } {
22
+ global env
23
+
24
+ lappend result exec [info nameofexecutable]
25
+
26
+ if {[info exists env(GATEWAY_INTERFACE)]} then {
27
+ #
28
+ # NOTE: This option is required when calling
29
+ # out to
--- a/test/fileStat.th1
+++ b/test/fileStat.th1
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
--- a/test/fileStat.th1
+++ b/test/fileStat.th1
@@ -0,0 +1,29 @@
1 <th1>
2 proc doSomeTclSetup {} {
3 #
4 # NOTE: Copy repository file name to the Tcl interpreter. This is
5 # done first (once) because it will be necessary for almost
6 # everything else later on.
7 #
8 tclInvoke set repository [repository]
9
10 #
11 # NOTE: Create some procedures in the Tcl interpreter to perform
12 # useful operations. This could also do things like load
13 # packages, etc.
14 #
15 tclEval {
16 #
17 # NOTE: Returns an [exec] command for Fossil, using the provided
18 # sub-command and arguments, suitable for use with [eval]
19 # or [catch].
20 #
21 proc getFossilCommand { repository user args } {
22 global env
23
24 lappend result exec [info nameofexecutable]
25
26 if {[info exists env(GATEWAY_INTERFACE)]} then {
27 #
28 # NOTE: This option is required when calling
29 # out to
+1 -1
--- test/tester.tcl
+++ test/tester.tcl
@@ -340,11 +340,11 @@
340340
set inFileName [file join $::tempPath [appendArgs test-http-in- $suffix]]
341341
set outFileName [file join $::tempPath [appendArgs test-http-out- $suffix]]
342342
set data [subst [read_file $dataFileName]]
343343
344344
write_file $inFileName $data
345
- fossil http $inFileName $outFileName 127.0.0.1 $repository
345
+ fossil http $inFileName $outFileName 127.0.0.1 $repository --localauth
346346
set result [expr {[file exists $outFileName] ? [read_file $outFileName] : ""}]
347347
348348
if {1} then {
349349
catch {file delete $inFileName}
350350
catch {file delete $outFileName}
351351
352352
ADDED test/th1-docs-input.txt
353353
ADDED test/th1-docs.test
--- test/tester.tcl
+++ test/tester.tcl
@@ -340,11 +340,11 @@
340 set inFileName [file join $::tempPath [appendArgs test-http-in- $suffix]]
341 set outFileName [file join $::tempPath [appendArgs test-http-out- $suffix]]
342 set data [subst [read_file $dataFileName]]
343
344 write_file $inFileName $data
345 fossil http $inFileName $outFileName 127.0.0.1 $repository
346 set result [expr {[file exists $outFileName] ? [read_file $outFileName] : ""}]
347
348 if {1} then {
349 catch {file delete $inFileName}
350 catch {file delete $outFileName}
351
352 DDED test/th1-docs-input.txt
353 DDED test/th1-docs.test
--- test/tester.tcl
+++ test/tester.tcl
@@ -340,11 +340,11 @@
340 set inFileName [file join $::tempPath [appendArgs test-http-in- $suffix]]
341 set outFileName [file join $::tempPath [appendArgs test-http-out- $suffix]]
342 set data [subst [read_file $dataFileName]]
343
344 write_file $inFileName $data
345 fossil http $inFileName $outFileName 127.0.0.1 $repository --localauth
346 set result [expr {[file exists $outFileName] ? [read_file $outFileName] : ""}]
347
348 if {1} then {
349 catch {file delete $inFileName}
350 catch {file delete $outFileName}
351
352 DDED test/th1-docs-input.txt
353 DDED test/th1-docs.test
--- a/test/th1-docs-input.txt
+++ b/test/th1-docs-input.txt
@@ -0,0 +1,4 @@
1
+GET ${url} HTTP/1.1
2
+Host: localhost
3
+User-Agent: Fossil
4
+
--- a/test/th1-docs-input.txt
+++ b/test/th1-docs-input.txt
@@ -0,0 +1,4 @@
 
 
 
 
--- a/test/th1-docs-input.txt
+++ b/test/th1-docs-input.txt
@@ -0,0 +1,4 @@
1 GET ${url} HTTP/1.1
2 Host: localhost
3 User-Agent: Fossil
4
--- a/test/th1-docs.test
+++ b/test/th1-docs.test
@@ -0,0 +1 @@
1
+thenthenthenset data [fossil info]
--- a/test/th1-docs.test
+++ b/test/th1-docs.test
@@ -0,0 +1 @@
 
--- a/test/th1-docs.test
+++ b/test/th1-docs.test
@@ -0,0 +1 @@
1 thenthenthenset data [fossil info]

Keyboard Shortcuts

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