Fossil SCM
Add tests for the TH1 docs feature.
Commit
71536a285116c644bf9ad784b3dc0a347a4bbd8f
Parent
8875c01abb6adf5…
6 files changed
+1
-1
+14
+29
+1
-1
+4
+1
+1
-1
| --- src/doc.c | ||
| +++ src/doc.c | ||
| @@ -640,11 +640,11 @@ | ||
| 640 | 640 | if( blob_size(&title)==0 ) blob_append(&title,zName,-1); |
| 641 | 641 | style_header("%s", blob_str(&title)); |
| 642 | 642 | blob_append(cgi_output_blob(), blob_buffer(&filebody),blob_size(&filebody)); |
| 643 | 643 | style_footer(); |
| 644 | 644 | #ifdef FOSSIL_ENABLE_TH1_DOCS |
| 645 | - }else if( db_get_boolean("th1-docs", 0) && | |
| 645 | + }else if( Th_AreDocsEnabled() && | |
| 646 | 646 | fossil_strcmp(zMime, "application/x-th1")==0 ){ |
| 647 | 647 | style_header("%h", zName); |
| 648 | 648 | Th_Render(blob_str(&filebody)); |
| 649 | 649 | style_footer(); |
| 650 | 650 | #endif |
| 651 | 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( 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 |
+14
| --- src/th_main.c | ||
| +++ src/th_main.c | ||
| @@ -1981,10 +1981,24 @@ | ||
| 1981 | 1981 | */ |
| 1982 | 1982 | if( TH_INIT_HOOK & TH_INIT_NEED_CONFIG ) Th_CloseConfig(1); |
| 1983 | 1983 | return rc; |
| 1984 | 1984 | } |
| 1985 | 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 | + | |
| 1986 | 2000 | |
| 1987 | 2001 | /* |
| 1988 | 2002 | ** The z[] input contains text mixed with TH1 scripts. |
| 1989 | 2003 | ** The TH1 scripts are contained within <th1>...</th1>. |
| 1990 | 2004 | ** TH1 variables are $aaa or $<aaa>. The first form of |
| 1991 | 2005 | |
| 1992 | 2006 | 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 |
+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 |
| --- 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 @@ | ||
| 340 | 340 | set inFileName [file join $::tempPath [appendArgs test-http-in- $suffix]] |
| 341 | 341 | set outFileName [file join $::tempPath [appendArgs test-http-out- $suffix]] |
| 342 | 342 | set data [subst [read_file $dataFileName]] |
| 343 | 343 | |
| 344 | 344 | 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 | |
| 346 | 346 | set result [expr {[file exists $outFileName] ? [read_file $outFileName] : ""}] |
| 347 | 347 | |
| 348 | 348 | if {1} then { |
| 349 | 349 | catch {file delete $inFileName} |
| 350 | 350 | catch {file delete $outFileName} |
| 351 | 351 | |
| 352 | 352 | ADDED test/th1-docs-input.txt |
| 353 | 353 | 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 |
+1
| --- 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] |