[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: tests: factor the generation of files without the final eol
From: |
Akim Demaille |
Subject: |
Re: tests: factor the generation of files without the final eol |
Date: |
Mon, 14 Oct 2019 18:40:07 +0200 |
Hi Paul,
> Le 14 oct. 2019 à 05:44, Paul Eggert <address@hidden> a écrit :
>
> A more portable way to do that would be to use 'dd', e.g., something like the
> following where 'file' contains name of the file to be trimmed:
>
> set x $(LC_ALL=C ls -l "$file") &&
> size=$6 &&
> { test $size -eq 0 ||
> dd obs=1 seek=$(($size - 1)) if=/dev/null of="$file"; }
Can we trust all the ls implementations to really issue the size at "column" 5?
At least the CI agrees :) But since so far the test suite is still using
`...`, I used this version:
commit ab3621678a582e7bde46482cf970ffb6b1ef154d
Author: Akim Demaille <address@hidden>
Date: Mon Oct 14 07:58:36 2019 +0200
tests: use a portable 'truncate' implementation
Suggested by Paul Eggert.
https://lists.gnu.org/archive/html/bison-patches/2019-10/msg00044.html
* tests/local.at (AT_DATA_NO_FINAL_EOL): Use dd instead of perl.
diff --git a/tests/local.at b/tests/local.at
index a753f13f..5027ec55 100644
--- a/tests/local.at
+++ b/tests/local.at
@@ -57,7 +57,11 @@ m4_define([AT_SETUP_STRIP],
m4_define([AT_DATA_NO_FINAL_EOL],
[AT_DATA([$1], [$2
])
-AT_PERL_REQUIRE([[-pi -e 'chomp if eof' $1]])
+AT_REQUIRE([
+set x $(LC_ALL=C ls -l '$1') &&
+ size=$][6 &&
+ { test $size -eq 0 || dd obs=1 seek=`expr $size - 1` if=/dev/null of='$1';
}],
+ [], [ignore], [ignore])
])
Thanks!