foreach arg [split [lindex $args 0] " "] {
# List of switches kept in ASCII collated order.
if [string match "-D" $arg] {
+ upvar 1 compilable_output_file_ext compilable_output_file_ext
+ set compilable_output_file_ext "html"
lappend out "-fdoc"
+ } elseif [string match "-H" $arg] {
+ upvar 1 compilable_output_file_ext compilable_output_file_ext
+ set compilable_output_file_ext "di"
+ lappend out "-H"
+
} elseif { [regexp -- {^-I([\w+/-]+)} $arg pattern path] } {
lappend out "-I$path"
} elseif { [regexp -- {^-J([\w+/-]+)} $arg pattern path] } {
lappend out "-J$path"
+ } elseif [string match "-X" $arg] {
+ upvar 1 compilable_output_file_ext compilable_output_file_ext
+ set compilable_output_file_ext "json"
+ lappend out "-X"
+
} elseif [string match "-allinst" $arg] {
lappend out "-fall-instantiations"
# COMPILED_IMPORTS: List of modules files that are imported by the main
# source file that should be included in compilation.
# Currently handled the same as EXTRA_SOURCES.
+# DFLAGS: Overrides the DFLAGS environment variable if specified
+# in the test. No values are permitted; an error will be
+# emitted if the value is not empty.
# EXTRA_SOURCES: List of extra sources to build and link along with
# the test.
+# EXTRA_CPP_SOURCES: List of extra C++ files to build and link along with
+# the test.
# EXTRA_FILES: List of extra files to copy for the test runs.
# PERMUTE_ARGS: The set of arguments to permute in multiple compiler
# invocations. An empty set means only one permutation
set extra_sources ""
set extra_files ""
+ upvar 1 compilable_do_what compilable_do_what
+ set compilable_output_file_ext ""
+
# Split base, folder/file.
set type [file dirname $test]
set name [file tail $test]
# POST_SCRIPT is not handled
regsub -- {POST_SCRIPT.*$} $copy_line "" out_line
+ } elseif [regexp -- {DFLAGS\s*:\s*(.*)} $copy_line match args] {
+ # DFLAGS overrides the default value of PERMUTE_ARGS.
+ if { $args != "" } {
+ error "gdc-convert-test: DFLAGS is not empty as expected"
+ }
+ if { $PERMUTE_ARGS == $DEFAULT_DFLAGS } {
+ set PERMUTE_ARGS ""
+ }
+ regsub -- {DFLAGS.*$} $copy_line "" out_line
+
} elseif [regexp -- {PERMUTE_ARGS\s*:\s*(.*)} $copy_line match args] {
# PERMUTE_ARGS is handled by gdc-do-test.
set PERMUTE_ARGS [gdc-convert-args $args]
foreach srcfile $extra_sources {
gdc-copy-extra $base "$type/$srcfile"
}
- set out_line "// { dg-additional-sources \"$extra_sources\" }"
- puts $fdout $out_line
+ puts $fdout "// { dg-additional-sources \"$extra_sources\" }"
}
if { [llength $extra_files] > 0 } {
foreach file $extra_files {
gdc-copy-extra $base "$type/$file"
}
- set out_line "// { dg-additional-files \"$extra_files\" }"
- puts $fdout $out_line
+ puts $fdout "// { dg-additional-files \"$extra_files\" }"
}
# 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.
- set out_line "// { dg-prune-output .* }"
- puts $fdout $out_line
+ puts $fdout "// { dg-prune-output .* }"
# Compilable files are successful if an output is generated.
# Fail compilable are successful if an output is not generated.
switch $type {
runnable {
if ![isnative] {
- set out_line "// { dg-final { output-exists } }"
- puts $fdout $out_line
+ puts $fdout "// { dg-final { output-exists } }"
}
}
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
+ puts $fdout "// { dg-final { output-exists } }"
+
+ # Compilable test may require checking another kind of output file.
+ if { $compilable_output_file_ext != "" } {
+ set compilable_do_what "compile"
+ # Check that file generation tests output the expected file.
+ set genfile "[file rootname $name].$compilable_output_file_ext"
+ puts $fdout "// { dg-final { if \[file exists $genfile\] \\{ } }"
+ puts $fdout "// { dg-final { pass \"$test (file exists $genfile)\" } }"
+ puts $fdout "// { dg-final { \\} else \\{ } }"
+ puts $fdout "// { dg-final { fail \"$test (file exists $genfile)\" } }"
+ puts $fdout "// { dg-final { \\} } }"
# Cleanup extra generated files.
- set out_line "// { dg-final { file delete $ddocfile } }"
- puts $fdout $out_line
+ puts $fdout "// { dg-final { file delete $genfile } }"
}
}
fail_compilation {
- set out_line "// { dg-final { output-exists-not } }"
- puts $fdout $out_line
+ puts $fdout "// { dg-final { output-exists-not } }"
}
}
# Convert to DG test.
set imports [format "-I%s/%s" $base $dir]
set cleanup_extra_files ""
+ set compilable_do_what "assemble"
set filename "[gdc-convert-test $base $dir/$name.$ext]"
if { $dir == "runnable" } {
compilable {
for { set i 0 } { $i<[llength $options] } { incr i } {
set flags [lindex $options $i]
- # 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"
- }
+ set dg-do-what-default $compilable_do_what
gdc-dg-runtest $filename $flags $imports
}
}