Excerpts from Iain Buclaw's message of January 7, 2021 6:48 pm:
> Excerpts from Rainer Orth's message of January 7, 2021 5:17 pm:
>> Hi Iain,
>> 
>>>> The Solaris assemblers don't support UTF-8 identifiers.  Unless gdc can
>>>> encode them in some way for toolchains like this (no idea if this is
>>>> worth the effort), it may be possible to guard the tests with the ucn
>>>> effective-target keyword.
>>>> 
>>>> Apart from that, it seems strange that the failing tests should only
>>>> show up as UNSUPPORTED.  I'd have expected the compilation to FAIL, but
>>>> IIRC the gdc testsuite has to ignore all output, so the test for excess
>>>> errors which would usually catch this is disabled effectively.
>>>
>>> Indeed, the testsuite is far too verbose.  Although many tests have a
>>> TEST_OUTPUT directive, converting them to a Dejagnu style is probably
>>> too much effort for the gain.
>>>
>>> Those tests can just be explicitly disabled, I'll look into that.
>> 
>> Great, thanks.
>> 

Having a look, actually I can just use the presence of TEST_OUTPUT to be
a gate for whether to prune all output or not.

Maybe this can be improved later to extract the contents of TEST_OUTPUT,
but for now, it has caught a few hidden bugs in the tests that I have
handled in the patch below (no changelog entry yet).

Iain.

---

diff --git a/gcc/testsuite/lib/gdc-utils.exp b/gcc/testsuite/lib/gdc-utils.exp
index 6d4a15e9a67..3d9fd401ee8 100644
--- a/gcc/testsuite/lib/gdc-utils.exp
+++ b/gcc/testsuite/lib/gdc-utils.exp
@@ -173,6 +173,27 @@ proc gdc-copy-extra { base extra } {
     return $extra
 }
 
+#
+# Some tests in the DMD testsuite have specific target requirements,
+# handle them explicitly here.
+#
+
+proc gdc-extra-test-options { fdout test } {
+    switch $test {
+       "runnable/mangle.d" -
+       "runnable/testmodule.d" -
+       "runnable/ufcs.d" {
+           # Tests that require effective-target-ucn
+           puts $fdout "// { dg-skip-if \"\" { ! ucn } }"
+       }
+
+       "runnable/test42.d" {
+           # Tests that overflow line limits of older assemblers.
+           puts $fdout "// { dg-xfail-if \"Lines exceed 10240 characters\" { 
*-*-solaris2.* && { ! gas } } }"
+       }
+    }
+}
+
 #
 # Translate DMD test directives to dejagnu equivalent.
 #
@@ -209,8 +230,10 @@ proc gdc-convert-test { base test } {
 
     set extra_sources ""
     set extra_files ""
+    set ddoc_options ""
     set needs_phobos 0
     set saw_test_flags 0
+    set saw_test_output 0
 
     upvar 1 compilable_do_what compilable_do_what
     set compilable_output_file_ext ""
@@ -243,6 +266,14 @@ proc gdc-convert-test { base test } {
            # LINK sets dg-do-what-default "link"
            set compilable_do_what "link"
 
+       } elseif [regexp -- {TEST_OUTPUT} $copy_line] {
+           # TEST_OUTPUT contents are ignored, but it might be possible to
+           # convert it into a series of either dg-prune or dg-errors.
+           # Currently, only saw_test_output is set so that dg-prune is
+           # added before running the test.
+           regsub -- {TEST_OUTPUT.*$} $copy_line "" out_line
+           set saw_test_output 1
+
        } elseif [regexp -- {POST_SCRIPT} $copy_line] {
            # POST_SCRIPT is not handled
            regsub -- {POST_SCRIPT.*$} $copy_line "" out_line
@@ -276,7 +307,15 @@ proc gdc-convert-test { base test } {
        } elseif [regexp -- {EXTRA_SOURCES\s*:\s*(.*)} $copy_line match 
sources] {
            # EXTRA_SOURCES are appended to extra_sources list
            foreach srcfile $sources {
-               lappend extra_sources $srcfile
+               # Ddoc files are not handled by the compiler directly, they are
+               # instead passed in using -fdoc-inc=
+               if [regexp -- {\.ddoc$} $srcfile extmatch] {
+                   lappend extra_files $srcfile
+                   lappend ddoc_options "-fdoc-inc=$type/$srcfile"
+
+               } else {
+                   lappend extra_sources $srcfile
+               }
            }
            regsub -- {EXTRA_SOURCES.*$} $copy_line "" out_line
 
@@ -311,7 +350,7 @@ proc gdc-convert-test { base test } {
        } elseif [regexp -- {COMPILABLE_MATH_TEST} $copy_line match sources] {
            # COMPILABLE_MATH_TEST annotates tests that import the std.math
            # module.  Which will need skipping if not available on the target.
-           regsub -- {RUNNABLE_PHOBOS_TEST.*$} $copy_line "" out_line
+           regsub -- {COMPILABLE_MATH_TEST.*$} $copy_line "" out_line
            set needs_phobos 1
        }
 
@@ -334,11 +373,17 @@ proc gdc-convert-test { base test } {
        puts $fdout "// { dg-additional-files \"$extra_files\" }"
     }
 
+    if { [llength $ddoc_options] > 0 } {
+       puts $fdout "// { dg-additional-options \"$ddoc_options\" }"
+    }
+
     # Add specific options for test type
 
     # DMD's testsuite is extremely verbose, compiler messages from constructs
     # such as pragma(msg, ...) would otherwise cause tests to fail.
-    puts $fdout "// { dg-prune-output .* }"
+    if $saw_test_output {
+       puts $fdout "// { dg-prune-output .* }"
+    }
 
     # Compilable files are successful if an output is generated.
     # Fail compilable are successful if an output is not generated.
@@ -357,6 +402,11 @@ proc gdc-convert-test { base test } {
            if !$saw_test_flags {
                set PERMUTE_ARGS $DEFAULT_DFLAGS
            }
+           # Tests mix C++ and D, but not all test options are common between
+           # the two front-end languages.
+           if { $type == "runnable_cxx" } {
+               puts $fdout "// { dg-prune-output \"'-frelease' is valid for D 
but not for C\" }"
+           }
        }
 
        compilable {
@@ -384,6 +434,8 @@ proc gdc-convert-test { base test } {
        }
     }
 
+    gdc-extra-test-options $fdout $test
+
     close $fdin
     close $fdout
 

Reply via email to