bug-gnulib
[Top][All Lists]
Advanced

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

Re: [PATCH] init.sh: new module, and add minimal tests of its compare fu


From: Jim Meyering
Subject: Re: [PATCH] init.sh: new module, and add minimal tests of its compare function
Date: Tue, 03 Jan 2012 08:23:21 +0100

Bruno Haible wrote:
>> * tests/test-init.sh: New file.

Hi Bruno,
Thanks for the testing and the report.

> This test fails on some platforms:
>
> On Solaris 7, HP-UX 11.00, IRIX 6.5:
>
> test-init.sh: failed test: err not empty: Can't open --
> FAIL: test-init.sh
>
> On FreeBSD 6.4:
>
> test-init.sh: failed test: err not empty: sed: --: No such file or directory
> PASS: test-init.sh
>
> On OpenBSD 4.9:
>
> --- exp       Tue Jan  3 01:53:17 2012
> +++ out       Tue Jan  3 01:53:17 2012
> @@ -1,4 +1,3 @@
>  diff -u /dev/null in
>  --- /dev/null        1970-01-01
>  +++ in       1970-01-01
> -+xyz
> test-init.sh: failed test: err not empty: sed: --: No such file or directory
> FAIL: test-init.sh
>
> On NetBSD 5.1:
>
> --- exp       2012-01-03 02:51:58.000000000 +0100
> +++ out       2012-01-03 02:51:58.000000000 +0100
> @@ -1,4 +1,3 @@
>  diff -u /dev/null in
>  --- /dev/null        1970-01-01
>  +++ in       1970-01-01
> -+xyz
> test-init.sh: failed test: err not empty: sed: --: No such file or directory
> FAIL: test-init.sh
>
> The use of '--' in tests/init.sh:compare_dev_null_ was probably meant to
> protect against a file name that starts with a minus sign.

Yes, it was.

> But is that a realistic expectation in a test suite?

I agree that it's not worth the bother, so did this:

>From bf1eb2d3b4bd6704ad0dc5c0a666803db876f2b4 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Tue, 3 Jan 2012 08:21:09 +0100
Subject: [PATCH] init.sh: do not try to accommodate compare arguments
 starting with "-"

* tests/init.sh (compare_dev_null_): Do not try to accommodate
compare arguments that start with "-".  Besides, we do not worry
about this when invoking diff or cmp; why start now with sed?
Using "--" to separate options from argument would trigger sed
failure in at least Solaris 7, HP-UX 11.00, IRIX 6.5, FreeBSD 6.4,
OpenBSD 4.9 and NetBSD 5.1.  Reported by Bruno Haible.
---
 ChangeLog     |   10 ++++++++++
 tests/init.sh |    4 ++--
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 04a3bfa..1951187 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2012-01-03  Jim Meyering  <address@hidden>
+
+       init.sh: do not try to accommodate compare arguments starting with "-"
+       * tests/init.sh (compare_dev_null_): Do not try to accommodate
+       compare arguments that start with "-".  Besides, we do not worry
+       about this when invoking diff or cmp; why start now with sed?
+       Using "--" to separate options from argument would trigger sed
+       failure in at least Solaris 7, HP-UX 11.00, IRIX 6.5, FreeBSD 6.4,
+       OpenBSD 4.9 and NetBSD 5.1.  Reported by Bruno Haible.
+
 2012-01-02  Jim Meyering  <address@hidden>

        gitlog-to-changelog: describe input syntax in --help output
diff --git a/tests/init.sh b/tests/init.sh
index 5d3e2be..9485492 100644
--- a/tests/init.sh
+++ b/tests/init.sh
@@ -242,13 +242,13 @@ compare_dev_null_ ()

   if test "x$1" = x/dev/null; then
     test -s "$2" || return 0
-    emit_diff_u_header_ "$@"; sed 's/^/+/' -- "$2"
+    emit_diff_u_header_ "$@"; sed 's/^/+/' "$2"
     return 1
   fi

   if test "x$2" = x/dev/null; then
     test -s "$1" || return 0
-    emit_diff_u_header_ "$@"; sed 's/^/-/' -- "$1"
+    emit_diff_u_header_ "$@"; sed 's/^/-/' "$1"
     return 1
   fi

--
1.7.8.1.391.g2c2ad



reply via email to

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