[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 2/6] tests: generalize the compilation macros.
From: |
Akim Demaille |
Subject: |
[PATCH 2/6] tests: generalize the compilation macros. |
Date: |
Tue, 26 Jun 2012 14:10:45 +0200 |
* tests/local.at (AT_COMPILE, AT_COMPILE_CXX): If OUTPUT ends with ".o",
then append the "natural" extension for the input file (.c or .cc).
If there is no source, pass -c.
* tests/headers.at, tests/input.at, tests/regression.at: Adjust.
---
tests/headers.at | 4 ++--
tests/input.at | 6 +++---
tests/local.at | 37 +++++++++++++++++++++++++++++--------
tests/regression.at | 10 +++++-----
4 files changed, 39 insertions(+), 18 deletions(-)
diff --git a/tests/headers.at b/tests/headers.at
index a28f2e1..549d62d 100644
--- a/tests/headers.at
+++ b/tests/headers.at
@@ -111,8 +111,8 @@ main (void)
# Link and execute, just to make sure everything is fine (and in
# particular, that MY_LLOC is indeed defined somewhere).
-AT_COMPILE([caller.o], [-c caller.c])
-AT_COMPILE([input.o], [-c input.c])
+AT_COMPILE([caller.o])
+AT_COMPILE([input.o])
AT_COMPILE([caller], [caller.o input.o])
AT_PARSER_CHECK([./caller])
diff --git a/tests/input.at b/tests/input.at
index 2f667d0..6d8d552 100644
--- a/tests/input.at
+++ b/tests/input.at
@@ -533,8 +533,8 @@ main (void)
AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([-d -v -o input.c input.y])
-AT_COMPILE([input.o], [-c input.c])
-AT_COMPILE([main.o], [-c main.c])
+AT_COMPILE([input.o])
+AT_COMPILE([main.o])
AT_COMPILE([input], [input.o main.o])
AT_PARSER_CHECK([./input], 0,
[[[@<:@],
@@ -654,7 +654,7 @@ input.y:18.8-16: warning: POSIX Yacc forbids dashes in
symbol names: with-dash
AT_BISON_CHECK([-o input.c input.y])
# Make sure we don't export silly token identifiers with periods or dashes.
-AT_COMPILE([input.o], [-c input.c])
+AT_COMPILE([input.o])
# Periods are genuine letters, they can start identifiers.
diff --git a/tests/local.at b/tests/local.at
index 85507a3..1646a5e 100644
--- a/tests/local.at
+++ b/tests/local.at
@@ -537,21 +537,37 @@ m4_define([AT_QUELL_VALGRIND],
# AT_COMPILE(OUTPUT, [SOURCES = OUTPUT.c])
# ----------------------------------------
-# Compile SOURCES into OUTPUT. If OUTPUT does not contain '.',
-# assume that we are linking too; this is a hack.
+# Compile SOURCES into OUTPUT.
+#
+# If OUTPUT does not contain '.', assume that we are linking too,
+# 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([$CC $CFLAGS $CPPFLAGS m4_bmatch([$1], [[.]], [], [$LDFLAGS ])-o $1
m4_default([$2], [$1.c])[]m4_bmatch([$1], [[.]], [], [ $LIBS])],
+[AT_CHECK(m4_join([ ],
+ [$CC $CFLAGS $CPPFLAGS],
+ [m4_bmatch([$1], [[.]], [-c], [$LDFLAGS])],
+ [-o $1],
+ [m4_default([$2], [m4_bpatsubst([$1], [\.o$]).c])],
+ [m4_bmatch([$1], [[.]], [], [$LIBS])]),
0, [ignore], [ignore])])
# AT_COMPILE_CXX(OUTPUT, [SOURCES = OUTPUT.cc])
-# --------------------------------------------
-# Compile SOURCES into OUTPUT. If OUTPUT does not contain '.',
-# assume that we are linking too; this is a hack.
-# If the C++ compiler does not work, ignore the test.
+# ---------------------------------------------
+# Compile SOURCES into OUTPUT. If the C++ compiler does not work,
+# ignore the test.
+#
+# If OUTPUT does not contain '.', assume that we are linking too,
+# otherwise pass "-c"; this is a hack. The default SOURCES is OUTPUT
+# with trailing .o removed, and ".cc" appended.
m4_define([AT_COMPILE_CXX],
[AT_KEYWORDS(c++)
AT_CHECK([$BISON_CXX_WORKS], 0, ignore, ignore)
-AT_CHECK([$CXX $CXXFLAGS $CPPFLAGS m4_bmatch([$1], [[.]], [], [$LDFLAGS ])-o
$1 m4_default([$2], [$1.cc])[]m4_bmatch([$1], [[.]], [], [ $LIBS])],
+AT_CHECK(m4_join([ ],
+ [$CXX $CXXFLAGS $CPPFLAGS],
+ [m4_bmatch([$1], [[.]], [-c], [$LDFLAGS])],
+ [-o $1],
+ [m4_default([$2], [m4_bpatsubst([$1], [\.o$]).cc])],
+ [m4_bmatch([$1], [[.]], [], [$LIBS])]),
0, [ignore], [ignore])])
# AT_JAVA_COMPILE(SOURCES)
@@ -566,6 +582,11 @@ AT_CHECK([[$SHELL ../../../javacomp.sh ]$1],
# AT_LANG_COMPILE(OUTPUT, [SOURCES = OUTPUT.c]
# --------------------------------------------
+# Compile SOURCES into OUTPUT. Skip if compiler does not work.
+#
+# If OUTPUT does not contain '.', assume that we are linking too,
+# otherwise pass "-c"; this is a hack. The default SOURCES is OUTPUT
+# with trailing .o removed, and ".c"/".cc" appended.
m4_define([AT_LANG_COMPILE],
[m4_case(AT_LANG,
[c], [AT_COMPILE([$1], [$2])],
diff --git a/tests/regression.at b/tests/regression.at
index 5c1ad32..4208153 100644
--- a/tests/regression.at
+++ b/tests/regression.at
@@ -41,7 +41,7 @@ program: 'x';
AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([-o input.c input.y])
-AT_COMPILE([input.o], [-c input.c])
+AT_COMPILE([input.o])
AT_COMPILE([input.o], [-DYYDEBUG -c input.c])
AT_CLEANUP
@@ -71,7 +71,7 @@ program: { $$ = ""; };
AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([-o input.c input.y])
-AT_COMPILE([input.o], [-c input.c])
+AT_COMPILE([input.o])
AT_CLEANUP
@@ -111,7 +111,7 @@ exp: MY_TOKEN;
AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([-y -o input.c input.y])
-AT_COMPILE([input.o], [-c input.c])
+AT_COMPILE([input.o])
AT_CLEANUP
@@ -156,7 +156,7 @@ exp: MY_TOKEN;
AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([-o input.c input.y])
-AT_COMPILE([input.o], [-c input.c])
+AT_COMPILE([input.o])
AT_CLEANUP
@@ -527,7 +527,7 @@ exp:
AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([-o input.c input.y])
-AT_COMPILE([input.o], [-c input.c])
+AT_COMPILE([input.o])
AT_CLEANUP
--
1.7.11.1
- [PATCH 0/6] Refactor the test suite, Akim Demaille, 2012/06/27
- Re: [PATCH 0/6] Refactor the test suite, Akim Demaille, 2012/06/26
- [PATCH 1/6] tests: fix confusion between api.prefix and name-prefix., Akim Demaille, 2012/06/27
- [PATCH 3/6] tests: improve the generic yylex implementation., Akim Demaille, 2012/06/27
- [PATCH 4/6] tests: use assert instead of plain abort., Akim Demaille, 2012/06/27
- [PATCH 5/6] tests: use the generic yyerror function., Akim Demaille, 2012/06/27
- [PATCH 6/6] tests: do not output m4 set up., Akim Demaille, 2012/06/27
- [PATCH 2/6] tests: generalize the compilation macros.,
Akim Demaille <=