From: Stefano Lattarini Date: Wed, 14 Sep 2011 12:58:05 +0000 (+0200) Subject: automake: remove code duplication in 'handle_tests' X-Git-Tag: ng-0.5a~89^2~42^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1e90abcc6da204b8ac0c9b53a5acda75c2b07204;p=thirdparty%2Fautomake.git automake: remove code duplication in 'handle_tests' * automake.in (handle_tests): Factor out some code dealing with test extensions and rules for generation of `.log' files into ... (handle_per_suffix_test): ... this new subroutine. * tests/parallel-tests-exeext.test: New test. * tests/Makefile.am (TESTS): Update. --- diff --git a/ChangeLog b/ChangeLog index 11b8bb750..ecde3d628 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2011-09-15 Stefano Lattarini + + automake: remove code duplication in 'handle_tests' + * automake.in (handle_tests): Factor out some code dealing with + test extensions and rules for generation of `.log' files into ... + (handle_per_suffix_test): ... this new subroutine. + * tests/parallel-tests-exeext.test: New test. + * tests/Makefile.am (TESTS): Update. + 2011-09-11 Stefano Lattarini tests: fix spurious failure on fast machines diff --git a/automake.in b/automake.in index cbf82e182..677e1faf5 100644 --- a/automake.in +++ b/automake.in @@ -4793,6 +4793,57 @@ sub handle_tests_dejagnu $output_rules .= file_contents ('dejagnu', new Automake::Location); } +sub handle_per_suffix_test +{ + my ($test_suffix, %transform) = @_; + my ($pfx, $generic, $parallel_tests_option, $am_exeext); + prog_error ("called with 'parallel-tests' option not set") + unless $parallel_tests_option = option 'parallel-tests'; + if ($test_suffix eq '') + { + $pfx = ''; + $generic = 0; + $am_exeext = 'FALSE'; + } + else + { + prog_error ("test suffix `$test_suffix' lacks leading dot") + unless $test_suffix =~ m/^\.(.*)/; + $pfx = uc ($1) . '_'; + $generic = 1; + $am_exeext = exists $configure_vars{'EXEEXT'} ? 'am__EXEEXT' + : 'FALSE'; + } + # The "test driver" program, deputed to handle tests protocol used by + # test scripts. By default, it's assumed that no protocol is used, + # so we fall back to the old "parallel-tests" behaviour, implemented + # by the `test-driver' auxiliary script. + if (! var "${pfx}LOG_DRIVER") + { + require_conf_file ($parallel_tests_option->{position}, FOREIGN, + 'test-driver'); + define_variable ("${pfx}LOG_DRIVER", + "\$(SHELL) $am_config_aux_dir/test-driver", + INTERNAL); + } + my $driver = '$(' . $pfx . 'LOG_DRIVER)'; + my $driver_flags = '$(AM_' . $pfx . 'LOG_DRIVER_FLAGS)' + . ' $(' . $pfx . 'LOG_DRIVER_FLAGS)'; + my $compile = "${pfx}LOG_COMPILE"; + define_variable ($compile, + '$(' . $pfx . 'LOG_COMPILER)' + . ' $(AM_' . $pfx . 'LOG_FLAGS)' + . ' $(' . $pfx . 'LOG_FLAGS)', + INTERNAL); + $output_rules .= file_contents ('check2', new Automake::Location, + GENERIC => $generic, + DRIVER => $driver, + DRIVER_FLAGS => $driver_flags, + COMPILE => '$(' . $compile . ')', + EXT => $test_suffix, + am__EXEEXT => $am_exeext, + %transform); +} # Handle TESTS variable and other checks. sub handle_tests @@ -4869,33 +4920,10 @@ sub handle_tests } my $base = $obj; $obj .= '.log'; - # The "test driver" program, deputed to handle tests protocol used by - # test scripts. By default, it's assumed that no protocol is used, - # so we fall back to the old "parallel-tests" behaviour, implemented - # by the `test-driver' auxiliary script. - if (! var 'LOG_DRIVER') - { - require_conf_file ($parallel_tests->{position}, FOREIGN, - 'test-driver'); - define_variable ('LOG_DRIVER', - "\$(SHELL) $am_config_aux_dir/test-driver", - INTERNAL); - } - my $driver = '$(LOG_DRIVER)'; - my $driver_flags = '$(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS)'; - my $compile = 'LOG_COMPILE'; - define_variable ($compile, - '$(LOG_COMPILER) $(AM_LOG_FLAGS) $(LOG_FLAGS)', INTERNAL); - $output_rules .= file_contents ('check2', new Automake::Location, - GENERIC => 0, - OBJ => $obj, - BASE => $base, - SOURCE => $val, - DRIVER => $driver, - DRIVER_FLAGS => $driver_flags, - COMPILE =>'$(' . $compile . ')', - EXT => '', - am__EXEEXT => 'FALSE'); + handle_per_suffix_test ('', + OBJ => $obj, + BASE => $base, + SOURCE => $val); return $obj; }); @@ -4921,35 +4949,10 @@ sub handle_tests $nhelper++; if ($test_suffix ne $at_exeext && $test_suffix ne '') { - (my $ext = $test_suffix) =~ s/^\.//; - $ext = uc $ext; - # See comments about definition of LOG_DRIVER, above. - if (! var "${ext}_LOG_DRIVER") - { - require_conf_file ($parallel_tests->{position}, FOREIGN, - 'test-driver'); - define_variable ("${ext}_LOG_DRIVER", - "\$(SHELL) $am_config_aux_dir/test-driver", - INTERNAL); - } - my $driver = '$(' . $ext . '_LOG_DRIVER)'; - my $driver_flags = '$(AM_' . $ext . '_LOG_DRIVER_FLAGS) ' . - '$(' . $ext . '_LOG_DRIVER_FLAGS)'; - my $compile = $ext . '_LOG_COMPILE'; - define_variable ($compile, - '$(' . $ext . '_LOG_COMPILER) $(AM_' . $ext . '_LOG_FLAGS)' - . ' $(' . $ext . '_LOG_FLAGS)', INTERNAL); - my $am_exeext = $handle_exeext ? 'am__EXEEXT' : 'FALSE'; - $output_rules .= file_contents ('check2', new Automake::Location, - GENERIC => 1, - OBJ => '', - BASE => '$*', - SOURCE => '$<', - DRIVER => $driver, - DRIVER_FLAGS => $driver_flags, - COMPILE => '$(' . $compile . ')', - EXT => $test_suffix, - am__EXEEXT => $am_exeext); + handle_per_suffix_test ($test_suffix, + OBJ => '', + BASE => '$*', + SOURCE => '$<'); } } $clean_files{'$(TEST_LOGS)'} = MOSTLY_CLEAN; diff --git a/tests/Makefile.am b/tests/Makefile.am index d1164f8e5..de2c25dbd 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -721,6 +721,7 @@ parallel-tests9.test \ parallel-tests10.test \ parallel-tests-dry-run.test \ parallel-tests-fd-redirect.test \ +parallel-tests-exeext.test \ parallel-tests-extra-programs.test \ parallel-tests-unreadable.test \ parallel-tests-subdir.test \ diff --git a/tests/Makefile.in b/tests/Makefile.in index 639356ee6..bca33ef99 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -980,6 +980,7 @@ parallel-tests9.test \ parallel-tests10.test \ parallel-tests-dry-run.test \ parallel-tests-fd-redirect.test \ +parallel-tests-exeext.test \ parallel-tests-extra-programs.test \ parallel-tests-unreadable.test \ parallel-tests-subdir.test \ diff --git a/tests/parallel-tests-exeext.test b/tests/parallel-tests-exeext.test new file mode 100755 index 000000000..50de89835 --- /dev/null +++ b/tests/parallel-tests-exeext.test @@ -0,0 +1,67 @@ +#! /bin/sh +# Copyright (C) 2011 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 2, 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 this program. If not, see . + +# parallel-tests: +# - check2.am and interaction with $(EXEEXT) + +parallel_tests=yes +. ./defs || Exit 1 + +cat >> configure.in << 'END' +dnl We need to fool the init.m4 internals a little. +AC_DEFUN([_AM_FOO], + [m4_provide([_AM_COMPILER_EXEEXT]) + AC_SUBST([CC], [false]) + AC_SUBST([EXEEXT])]) +_AM_FOO +AC_OUTPUT +END + +cat > Makefile.am << 'END' +TESTS = x y a.test b.test +LOG_COMPILER = true +TEST_LOG_COMPILER = true +## We also need to fool the automake internals a little. +EXTRA_PROGRAMS = y +y_SOURCES = +END + +$ACLOCAL +$AUTOCONF +$AUTOMAKE -a + +$EGREP 'EXEEXT|\.log|\.test' Makefile.in # For debugging. + +./configure EXEEXT= +touch x y a.test b.test +$MAKE check + +$MAKE distclean +rm -f x y a.test b.test *.log *.trs + +./configure EXEEXT=.bin +touch x y.bin a.test b.test.bin +$MAKE check +ls -l # For debugging. +test -f y.log +test ! -r y.bin.log +test -f b.log +test ! -r b.test.log + +$EGREP '^y\.log: y(\$\(EXEEXT\)|\.bin)' Makefile +$EGREP '^\.test(\$\(EXEEXT\)|\.bin)\.log:' Makefile + +: