bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

tests: run the C++ tests on all the available standards


From: Akim Demaille
Subject: tests: run the C++ tests on all the available standards
Date: Wed, 12 Sep 2018 22:14:51 +0200

To install after my changes for move semantics.

I decided to go for a dynamic loop (from the shell) rather than
a static one (from M4), as it’s more compact, and the static loop
would even require that we check dynamically whether a standard is
supported or not.

But at a consequence, AT_FOR_EACH_CXX must be inside the
SETUP/CLEANUP pair, it cannot wrap it.

commit 4ffb0c0a13e5b052860ed225a612dbc22f3e186f
Author: Akim Demaille <address@hidden>
Date:   Wed Sep 12 22:01:32 2018 +0200

    tests: run the C++ tests on all the available standards
    
    This is much of course more efficient than in the matrix of the CI (or
    on our own machines), but a bit more tedious.
    
    * configure.ac (CXX03_CXXFLAGS, CXX11_CXXFLAGS, CXX14_CXXFLAGS)
    (CXX17_CXXFLAGS, CXX2A_CXXFLAGS, STDCXX_FLAGS): New.
    * tests/atlocal.in: Receive them.
    * tests/local.at (AT_FOR_EACH_CXX): New.
    * tests/c++.at: Use AT_FOR_EACH_CXX.

diff --git a/configure.ac b/configure.ac
index 34e94b3b..f8faa2b7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -54,7 +54,14 @@ AC_PROG_CC_STDC
 AC_PROG_CXX
 AC_LANG_PUSH([C++])
 gl_WARN_ADD([-fno-exceptions], [NO_EXCEPTIONS_CXXFLAGS])
+gl_WARN_ADD([-std=c++98], [CXX98_CXXFLAGS])
+gl_WARN_ADD([-std=c++03], [CXX03_CXXFLAGS])
 gl_WARN_ADD([-std=c++11], [CXX11_CXXFLAGS])
+gl_WARN_ADD([-std=c++14], [CXX14_CXXFLAGS])
+gl_WARN_ADD([-std=c++17], [CXX17_CXXFLAGS])
+gl_WARN_ADD([-std=c++2a], [CXX2A_CXXFLAGS])
+AC_SUBST([STDCXX_FLAGS],
+["$CXX98_CXXFLAGS $CXX03_CXXFLAGS $CXX11_CXXFLAGS $CXX14_CXXFLAGS 
$CXX17_CXXFLAGS $CXX2A_CXXFLAGS "])
 AM_CONDITIONAL([ENABLE_CXX11], [test x"$CXX11_CXXFLAGS" != x])
 AC_LANG_POP([C++])
 
diff --git a/tests/atlocal.in b/tests/atlocal.in
index e706d3a2..8638d1a0 100644
--- a/tests/atlocal.in
+++ b/tests/atlocal.in
@@ -55,7 +55,9 @@ fi
 : ${NO_EXCEPTIONS_CXXFLAGS='@NO_EXCEPTIONS_CXXFLAGS@'}
 
 # Requiring a specific C++ standard.
+: ${CXX98_CXXFLAGS='@CXX98_CXXFLAGS@'}
 : ${CXX11_CXXFLAGS='@CXX11_CXXFLAGS@'}
+: ${STDCXX_FLAGS='@STDCXX_FLAGS@'}
 
 # Be sure that the C++ compiler is not broken because of gnulib.  This
 # cannot be checked in configure (gnulib is not parameterized yet),
diff --git a/tests/c++.at b/tests/c++.at
index b92fe9e1..8b14da12 100644
--- a/tests/c++.at
+++ b/tests/c++.at
@@ -82,8 +82,10 @@ main (void)
 }
 ]])
 
-AT_FULL_COMPILE([input])
-AT_PARSER_CHECK([./input], 0)
+AT_FOR_EACH_CXX([
+  AT_FULL_COMPILE([input])
+  AT_PARSER_CHECK([./input], 0)
+])
 AT_BISON_OPTION_POPDEFS
 AT_CLEANUP
 
@@ -177,11 +179,13 @@ int main()
 }
 ]])
 
+AT_FOR_EACH_CXX([
 AT_FULL_COMPILE([list])
 AT_PARSER_CHECK([./list], 0, [],
 [12
 123
 ])
+])
 
 AT_BISON_OPTION_POPDEFS
 AT_CLEANUP
@@ -360,6 +364,7 @@ namespace yy
 ]AT_MAIN_DEFINE[
 ]])
 
