]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Generate and scan documentation output in Ddoc tests.
authoribuclaw <ibuclaw@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 9 Dec 2018 19:55:54 +0000 (19:55 +0000)
committeribuclaw <ibuclaw@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 9 Dec 2018 19:55:54 +0000 (19:55 +0000)
The tests in gdc.test/compilable/ddoc*.d don't require the module to be
compiled all the way down to object code.  Instead, only compile the
test sources with -fdoc, and scan the generated html content.

gcc/testsuite/ChangeLog:

PR d/88039
* gdc.test/gdc-test.exp (gdc-convert-args): Handle -D.
(dmd2dg): Check generated html in ddoc tests.
(gdc-do-test): Set dg-do-what-default to compile for ddoc tests.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@266933 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/testsuite/ChangeLog
gcc/testsuite/gdc.test/gdc-test.exp

index aac29ffe61416eec7d3e4705397a325cd0b9fcd0..043c5ea2ef289b45ca0df46a7bbb1bf62225d8b4 100644 (file)
@@ -1,3 +1,10 @@
+2018-12-09  Iain Buclaw  <ibuclaw@gdcproject.org>
+
+       PR d/88039
+       * gdc.test/gdc-test.exp (gdc-convert-args): Handle -D.
+       (dmd2dg): Check generated html in ddoc tests.
+       (gdc-do-test): Set dg-do-what-default to compile for ddoc tests.
+
 2018-12-09  Steven G. Kargl  <kargl@gcc.gnu.org>
 
        PR fortran/88206
index 246ac850a2079e199aa5467c026aedaaf3637a7d..7dd97d393ea0911e9666d3d338004f7773efaff1 100644 (file)
@@ -27,7 +27,10 @@ proc gdc-convert-args { args } {
 
     foreach arg [split [lindex $args 0] " "] {
         # List of switches kept in ASCII collated order.
-        if { [regexp -- {^-I([\w+/-]+)} $arg pattern path] } {
+        if [string match "-D" $arg] {
+            lappend out "-fdoc"
+
+        } elseif { [regexp -- {^-I([\w+/-]+)} $arg pattern path] } {
             lappend out "-I$path"
 
         } elseif { [regexp -- {^-J([\w+/-]+)} $arg pattern path] } {
@@ -183,6 +186,7 @@ proc dmd2dg { base test } {
 
     # Split base, folder/file.
     set type [file dirname $test]
+    set name [file tail $test]
 
     # print "Filename: $base - $test"
 
@@ -279,7 +283,7 @@ proc dmd2dg { base test } {
     # Compilable files are successful if an output is generated.
     # Fail compilable are successful if an output is not generated.
     # Runnable must compile, link, and return 0 to be successful by default.
-    switch [file dirname $test] {
+    switch $type {
         runnable {
             if ![isnative] {
                 set out_line "// { dg-final { output-exists } }"
@@ -290,6 +294,16 @@ proc dmd2dg { base test } {
         compilable {
             set out_line "// { dg-final { output-exists } }"
             puts $fdout $out_line
+
+            # Check that Ddoc tests also generate a html file.
+            if [regexp -- "ddoc.*" $name] {
+                set ddocfile "[file rootname $name].html"
+                set out_line "// { dg-final { scan-file $ddocfile \"Generated by Ddoc from $test\" } }"
+                puts $fdout $out_line
+                # Cleanup extra generated files.
+                set out_line "// { dg-final { file delete $ddocfile } }"
+                puts $fdout $out_line
+            }
         }
 
         fail_compilation {
@@ -389,8 +403,12 @@ proc gdc-do-test { } {
             compilable {
                 for { set i 0 } { $i<[llength $options] } { incr i } {
                     set flags [lindex $options $i]
-                    #set dg-do-what-default "compile"
-                    set dg-do-what-default "assemble"
+                    # Compilable test may require checking another kind of output file.
+                    if [regexp -- "ddoc.*" $name] {
+                        set dg-do-what-default "compile"
+                    } else {
+                        set dg-do-what-default "assemble"
+                    }
                     gdc-dg-runtest $filename $flags $imports
                 }
             }