[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 09/14] Refactor code requiring compilers in testsuite.
From: |
Stefano Lattarini |
Subject: |
[PATCH 09/14] Refactor code requiring compilers in testsuite. |
Date: |
Fri, 2 Jul 2010 15:14:19 +0200 |
User-agent: |
KMail/1.12.1 (Linux/2.6.30-2-686; KDE/4.3.4; i686; ; ) |
This refactoring will be superseded by a new one later in the patch
series, so nitpicking at it it's not worthy IMO. And yes, I'd rather
keep this "temporary" refactory anyway, since:
1. it avoids some yet unneeded complexities, and
2. it helped me shaping the next refactoring.
Regards,
Stefano
-*-*-*-
* tests/defs.in (require_compiler): New function.
(require_gnu_compiler): Likewise.
Use them throughout.
---
ChangeLog | 5 +++
tests/defs.in | 93 ++++++++++++++++++++++++++++++++-------------------------
2 files changed, 57 insertions(+), 41 deletions(-)
From 88e5a5365d6f23486320abd7d20fd25941e497a4 Mon Sep 17 00:00:00 2001
From: Stefano Lattarini <address@hidden>
Date: Fri, 2 Jul 2010 12:41:30 +0200
Subject: [PATCH 09/14] Refactor code requiring compilers in testsuite.
* tests/defs.in (require_compiler): New function.
(require_gnu_compiler): Likewise.
Use them throughout.
---
ChangeLog | 5 +++
tests/defs.in | 93 ++++++++++++++++++++++++++++++++-------------------------
2 files changed, 57 insertions(+), 41 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 7aa5ad3..4e2c685 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
2010-07-02 Stefano Lattarini <address@hidden>
+ Refactor code requiring compilers in testsuite.
+ * tests/defs.in (require_compiler): New function.
+ (require_gnu_compiler): Likewise.
+ Use them throughout.
+
Fixes/renamings for "synced tests" among `silent*.test'.
* tests/silent.test: Renamed to ...
* tests/silent1a.test: ... this.
diff --git a/tests/defs.in b/tests/defs.in
index 426424d..d97581f 100644
--- a/tests/defs.in
+++ b/tests/defs.in
@@ -88,6 +88,53 @@ echo "$PATH"
# (See note about `export' in the Autoconf manual.)
export PATH
+# Usage: require_compiler ENV-VARIABLE [FALLBACK-GNU-COMPILERS]
+# Presently, this function is meant for internal use only.
+require_compiler()
+{
+ eval compiler=\$$1
+ if eval 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"
+ 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
+}
+
for tool in : $required
do
# Check that each required tool is present.
@@ -121,55 +168,19 @@ do
( $MAKE --version -v | grep GNU ) || exit 77
;;
cc)
- if test x"$CC" = x"no"; then
- # The user told explicitly it don't want a C compiler to be used.
- echo "$me: \$CC is \"no\", skipping test"
- exit 77
- elif test -z "$CC"; then
- # The user specified no explicit compiler in its environment, so
- # we try to force the use of gcc as C compiler.
- CC=gcc
- export CC
- echo "$me: running $CC --version"
- ( $CC --version ) || exit 77
- fi
+ require_compiler 'CC' gcc
;;
gcc)
- # When gcc is required, export `CC=gcc' so that ./configure
- # always use it. This is important only when the user
- # has defined CC in his environment, otherwise ./configure will
- # prefer gcc to other compilers.
- CC=gcc
- export CC
- echo "$me: running $CC --version"
- ( $CC --version ) || exit 77
+ require_gnu_compiler 'CC' gcc
;;
gcj)
- GCJ=gcj
- export GCJ
- echo "$me: running $GCJ --version"
- ( $GCJ --version ) || exit 77
- ( $GCJ -v ) || exit 77
+ require_gnu_compiler 'GCJ' gcj
;;
c++)
- if test x"$CXX" = x"no"; then
- # The user told explicitly it don't want a C++ compiler to be used.
- echo "$me: \$CXX is \"no\", skipping test"
- exit 77
- elif test -z "$CXX"; then
- # The user specified no explicit compiler in its environment, so
- # we try to force the use of g++ as C++ compiler.
- CXX=g++
- export CXX
- echo "$me: running $CXX --version"
- ( $CXX --version ) || exit 77
- fi
+ require_compiler 'CXX' g++
;;
g++)
- CXX=g++
- export CXX
- echo "$me: running $CXX --version"
- ( $CXX --version ) || exit 77
+ require_gnu_compiler 'CXX' g++
;;
icc)
CC=icc
--
1.6.5
- [PATCH 0/14] Fix/improve requirements declaration for test scripts., Stefano Lattarini, 2010/07/02
- [PATCH 01/14] New requirement "cc" for tests using a C compiler., Stefano Lattarini, 2010/07/02
- [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 <=
- [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, 2010/07/02
- [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