+AT_FOR_EACH_CXX([
 AT_FULL_COMPILE([list])
 AT_PARSER_CHECK([./list], 0,
 [[(0, 1, 2, 4, 6)
@@ -386,6 +391,7 @@ Destroy: "6"
 Destroy: ()
 Destroy: (0, 1, 2, 4, 6)
 ]])
+])
 
 AT_BISON_OPTION_POPDEFS
 AT_CLEANUP
@@ -482,7 +488,7 @@ int main()
 }
 ]])
 
-
+AT_FOR_EACH_CXX([
 AT_FULL_COMPILE([[input]])
 # This used to print "Discarding 'a'." again at the end.
 AT_PARSER_CHECK([[./input]], [[0]], [[]],
@@ -523,6 +529,7 @@ Cleanup: popping token EOI ()
 Cleanup: popping nterm expr (40)
 destroy: 40
 ]])
+])
 
 AT_BISON_OPTION_POPDEFS
 AT_CLEANUP
@@ -657,8 +664,9 @@ void
 AT_BISON_CHECK([[-o input.cc input.yy]])
 
 m4_if([$#], [1],
-[AT_COMPILE_CXX([[input]])
-AT_PARSER_CHECK([[./input]])])
+[AT_FOR_EACH_CXX([
+  AT_COMPILE_CXX([[input]])
+  AT_PARSER_CHECK([[./input]])])])
 AT_BISON_OPTION_POPDEFS
 ])
 
@@ -754,6 +762,7 @@ yy::parser::error (const std::string &m)
 ]AT_MAIN_DEFINE[
 ]])
 
+AT_FOR_EACH_CXX([
 AT_FULL_COMPILE([[input]])
 # This used to print "Discarding 'a'." again at the end.
 AT_PARSER_CHECK([[./input]], [[1]], [[]],
@@ -761,6 +770,7 @@ AT_PARSER_CHECK([[./input]], [[1]], [[]],
 Discarding 'a'.
 Reducing 'a'.
 ]])
+])
 
 AT_BISON_OPTION_POPDEFS
 AT_CLEANUP
@@ -834,6 +844,7 @@ yylex (yy::parser::semantic_type *)
 }
 ]])
 
+AT_FOR_EACH_CXX([
 AT_FULL_COMPILE([[input]], [[scan]])
 
 AT_PARSER_CHECK([[./input]], [[0]], [[]],
@@ -842,6 +853,7 @@ caught error
 error: invalid character
 caught error
 ]])
+])
 
 AT_BISON_OPTION_POPDEFS
 AT_CLEANUP
@@ -1095,6 +1107,8 @@ main (int argc, const char *argv[])
 }
 ]])
 AT_BISON_CHECK([[-o input.cc --report=all input.yy]])
+
+AT_FOR_EACH_CXX([
 AT_COMPILE_CXX([[input]])
 
 AT_PARSER_CHECK([[./input aaaas]], [[2]], [[]],
@@ -1125,6 +1139,7 @@ AT_PARSER_CHECK([[./input aaaaE]], [[2]], [[]],
 AT_PARSER_CHECK([[./input aaaaT]], [[1]])
 
 AT_PARSER_CHECK([[./input aaaaR]], [m4_if([$2], [with], [0], [1])])
+])
 
 AT_BISON_OPTION_POPDEFS
 
@@ -1181,6 +1196,6 @@ int main ()
 ])
 
 AT_BISON_CHECK([[-o input.cc input.yy]])
-AT_COMPILE_CXX([[input]])
+AT_FOR_EACH_CXX([AT_COMPILE_CXX([[input]])])
 
 AT_CLEANUP
diff --git a/tests/local.at b/tests/local.at
index de3ef80d..e1c8f353 100644
--- a/tests/local.at
+++ b/tests/local.at
@@ -563,7 +563,16 @@ main (int argc, char const* argv[])
   return p.parse ();
 }]])
 
-
+m4_define([AT_FOR_EACH_CXX],
+[[at_for_each_cxx_CXXFLAGS_save=$CXXFLAGS
+for at_cxx_std in "" $STDCXX_FLAGS
+do
+  ]AS_ECHO(["Testing with C++ standard flags: '$at_cxx_std'"])[
+  CXXFLAGS="$at_for_each_cxx_CXXFLAGS_save $at_cxx_std"
+  ]$1[
+done
+CXXFLAGS=$at_for_each_cxx_CXXFLAGS_save
+]])
 
 ## ------ ##
 ## Java.  ##




reply via email to

[Prev in Thread] Current Thread [Next in Thread]