public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [committed] testsuite: Split up gdc-test.exp into each subdirectory
@ 2020-03-29 15:32 Iain Buclaw
  2020-04-01 13:03 ` Rainer Orth
  0 siblings, 1 reply; 2+ messages in thread
From: Iain Buclaw @ 2020-03-29 15:32 UTC (permalink / raw)
  To: gcc-patches

Hi,

This patch splits up gdc-test.exp into multiple test scipts, one for
each subdirectory containing test files, instead of having one test
script to manage them all.

This allows removing some workarounds, such as the need to create
symlinks in the test run directory.

Tested on x86_64-linux-gnu, and committed to mainline.

Regards
Iain.
---

gcc/testsuite/ChangeLog:

2020-03-29  Iain Buclaw  <ibuclaw@gdcproject.org>

	* gdc.test/compilable/compilable.exp: New file.
	* gdc.test/fail_compilation/fail_compilation.exp: New file.
	* gdc.test/runnable/runnable.exp: New file.
	* gdc.test/gdc-test.exp: Move and rename to...
	* lib/gdc-utils.exp: ...this.  Remove load_lib gdc-dg.exp.
	(dmd2dg): Rename to...
	(gdc-convert-test): ...this.
	(gdc-do-test): Add testcases parameter and remove subdir handling.

---
 .../gdc.test/compilable/compilable.exp        | 30 ++++++++++++++
 .../fail_compilation/fail_compilation.exp     | 30 ++++++++++++++
 gcc/testsuite/gdc.test/runnable/runnable.exp  | 35 ++++++++++++++++
 .../gdc-test.exp => lib/gdc-utils.exp}        | 41 +++++--------------
 4 files changed, 106 insertions(+), 30 deletions(-)
 create mode 100644 gcc/testsuite/gdc.test/compilable/compilable.exp
 create mode 100644 gcc/testsuite/gdc.test/fail_compilation/fail_compilation.exp
 create mode 100644 gcc/testsuite/gdc.test/runnable/runnable.exp
 rename gcc/testsuite/{gdc.test/gdc-test.exp => lib/gdc-utils.exp} (94%)

diff --git a/gcc/testsuite/gdc.test/compilable/compilable.exp b/gcc/testsuite/gdc.test/compilable/compilable.exp
new file mode 100644
index 00000000000..e2af832ccc9
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/compilable.exp
@@ -0,0 +1,30 @@
+# Copyright (C) 2020 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3.  If not see
+# <http://www.gnu.org/licenses/>.
+
+# Compilable tests for the D2 testsuite.
+
+# Load support procs.
+load_lib gdc-dg.exp
+load_lib gdc-utils.exp
+
+# Initialize `dg'.
+dg-init
+
+# Main loop.
+gdc-do-test [glob -nocomplain $srcdir/$subdir/*.d]
+
+# All done.
+dg-finish
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail_compilation.exp b/gcc/testsuite/gdc.test/fail_compilation/fail_compilation.exp
new file mode 100644
index 00000000000..c5603086b52
--- /dev/null
+++ b/gcc/testsuite/gdc.test/fail_compilation/fail_compilation.exp
@@ -0,0 +1,30 @@
+# Copyright (C) 2020 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3.  If not see
+# <http://www.gnu.org/licenses/>.
+
+# Fail compilation tests for the D2 testsuite.
+
+# Load support procs.
+load_lib gdc-dg.exp
+load_lib gdc-utils.exp
+
+# Initialize `dg'.
+dg-init
+
+# Main loop.
+gdc-do-test [glob -nocomplain $srcdir/$subdir/*.d]
+
+# All done.
+dg-finish
diff --git a/gcc/testsuite/gdc.test/runnable/runnable.exp b/gcc/testsuite/gdc.test/runnable/runnable.exp
new file mode 100644
index 00000000000..af5d749f3b0
--- /dev/null
+++ b/gcc/testsuite/gdc.test/runnable/runnable.exp
@@ -0,0 +1,35 @@
+# Copyright (C) 2020 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3.  If not see
+# <http://www.gnu.org/licenses/>.
+
+# Runnable tests for the D2 testsuite.
+
+# Load support procs.
+load_lib gdc-dg.exp
+load_lib gdc-utils.exp
+
+# If the D runtime library is missing, bail.
+if { ![check_effective_target_d_runtime] } {
+    return
+}
+
+# Initialize `dg'.
+dg-init
+
+# Main loop.
+gdc-do-test [glob -nocomplain $srcdir/$subdir/*.d]
+
+# All done.
+dg-finish
diff --git a/gcc/testsuite/gdc.test/gdc-test.exp b/gcc/testsuite/lib/gdc-utils.exp
similarity index 94%
rename from gcc/testsuite/gdc.test/gdc-test.exp
rename to gcc/testsuite/lib/gdc-utils.exp
index 5554e218b50..298c6a733a6 100644
--- a/gcc/testsuite/gdc.test/gdc-test.exp
+++ b/gcc/testsuite/lib/gdc-utils.exp
@@ -15,8 +15,6 @@
 # <http://www.gnu.org/licenses/>.
 
 # Test using the DMD testsuite.
-# Load support procs.
-load_lib gdc-dg.exp
 
 #
 # Convert DMD arguments to GDC equivalent
@@ -183,7 +181,7 @@ proc gdc-copy-extra { base extra } {
 #   DISABLED:		Not handled.
 #
 
-proc dmd2dg { base test } {
+proc gdc-convert-test { base test } {
     global DEFAULT_DFLAGS
     global PERMUTE_ARGS
     global GDC_EXECUTE_ARGS
@@ -353,9 +351,11 @@ proc gdc-permute-options { options } {
     return $result
 }
 
+#
+# Main loop for running all tests for the subdirectory in gdc.test
+#
 
-proc gdc-do-test { } {
-    global srcdir subdir
+proc gdc-do-test { testcases } {
     global dg-do-what-default
     global verbose
 
@@ -375,9 +375,6 @@ proc gdc-do-test { } {
     # Additional arguments for gdc_load
     global GDC_EXECUTE_ARGS
 
-    # Initialize `dg'.
-    dg-init
-
     # Allow blank linkes in output for all of gdc.test.
     global allow_blank_lines
     set save_allow_blank_lines $allow_blank_lines
@@ -385,36 +382,25 @@ proc gdc-do-test { } {
 	set allow_blank_lines 2
     }
 
-    # Create gdc.test link so test names include that subdir.
-    catch { file link $subdir . }
+    set saved-dg-do-what-default ${dg-do-what-default}
 
     # Main loop.
 
     # set verbose 1
     # set dg-final-code ""
     # Find all tests and pass to routine.
-    foreach test [lsort [find $srcdir/$subdir *]] {
+    foreach test $testcases {
 	regexp -- "(.*)/(.+)/(.+)\.(.+)$" $test match base dir name ext
 
-	# Skip invalid test directory
-	if { [lsearch "runnable compilable fail_compilation" $dir] == -1 } {
-	    continue
-	}
-
-	# Skip invalid test extensions
-	if { [lsearch "d" $ext] == -1 } {
-	    continue
-	}
-
 	# Convert to DG test.
 	set imports [format "-I%s/%s" $base $dir]
 	set cleanup_extra_files ""
-	# Include $subdir prefix so test names follow DejaGnu conventions.
-	set filename "$subdir/[dmd2dg $base $dir/$name.$ext]"
+	set filename "[gdc-convert-test $base $dir/$name.$ext]"
 
 	if { $dir == "runnable" } {
 	    append PERMUTE_ARGS " $SHARED_OPTION"
 	}
+
 	set options [gdc-permute-options [lsort -unique $PERMUTE_ARGS]]
 
 	switch $dir {
@@ -454,16 +440,11 @@ proc gdc-do-test { } {
 
 	# Cleanup test directory.
 	foreach srcfile $cleanup_extra_files {
-	    file delete $subdir/$srcfile
+	    file delete $srcfile
 	}
 	file delete $filename
     }
 
+    set dg-do-what-default ${saved-dg-do-what-default}
     set allow_blank_lines $save_allow_blank_lines
-
-    # All done.
-    dg-finish
 }
-
-gdc-do-test
-
-- 
2.20.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [committed] testsuite: Split up gdc-test.exp into each subdirectory
  2020-03-29 15:32 [committed] testsuite: Split up gdc-test.exp into each subdirectory Iain Buclaw
@ 2020-04-01 13:03 ` Rainer Orth
  0 siblings, 0 replies; 2+ messages in thread
From: Rainer Orth @ 2020-04-01 13:03 UTC (permalink / raw)
  To: Iain Buclaw via Gcc-patches

Hi Iain,

> This patch splits up gdc-test.exp into multiple test scipts, one for
> each subdirectory containing test files, instead of having one test
> script to manage them all.
>
> This allows removing some workarounds, such as the need to create
> symlinks in the test run directory.

unfortunately this caused the gdc.test test names to lose their subdir
prefix again: instead of

-FAIL: gdc.test/runnable/eh.d -fPIC -shared-libphobos   execution test

you now have

+FAIL: runnable/eh.d -fPIC -shared-libphobos   execution test

without the gdc.test.  Since testnames are supposed to be relative to
gcc/testsuite, this needs to be fixed.

	Rainer
 
-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-04-01 13:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-29 15:32 [committed] testsuite: Split up gdc-test.exp into each subdirectory Iain Buclaw
2020-04-01 13:03 ` Rainer Orth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).