[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
tests: don't fail if the C++ compiler does not work
From: |
Akim Demaille |
Subject: |
tests: don't fail if the C++ compiler does not work |
Date: |
Sun, 4 Nov 2018 12:53:15 +0100 |
Before this patch, with ./configure CXX=false, configure was passing
(which is fine, the C++ compiler is not required to build/install
bison), but the test suite was failing.
It now properly passes, with a few SKIPs.
commit 18597d3644cf881541656975b29f80071d8789e7
Author: Akim Demaille <address@hidden>
Date: Sun Nov 4 11:26:17 2018 +0100
tests: don't fail if the C++ compiler does not work
Also, make sure that `make dist` generates a correct tarball even if
the C++ compiler does not work.
Reported by Nelson H. F. Beebe.
* m4/cxx.m4 (BISON_CXX_WORKS): Define to true/false instead of
true/exit 77. The latter is too dangerous to use (it directly quits).
(ENABLE_CXX): New name for the Automake conditional, for consistency
with ENABLE_CXX11 etc.
* tests/local.at (AT_COMPILE, AT_COMPILE_CXX): Adjust to the new
semantics of BISON_CXX_WORKS.
* examples/c++/local.mk: Skip the variant test if C++ does not work.
* examples/calc++/local.mk: Likewise.
diff --git a/examples/c++/local.mk b/examples/c++/local.mk
index b5f8f8fe..654c2bd2 100644
--- a/examples/c++/local.mk
+++ b/examples/c++/local.mk
@@ -35,21 +35,25 @@ if ENABLE_CXX14
%C%_simple_CXXFLAGS = $(CXX11_CXXFLAGS)
# Don't use gnulib's system headers.
%C%_simple_CPPFLAGS = -I$(top_builddir)
- dist_TESTS += %D%/simple.test
+ TESTS += %D%/simple.test
%D%/simple.cc: $(BISON_IN) $(dist_pkgdata_DATA)
endif
+EXTRA_DIST += %D%/simple.test
## ---------- ##
## Variants. ##
## ---------- ##
-check_PROGRAMS += %D%/variant
-nodist_%C%_variant_SOURCES = %D%/variant.yy
-# Don't use gnulib's system headers.
-%C%_variant_CPPFLAGS = -I$(top_builddir)
-dist_TESTS += %D%/variant.test
-%D%/variant.cc: $(BISON_IN) $(dist_pkgdata_DATA)
+if ENABLE_CXX
+ check_PROGRAMS += %D%/variant
+ nodist_%C%_variant_SOURCES = %D%/variant.yy
+ # Don't use gnulib's system headers.
+ %C%_variant_CPPFLAGS = -I$(top_builddir)
+ TESTS += %D%/variant.test
+ %D%/variant.cc: $(BISON_IN) $(dist_pkgdata_DATA)
+endif
+EXTRA_DIST += %D%/variant.test
if ENABLE_CXX11
check_PROGRAMS += %D%/variant-11
@@ -57,9 +61,10 @@ if ENABLE_CXX11
%C%_variant_11_CXXFLAGS = $(CXX11_CXXFLAGS)
# Don't use gnulib's system headers.
%C%_variant_11_CPPFLAGS = -I$(top_builddir)
- dist_TESTS += %D%/variant-11.test
+ TESTS += %D%/variant-11.test
%D%/variant-11.cc: $(BISON_IN) $(dist_pkgdata_DATA)
endif
+EXTRA_DIST += %D%/variant-11.test
dist_cxx_DATA = %D%/README %D%/Makefile %D%/variant.yy %D%/variant-11.yy
CLEANFILES += %D%/simple.output %D%/variant.output %D%/variant-11.output
diff --git a/examples/calc++/local.mk b/examples/calc++/local.mk
index 6809188e..4b31283f 100644
--- a/examples/calc++/local.mk
+++ b/examples/calc++/local.mk
@@ -65,17 +65,16 @@ calcxx_sources = \
$(calcxx_sources_generated)
if FLEX_CXX_WORKS
-check_PROGRAMS += %D%/calc++
-nodist_%C%_calc___SOURCES = \
- $(calcxx_sources)
-
-# Don't use gnulib's system headers.
-%C%_calc___CPPFLAGS = -I$(top_builddir)/%D%
-%C%_calc___CXXFLAGS = $(AM_CXXFLAGS) $(FLEX_SCANNER_CXXFLAGS)
-dist_TESTS += %D%/calc++.test
-else
+if ENABLE_CXX
+ check_PROGRAMS += %D%/calc++
+ nodist_%C%_calc___SOURCES = $(calcxx_sources)
+ # Don't use gnulib's system headers.
+ %C%_calc___CPPFLAGS = -I$(top_builddir)/%D%
+ %C%_calc___CXXFLAGS = $(AM_CXXFLAGS) $(FLEX_SCANNER_CXXFLAGS)
+ TESTS += %D%/calc++.test
+endif ENABLE_CXX
+endif FLEX_CXX_WORKS
EXTRA_DIST += %D%/calc++.test
-endif
## ------------ ##
diff --git a/m4/cxx.m4 b/m4/cxx.m4
index 58bc47e9..1fdca870 100644
--- a/m4/cxx.m4
+++ b/m4/cxx.m4
@@ -50,14 +50,12 @@ AC_DEFUN([BISON_TEST_FOR_WORKING_CXX_COMPILER],
AC_LANG_POP([C++])])
case $bison_cv_cxx_works in
- yes)
- BISON_CXX_WORKS=':';;
- no | cross)
- BISON_CXX_WORKS='exit 77';;
+ yes) BISON_CXX_WORKS=':';;
+ no | cross) BISON_CXX_WORKS='false';;
esac
AC_SUBST([BISON_CXX_WORKS])
- AM_CONDITIONAL(BISON_CXX_WORKS, test $bison_cv_cxx_works = yes)
+ AM_CONDITIONAL([ENABLE_CXX], [test $bison_cv_cxx_works = yes])
])
# BISON_CXX_COMPILER_POSIXLY_CORRECT
diff --git a/tests/atlocal.in b/tests/atlocal.in
index b29449aa..f48bb575 100644
--- a/tests/atlocal.in
+++ b/tests/atlocal.in
@@ -98,10 +98,8 @@ fi
: ${CXX_COMPILER_POSIXLY_CORRECT='@CXX_COMPILER_POSIXLY_CORRECT@'}
if $POSIXLY_CORRECT_IS_EXPORTED; then
- $C_COMPILER_POSIXLY_CORRECT ||
- BISON_C_WORKS="as_fn_error 77 POSIXLY_CORRECT"
- $CXX_COMPILER_POSIXLY_CORRECT ||
- BISON_CXX_WORKS="as_fn_error 77 POSIXLY_CORRECT"
+ $C_COMPILER_POSIXLY_CORRECT || BISON_C_WORKS=false
+ $CXX_COMPILER_POSIXLY_CORRECT || BISON_CXX_WORKS=false
fi
# Handle --compile-c-with-cxx here, once CXX and CXXFLAGS are known.
diff --git a/tests/local.at b/tests/local.at
index 89a117b8..0b37007f 100644
--- a/tests/local.at
+++ b/tests/local.at
@@ -777,7 +777,7 @@ m4_define([AT_QUELL_VALGRIND],
# otherwise pass "-c"; this is a hack. The default SOURCES is OUTPUT
# with trailing .o removed, and ".c" appended.
m4_define([AT_COMPILE],
-[AT_CHECK([$BISON_C_WORKS], 0, ignore, ignore)
+[AT_SKIP_IF([[! $BISON_C_WORKS]])
AT_CHECK(m4_join([ ],
[$CC $CFLAGS $CPPFLAGS $3],
[m4_bmatch([$1], [[.]], [-c], [$LDFLAGS])],
@@ -797,7 +797,7 @@ AT_CHECK(m4_join([ ],
# with trailing ".o" removed, and ".cc" appended.
m4_define([AT_COMPILE_CXX],
[AT_KEYWORDS(c++)
-AT_CHECK([$BISON_CXX_WORKS], 0, ignore, ignore)
+AT_SKIP_IF([[! $BISON_CXX_WORKS]])
AT_CHECK(m4_join([ ],
[$CXX $CXXFLAGS $CPPFLAGS $3],
[m4_bmatch([$1], [[.]], [-c], [$LDFLAGS])],
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- tests: don't fail if the C++ compiler does not work,
Akim Demaille <=