[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 12/14] Refactor code requiring compilers in testsuite.
From: |
Stefano Lattarini |
Subject: |
[PATCH 12/14] Refactor code requiring compilers in testsuite. |
Date: |
Fri, 2 Jul 2010 15:36:32 +0200 |
User-agent: |
KMail/1.12.1 (Linux/2.6.30-2-686; KDE/4.3.4; i686; ; ) |
Second refactoring of this part of code. The result is admittedly
more unelegant and "spaghetti-code-style", but it's necessary to
the next patch ("Clobber global CFLAGS etc. when requiring GNU
compilers.")
Regads,
Stefano
-*-*-*-
Refactor code requiring compilers in testsuite.
* tests/defs.in (require_gnu_compilers): Removed, merged ...
(require_compiler): ... with this one, and added knowledge of
which compilers/variables should be used with which language (e.g.
gcc, $CC for the C language, g++, $CXX for C++, etc).
All usages updated accordingly.
---
ChangeLog | 7 ++++
tests/defs.in | 111 +++++++++++++++++++++++++++++++++-----------------------
2 files changed, 72 insertions(+), 46 deletions(-)
From 3e874d9a21214789bdda6a2b6c77d5887533c7ba Mon Sep 17 00:00:00 2001
From: Stefano Lattarini <address@hidden>
Date: Fri, 2 Jul 2010 12:41:30 +0200
Subject: [PATCH 12/14] Refactor code requiring compilers in testsuite.
* tests/defs.in (require_gnu_compilers): Removed, merged ...
(require_compiler): ... with this one, and added knowledge of
which compilers/variables should be used with which language (e.g.
gcc, $CC for the C language, g++, $CXX for C++, etc).
All usages updated accordingly.
---
ChangeLog | 7 ++++
tests/defs.in | 111 +++++++++++++++++++++++++++++++++-----------------------
2 files changed, 72 insertions(+), 46 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 6a1d5a0..0d1e536 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2010-07-02 Stefano Lattarini <address@hidden>
+ Refactor code requiring compilers in testsuite.
+ * tests/defs.in (require_gnu_compilers): Removed, merged ...
+ (require_compiler): ... with this one, and added knowledge of
+ which compilers/variables should be used with which language (e.g.
+ gcc, $CC for the C language, g++, $CXX for C++, etc).
+ All usages updated accordingly.
+
Fix code for requiring gfortran in tests.
* tests/defs.in: Correctly set and export F77 and/or FC when
gfortran is in $required.
diff --git a/tests/defs.in b/tests/defs.in
index 42a23ef..d34d425 100644
--- a/tests/defs.in
+++ b/tests/defs.in
@@ -88,51 +88,71 @@ echo "$PATH"
# (See note about `export' in the Autoconf manual.)
export PATH
-# Usage: require_compiler ENV-VARIABLE [FALLBACK-GNU-COMPILERS]
+# require_compiler [--force-gnu|--avoid-gnu] {c|c++|gcj|f9x|f77}
# Presently, this function is meant for internal use only.
require_compiler()
{
- eval compiler=\$$1
- if eval test x"$compiler" = x"no"; then
+ what_gnu=try
+ case $1 in
+ --force-gnu) what_gnu=force; shift;;
+ --avoid-gnu) what_gnu=avoid; shift;;
+ -*) echo "$me: require_compiler: $1: invalid option" >&2; exit 99;;
+ esac
+
+ case $1 in
+ c)
+ compiler_variable=CC
+ gnu_compiler_candidates=gcc;;
+ c++)
+ compiler_variable=CXX
+ gnu_compiler_candidates=g++;;
+ f77)
+ compiler_variable=F77
+ # gfortran should be able to seamlessly compile Fortran 77 code
+ gnu_compiler_candidates='g77 gfortran';;
+ f9x)
+ compiler_variable=FC
+ gnu_compiler_candidates=gfortran;;
+ gcj)
+ compiler_variable=GCJ
+ gnu_compiler_candidates=gcj;;
+ *)
+ echo "$me: $1: invalid compiler language" >&2; exit 99;;
+ esac
+
+ eval compiler=\$$compiler_variable
+
+ if test x"$what_gnu" != x"force" && test x"$compiler" = x"no"; then
# The user told explicitly he doesn't want a compiler of this kind
# to be used.
- echo "$me: \$$1 is \"no\", skipping test"
+ echo "$me: \$$compiler_variable is \"no\", skipping test"
exit 77
- elif test -z "$compiler"; then
- if test $# -gt 1; then
- # The user specified no explicit compiler in its environment, so
- # we try to force the use of a GNU compiler.
- require_gnu_compiler "$@"
- else
- echo "$me: \$$1 is unset or empty, and no default GNU compiler" \
- "has been specified"
- exit 77
- fi
fi
- unset compiler
-}
-# Usage: require_gnu_compiler ENV-VARIABLE GNU-COMPILER [OTHER-GNU-COMPILERS]
-# Presently, this function is meant for internal use only.
-require_gnu_compiler()
-{
- environment_variable=$1
- shift
- have_gnu_compiler=false
- for gnu_compiler in ${1+"$@"}; do
- echo "$me: running $gnu_compiler --version"
- "$gnu_compiler" --version || continue
- # This gives more information about the compiler, and also checks for
- # e.g. broken gcj installations.
- echo "$me: running $gnu_compiler -v"
- "$gnu_compiler" -v || continue
- echo # gracefully separate verbose information from rest of testlog
- have_gnu_compiler=:
- done
- $have_gnu_compiler || exit 77
- eval $environment_variable=\$gnu_compiler
- export $environment_variable
- unset environment_variable gnu_compiler have_gnu_compiler
+ if { test x"$what_gnu" = x"try" && test -z "$compiler"; } \
+ || test x"$what_gnu" = x"force"; then
+ # Either the user specified no explicit compiler in its environment,
+ # or the script asked to force the use of a GNU compiler, so we try
+ # to enable the use of a GNU compiler.
+ have_gnu_compiler=false
+ for compiler in $gnu_compiler_candidates; do
+ echo "$me: running $compiler --version"
+ "$compiler" --version || continue
+ # This gives more information about the compiler, and also checks
+ # for e.g. broken gcj installations.
+ echo "$me: running $compiler -v"
+ "$compiler" -v || continue
+ echo # gracefully separate verbose information from rest of testlog
+ have_gnu_compiler=:
+ done
+ $have_gnu_compiler || exit 77
+ eval "$compiler_variable=\$compiler"
+ export $compiler_variable
+ fi
+
+ # Remove local variables.
+ unset what_gnu compiler_variable compiler
+ unset gnu_compiler_candidates have_gnu_compiler
}
for tool in : $required
@@ -168,29 +188,28 @@ do
( $MAKE --version -v | grep GNU ) || exit 77
;;
cc)
- require_compiler 'CC' gcc
+ require_compiler c
;;
gcc)
- require_gnu_compiler 'CC' gcc
+ require_compiler --force-gnu c
;;
gcj)
- require_gnu_compiler 'GCJ' gcj
+ require_compiler --force-gnu gcj
;;
c++)
- require_compiler 'CXX' g++
+ require_compiler c++
;;
g++)
- require_gnu_compiler 'CXX' g++
+ require_compiler --force-gnu c++
;;
fortran)
- require_compiler 'FC' gfortran
+ require_compiler f9x
;;
fortran77)
- # gfortran should be able to seamlessly compile Fortran 77 code
- require_compiler 'F77' g77 gfortran
+ require_compiler f77
;;
gfortran)
- require_gnu_compiler 'FC' gfortran
+ require_compiler --force-gnu f9x
# This ensures that gfortran and a fortran77 compiler can both be
# required.
case " $required " in
--
1.6.5
- [PATCH 02/14] Drop useless "cc" requirement from a test script., (continued)
- [PATCH 02/14] Drop useless "cc" requirement from a test script., Stefano Lattarini, 2010/07/02
- [PATCH 03/14] Do not SKIP a test on a command failing with `77' exit status., Stefano Lattarini, 2010/07/02
- [PATCH 04/14] Make sure all tests needing C compiler require it explicitly., Stefano Lattarini, 2010/07/02
- [PATCH 05/14] New requirement "c++" for tests using a C++ compiler., Stefano Lattarini, 2010/07/02
- [PATCH 06/14] Fix `silent*.test' for C++ compilers with "weird" names., Stefano Lattarini, 2010/07/02
- [PATCH 07/14] Make sure silent*.test work with non-GNU C compilers., Stefano Lattarini, 2010/07/02
- [PATCH 08/14] Fixes/renamings for "synced tests" among `silent*.test'., Stefano Lattarini, 2010/07/02
- [PATCH 09/14] Refactor code requiring compilers in testsuite., Stefano Lattarini, 2010/07/02
- [PATCH 10/14] Tests: new requirements "fortran" and "fortran77", Stefano Lattarini, 2010/07/02
- [PATCH 11/14] Fix code for requiring gfortran in tests., Stefano Lattarini, 2010/07/02
- [PATCH 12/14] Refactor code requiring compilers in testsuite.,
Stefano Lattarini <=
- [PATCH 13/14] Clobber global CFLAGS etc. when requiring GNU compilers., Stefano Lattarini, 2010/07/02
- Re: [PATCH 0/14] Fix/improve requirements declaration for test scripts., Stefano Lattarini, 2010/07/02
- [PATCH 14/14] Make sure all tests needing gzip require it explicitly., Stefano Lattarini, 2010/07/02