[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
tests: factor the generation of files without the final eol
From: |
Akim Demaille |
Subject: |
tests: factor the generation of files without the final eol |
Date: |
Sun, 13 Oct 2019 09:46:53 +0200 |
If some day we find something more portable than Perl. E.g., toying with
truncate, but I don't know about its portability.
commit 94291fc21ee30d31632f982bd90097cf546dc7c0
Author: Akim Demaille <address@hidden>
Date: Sun Oct 13 09:36:45 2019 +0200
tests: factor the generation of files without the final eol
AFAICT Autotest 2.69 still does not support AT_DATA without the final
eol.
* tests/local.at (AT_DATA_NO_FINAL_EOL): New.
* tests/input.at: Use it.
diff --git a/tests/input.at b/tests/input.at
index f3d1578d..35199d8d 100644
--- a/tests/input.at
+++ b/tests/input.at
@@ -2179,12 +2179,11 @@ AT_CLEANUP
AT_SETUP([[Bad character literals]])
-AT_DATA([empty.y],
+AT_DATA_NO_FINAL_EOL([empty.y],
[[%%
start: '';
start: '
-]])
-AT_PERL_REQUIRE([[-e "print 'start: \'';" >> empty.y]])
+start: ']])
AT_BISON_CHECK([-fcaret empty.y], [1], [],
[[empty.y:2.8-9: warning: empty character literal [-Wother]
@@ -2204,12 +2203,11 @@ empty.y:4.8: warning: empty character literal [-Wother]
| ^
]])
-AT_DATA([two.y],
+AT_DATA_NO_FINAL_EOL([two.y],
[[%%
start: 'ab';
start: 'ab
-]])
-AT_PERL_REQUIRE([[-e "print 'start: \'ab';" >> two.y]])
+start: 'ab]])
AT_BISON_CHECK([two.y], [1], [],
[[two.y:2.8-11: warning: extra characters in character literal [-Wother]
@@ -2219,12 +2217,11 @@ two.y:4.8-10: error: missing "'" at end of file
two.y:4.8-10: warning: extra characters in character literal [-Wother]
]])
-AT_DATA([three.y],
+AT_DATA_NO_FINAL_EOL([three.y],
[[%%
start: 'abc';
start: 'abc
-]])
-AT_PERL_REQUIRE([[-e "print 'start: \'abc';" >> three.y]])
+start: 'abc]])
AT_BISON_CHECK([three.y], [1], [],
[[three.y:2.8-12: warning: extra characters in character literal [-Wother]
diff --git a/tests/local.at b/tests/local.at
index 12443d44..a753f13f 100644
--- a/tests/local.at
+++ b/tests/local.at
@@ -47,6 +47,21 @@ m4_define([AT_SETUP_STRIP],
])
+# AT_DATA_NO_FINAL_EOL(FILE, CONTENT)
+# -----------------------------------
+# Same as AT_DATA, except that CONTENT has no the final end of line.
+#
+# FIXME: AT_DATA or some variant of AT_DATA may eventually permit
+# the final newline to be omitted. See the threads starting at
+# <http://lists.gnu.org/archive/html/bison-patches/2009-07/msg00019.html>.
+m4_define([AT_DATA_NO_FINAL_EOL],
+[AT_DATA([$1], [$2
+])
+AT_PERL_REQUIRE([[-pi -e 'chomp if eof' $1]])
+])
+
+
+
## ------------- ##
## Basic tests. ##
## ------------- ##
- tests: factor the generation of files without the final eol,
Akim Demaille <=