Hi! Here is an attempt to fix gfortran dg.exp testing in case of very fine-grained parallelization. So far tested just with make check-gfortran "RUNTESTFLAGS=dg.exp='binding_label_tests_10_main.f03 binding_label_tests_11_main.f03 binding_label_tests_13_main.f03 binding_label_tests_26b.f90 coarray_29_2.f90 test_common_binding_labels_2_main.f03 test_common_binding_labels_3_main.f03 whole_file_29.f90 whole_file_31.f90 class_45b.f03 class_4a.f03'" and make check-gfortran "RUNTESTFLAGS=dg.exp='binding_label_tests_10.f03 binding_label_tests_11.f03 binding_label_tests_13.f03 binding_label_tests_26a.f90 coarray_29_1.f90 test_common_binding_labels_2.f03 test_common_binding_labels_3.f03 whole_file_28.f90 whole_file_30.f90 class_45a.f03 class_4b.f03 class_4c.f03'" where the latter would keep around tons of non-cleaned up modules and the former would mostly fail. The patch introduces a new dg-compile-aux-modules directive which instructs dejagnu to compile the in there named test first (that test shouldn't need to have keep-modules; but you probably need cleanup-modules in the test that uses dg-compile-aux-modules because the tests won't be automatically discovered (perhaps can be changed later)).
2014-09-15 Jakub Jelinek <ja...@redhat.com> PR fortran/56408 * gfortran.dg/dg.exp (gfortran_test_path, gfortran_aux_module_flags): New global vars. (dg-compile-aux-modules): New procedure. * gfortran.dg/binding_label_tests_10.f03: Remove comment and keep-modules. * gfortran.dg/binding_label_tests_10_main.f03: Remove comment, use dg-compile-aux-modules. * gfortran.dg/binding_label_tests_11.f03: Remove comment and keep-modules. * gfortran.dg/binding_label_tests_11_main.f03: Remove comment, use dg-compile-aux-modules. * gfortran.dg/binding_label_tests_13.f03: Remove comment and keep-modules. * gfortran.dg/binding_label_tests_13_main.f03: Remove comment, use dg-compile-aux-modules. * gfortran.dg/binding_label_tests_26a.f90: Remove comment and keep-modules. * gfortran.dg/binding_label_tests_26b.f90: Remove comment, use dg-compile-aux-modules. * gfortran.dg/class_45a.f03: Remove keep-modules. * gfortran.dg/class_45b.f03: Use dg-compile-aux-modules and cleanup-modules. * gfortran.dg/class_4a.f03: Use dg-do link, use dg-additional-sources and cleanup-modules, remove keep-modules and update comment. * gfortran.dg/class_4b.f03: Don't compile anywhere, remove keep-modules, adjust comment. * gfortran.dg/class_4c.f03: Don't compile anywhere, remove dg-additional-sources and cleanup-modules. * gfortran.dg/coarray_29_1.f90: Remove keep-modules and associated comment. * gfortran.dg/coarray_29_2.f90: Use dg-compile-aux-modules, remove comment. * gfortran.dg/test_common_binding_labels_2.f03: Remove keep-modules. * gfortran.dg/test_common_binding_labels_2_main.f03: Remove comment, use dg-compile-aux-modules. * gfortran.dg/test_common_binding_labels_3.f03: Remove keep-modules. * gfortran.dg/test_common_binding_labels_3_main.f03: Remove comment, use dg-compile-aux-modules. * gfortran.dg/whole_file_28.f90: Remove comment and keep-modules. * gfortran.dg/whole_file_29.f90: Remove comment, use dg-compile-aux-modules. * gfortran.dg/whole_file_30.f90: Remove comment and keep-modules. * gfortran.dg/whole_file_31.f90: Remove comment, use dg-compile-aux-modules. --- gcc/testsuite/gfortran.dg/dg.exp.jj 2014-07-04 10:20:35.000000000 +0200 +++ gcc/testsuite/gfortran.dg/dg.exp 2014-09-15 17:05:04.038126245 +0200 @@ -28,6 +28,21 @@ if ![info exists DEFAULT_FFLAGS] then { # Initialize `dg'. dg-init +global gfortran_test_path +global gfortran_aux_module_flags +set gfortran_test_path $srcdir/$subdir +set gfortran_aux_module_flags $DEFAULT_FFLAGS +proc dg-compile-aux-modules { args } { + global gfortran_test_path + global gfortran_aux_module_flags + if { [llength $args] != 2 } { + error "dg-set-target-env-var: needs one argument" + return + } + dg-test $gfortran_test_path/[lindex $args 1] "" $gfortran_aux_module_flags + # cleanup-modules isn't intentionally invoked here. +} + # Main loop. gfortran-dg-runtest [lsort \ [glob -nocomplain $srcdir/$subdir/*.\[fF\]{,90,95,03,08} ] ] "" $DEFAULT_FFLAGS --- gcc/testsuite/gfortran.dg/binding_label_tests_10.f03.jj 2012-03-20 08:51:24.000000000 +0100 +++ gcc/testsuite/gfortran.dg/binding_label_tests_10.f03 2014-09-15 16:50:57.710322608 +0200 @@ -1,9 +1,6 @@ ! { dg-do compile } -! This file must be compiled BEFORE binding_label_tests_10_main.f03, which it -! should be because dejagnu will sort the files. module binding_label_tests_10 use iso_c_binding implicit none integer(c_int), bind(c,name="c_one") :: one end module binding_label_tests_10 -! { dg-final { keep-modules "" } } --- gcc/testsuite/gfortran.dg/binding_label_tests_10_main.f03.jj 2014-01-13 08:54:27.000000000 +0100 +++ gcc/testsuite/gfortran.dg/binding_label_tests_10_main.f03 2014-09-15 17:05:57.810859201 +0200 @@ -1,6 +1,5 @@ ! { dg-do compile } -! This file must be compiled AFTER binding_label_tests_10.f03, which it -! should be because dejagnu will sort the files. +! { dg-compile-aux-modules "binding_label_tests_10.f03" } module binding_label_tests_10_main use iso_c_binding implicit none --- gcc/testsuite/gfortran.dg/binding_label_tests_11.f03.jj 2012-03-20 08:51:24.000000000 +0100 +++ gcc/testsuite/gfortran.dg/binding_label_tests_11.f03 2014-09-15 17:07:15.888471110 +0200 @@ -1,6 +1,4 @@ ! { dg-do compile } -! This file must be compiled BEFORE binding_label_tests_11_main.f03, which it -! should be because dejagnu will sort the files. module binding_label_tests_11 use iso_c_binding, only: c_int implicit none @@ -10,4 +8,3 @@ contains one = 1 end function one end module binding_label_tests_11 -! { dg-final { keep-modules "" } } --- gcc/testsuite/gfortran.dg/binding_label_tests_11_main.f03.jj 2013-05-21 09:43:19.000000000 +0200 +++ gcc/testsuite/gfortran.dg/binding_label_tests_11_main.f03 2014-09-15 17:07:02.149538779 +0200 @@ -1,6 +1,5 @@ ! { dg-do compile } -! This file must be compiled AFTER binding_label_tests_11.f03, which it -! should be because dejagnu will sort the files. +! { dg-compile-aux-modules "binding_label_tests_11.f03" } module binding_label_tests_11_main use iso_c_binding, only: c_int implicit none --- gcc/testsuite/gfortran.dg/binding_label_tests_13.f03.jj 2012-03-20 08:51:24.000000000 +0100 +++ gcc/testsuite/gfortran.dg/binding_label_tests_13.f03 2014-09-15 17:07:25.603422353 +0200 @@ -1,9 +1,6 @@ ! { dg-do compile } -! This file must be compiled BEFORE binding_label_tests_13_main.f03, which it -! should be because dejagnu will sort the files. module binding_label_tests_13 use, intrinsic :: iso_c_binding, only: c_int integer(c_int) :: c3 bind(c) c3 end module binding_label_tests_13 -! { dg-final { keep-modules "" } } --- gcc/testsuite/gfortran.dg/binding_label_tests_13_main.f03.jj 2013-05-21 09:43:20.000000000 +0200 +++ gcc/testsuite/gfortran.dg/binding_label_tests_13_main.f03 2014-09-15 17:07:52.815288018 +0200 @@ -1,7 +1,5 @@ ! { dg-do compile } -! This file must be compiled AFTER binding_label_tests_13.f03, which it -! should be because dejagnu will sort the files. The module file -! binding_label_tests_13.mod can not be removed until after this test is done. +! { dg-compile-aux-modules "binding_label_tests_13.f03" } module binding_label_tests_13_main use, intrinsic :: iso_c_binding, only: c_int integer(c_int) :: c3 ! { dg-error "Variable c3 from module binding_label_tests_13_main with binding label c3 at .1. uses the same global identifier as entity at .2. from module binding_label_tests_13" } --- gcc/testsuite/gfortran.dg/binding_label_tests_26a.f90.jj 2014-01-08 17:45:05.000000000 +0100 +++ gcc/testsuite/gfortran.dg/binding_label_tests_26a.f90 2014-09-15 17:08:27.768112809 +0200 @@ -4,8 +4,6 @@ ! ! Contributed by Andrew Bensons <abenso...@gmail.com> ! -! This file must be compiled BEFORE binding_label_tests_26b.f90, which it -! should be because dejagnu will sort the files. module fg contains @@ -16,5 +14,3 @@ contains end interface end function end module - -! { dg-final { keep-modules "" } } --- gcc/testsuite/gfortran.dg/binding_label_tests_26b.f90.jj 2014-01-08 17:45:05.000000000 +0100 +++ gcc/testsuite/gfortran.dg/binding_label_tests_26b.f90 2014-09-15 17:08:58.460961242 +0200 @@ -1,11 +1,9 @@ ! { dg-do compile } +! { dg-compile-aux-modules "binding_label_tests_26a.f90" } ! ! PR 58182: [4.9 Regression] ICE with global binding name used as a FUNCTION ! ! Contributed by Andrew Bensons <abenso...@gmail.com> -! -! This file must be compiled AFTER binding_label_tests_26a.f90, which it -! should be because dejagnu will sort the files. module f ! { dg-error "uses the same global identifier" } use fg ! { dg-error "uses the same global identifier" } --- gcc/testsuite/gfortran.dg/class_45a.f03.jj 2012-03-20 08:51:24.000000000 +0100 +++ gcc/testsuite/gfortran.dg/class_45a.f03 2014-09-15 17:15:52.800901905 +0200 @@ -26,4 +26,3 @@ contains end function basicGet end module G_Nodes -! { dg-final { keep-modules "" } } --- gcc/testsuite/gfortran.dg/class_45b.f03.jj 2012-05-17 08:40:32.000000000 +0200 +++ gcc/testsuite/gfortran.dg/class_45b.f03 2014-09-15 17:17:03.854547243 +0200 @@ -1,5 +1,5 @@ ! { dg-do link } -! { dg-additional-sources class_45a.f03 } +! { dg-compile-aux-modules "class_45a.f03" } ! ! PR 50227: [4.7 Regression] [OOP] ICE-on-valid with allocatable class variable ! @@ -10,3 +10,4 @@ program Test class(t0), allocatable :: c allocate(t1 :: c) end program Test +! { dg-final { cleanup-modules "G_Nodes" } } --- gcc/testsuite/gfortran.dg/class_4a.f03.jj 2012-03-20 08:51:24.000000000 +0100 +++ gcc/testsuite/gfortran.dg/class_4a.f03 2014-09-15 17:23:35.315599421 +0200 @@ -1,10 +1,11 @@ -! { dg-do compile } +! { dg-do link } +! { dg-additional-sources "class_4b.f03 class_4c.f03" } ! ! Test the fix for PR41583, in which the different source files ! would generate the same 'vindex' for different class declared ! types. ! -! The test comprises class_4a, class_4b class_4c and class_4d.f03 +! The test comprises class_4a, class_4b and class_4c.f03 ! Contributed by Tobias Burnus <bur...@gcc.gnu.org> ! @@ -12,4 +13,4 @@ module m type t end type t end module m -! { dg-final { keep-modules "m" } } +! { dg-final { cleanup-modules "m m2" } } --- gcc/testsuite/gfortran.dg/class_4b.f03.jj 2012-03-20 08:51:24.000000000 +0100 +++ gcc/testsuite/gfortran.dg/class_4b.f03 2014-09-15 16:08:50.064931051 +0200 @@ -1,10 +1,11 @@ -! { dg-do compile } +! Don't compile this anywhere. +! { dg-do compile { target { lp64 && { ! lp64 } } } } ! ! Test the fix for PR41583, in which the different source files ! would generate the same 'vindex' for different class declared ! types. ! -! The test comprises class_4a, class_4b class_4c and class_4d.f03 +! The test comprises class_4a, class_4b class_4c.f03 ! ! Contributed by Tobias Burnus <bur...@gcc.gnu.org> ! @@ -13,4 +14,3 @@ module m2 type, extends(t) :: t2 end type t2 end module m2 -! { dg-final { keep-modules "m2" } } --- gcc/testsuite/gfortran.dg/class_4c.f03.jj 2012-03-20 08:51:24.000000000 +0100 +++ gcc/testsuite/gfortran.dg/class_4c.f03 2014-09-15 16:08:33.870010430 +0200 @@ -1,5 +1,5 @@ -! { dg-do link } -! { dg-additional-sources class_4a.f03 class_4b.f03 } +! Don't compile this anywhere. +! { dg-do compile { target { lp64 && { ! lp64 } } } } ! ! Test the fix for PR41583, in which the different source files ! would generate the same 'vindex' for different class declared @@ -27,4 +27,3 @@ end select print *, i end -! { dg-final { cleanup-modules "m m2" } } --- gcc/testsuite/gfortran.dg/coarray_29_1.f90.jj 2012-11-12 16:58:41.000000000 +0100 +++ gcc/testsuite/gfortran.dg/coarray_29_1.f90 2014-09-15 17:12:01.948048800 +0200 @@ -11,6 +11,3 @@ contains integer scalar[*] end subroutine end module - -! DO NOT CLEAN UP THE MODULE FILE - coarray_29_2.f90 does it. -! { dg-final { keep-modules "" } } --- gcc/testsuite/gfortran.dg/coarray_29_2.f90.jj 2013-01-15 09:04:48.000000000 +0100 +++ gcc/testsuite/gfortran.dg/coarray_29_2.f90 2014-09-15 17:12:49.177813702 +0200 @@ -1,8 +1,6 @@ ! { dg-do compile } ! { dg-options "-fcoarray=single" } - -! Requires that coarray_29.f90 has been compiled before -! and that, thus, co_sum_module is available +! { dg-compile-aux-modules "coarray_29_1.f90" } ! PR fortran/55272 ! --- gcc/testsuite/gfortran.dg/test_common_binding_labels_2.f03.jj 2012-03-20 08:51:24.000000000 +0100 +++ gcc/testsuite/gfortran.dg/test_common_binding_labels_2.f03 2014-09-15 17:13:13.777692033 +0200 @@ -12,4 +12,3 @@ module test_common_binding_labels_2 integer(c_int) :: i bind(c, name="") /com2/ end module test_common_binding_labels_2 -! { dg-final { keep-modules "" } } --- gcc/testsuite/gfortran.dg/test_common_binding_labels_2_main.f03.jj 2013-05-21 09:43:20.000000000 +0200 +++ gcc/testsuite/gfortran.dg/test_common_binding_labels_2_main.f03 2014-09-15 17:13:49.344513701 +0200 @@ -1,9 +1,7 @@ ! { dg-do compile } ! { dg-options "-std=f2003" } +! { dg-compile-aux-modules "test_common_binding_labels_2.f03" } ! -! -! This file depends on the module test_common_binding_labels_2. That module -! must be compiled first and not be removed until after this test. module test_common_binding_labels_2_main use, intrinsic :: iso_c_binding, only: c_double, c_int implicit none --- gcc/testsuite/gfortran.dg/test_common_binding_labels_3.f03.jj 2012-03-20 08:51:24.000000000 +0100 +++ gcc/testsuite/gfortran.dg/test_common_binding_labels_3.f03 2014-09-15 17:13:18.355668395 +0200 @@ -8,4 +8,3 @@ module test_common_binding_labels_3 real(c_double) :: s bind(c, name="my_common_block") :: /mycom/ end module test_common_binding_labels_3 -! { dg-final { keep-modules "" } } --- gcc/testsuite/gfortran.dg/test_common_binding_labels_3_main.f03.jj 2013-05-21 09:43:20.000000000 +0200 +++ gcc/testsuite/gfortran.dg/test_common_binding_labels_3_main.f03 2014-09-15 17:14:01.655453621 +0200 @@ -1,6 +1,5 @@ ! { dg-do compile } -! This file depends on the module test_common_binding_labels_3. That module -! must be compiled first and not be removed until after this test. +! { dg-compile-aux-modules "test_common_binding_labels_3.f03" } module test_common_binding_labels_3_main use, intrinsic :: iso_c_binding, only: c_int integer(c_int), bind(c, name="my_common_block") :: my_int ! { dg-error "COMMON block at .1. with binding label my_common_block uses the same global identifier as entity at .2." } --- gcc/testsuite/gfortran.dg/whole_file_28.f90.jj 2012-03-20 08:51:24.000000000 +0100 +++ gcc/testsuite/gfortran.dg/whole_file_28.f90 2014-09-15 17:15:09.217117852 +0200 @@ -1,6 +1,5 @@ ! { dg-do compile } ! Test the fix for the problem described in PR45077 comments #4 and #5. -! Note that the module file is kept for whole_file_29.f90 ! ! Contributed by Tobias Burnus <bur...@gcc.gnu.org> ! @@ -9,5 +8,3 @@ module iso_red character(LEN=1), dimension(:), allocatable :: chars end type varying_string end module iso_red -! DO NOT CLEAN UP THE MODULE FILE - whole_file_29.f90 does it. -! { dg-final { keep-modules "" } } --- gcc/testsuite/gfortran.dg/whole_file_29.f90.jj 2012-03-20 08:51:24.000000000 +0100 +++ gcc/testsuite/gfortran.dg/whole_file_29.f90 2014-09-15 17:14:56.401181922 +0200 @@ -1,7 +1,6 @@ ! { dg-do compile } +! { dg-compile-aux-modules "whole_file_28.f90" } ! Test the fix for the problem described in PR45077 comments #4 and #5. -! Note that the module file from whole_file_28.f90, 'iso_red', is -! needed for this test. ! ! Contributed by Tobias Burnus <bur...@gcc.gnu.org> ! --- gcc/testsuite/gfortran.dg/whole_file_30.f90.jj 2012-03-20 08:51:24.000000000 +0100 +++ gcc/testsuite/gfortran.dg/whole_file_30.f90 2014-09-15 17:15:04.512141212 +0200 @@ -1,6 +1,5 @@ ! { dg-do compile } ! Test the fix for the problem described in PR46818. -! Note that the module file is kept for whole_file_31.f90 ! ! Contributed by Martien Hulsen <m.a.hul...@tue.nl> ! and reduced by Tobias Burnus <bur...@gcc.gnu.org> @@ -12,5 +11,3 @@ module system_defs_m real, allocatable, dimension(:) :: u end type sysvector_t end module system_defs_m -! DO NOT CLEAN UP THE MODULE FILE - whole_file_31.f90 does it. -! { dg-final { keep-modules "" } } --- gcc/testsuite/gfortran.dg/whole_file_31.f90.jj 2012-03-20 08:51:24.000000000 +0100 +++ gcc/testsuite/gfortran.dg/whole_file_31.f90 2014-09-15 17:15:23.347047734 +0200 @@ -1,7 +1,6 @@ ! { dg-do compile } +! { dg-compile-aux-modules "whole_file_30.f90" } ! Test the fix for the problem described in PR46818. -! Note that the module file from whole_file_30.f90, 'system_defs_m', -! is needed for this test. ! ! Contributed by Martien Hulsen <m.a.hul...@tue.nl> ! and reduced by Tobias Burnus <bur...@gcc.gnu.org> Jakub