bug-diffutils
[Top][All Lists]
Advanced

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

[bug-diffutils] [PATCH] tests: ensure that an argument of "-" is treated


From: Jim Meyering
Subject: [bug-diffutils] [PATCH] tests: ensure that an argument of "-" is treated as standard input
Date: Wed, 13 Jan 2010 13:59:00 +0100

While testing on openbsd4.5, I noticed that the very latest
gnu diff would misbehave:

    $ echo a|./diff - <(echo a)
    ./diff: failed to reopen `stdin' with mode `rb': Bad address
    [Exit 2]

To ensure we fix it eventually, I've written a test
to exercise that failure:

>From 07e844a96ddecc1702b847ce95d956409a75de46 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Wed, 13 Jan 2010 13:54:13 +0100
Subject: [PATCH] tests: ensure that an argument of "-" is treated as standard 
input

* tests/stdin: New test.
* tests/Makefile.am (TESTS): Add it.
---
 tests/Makefile.am |    3 ++-
 tests/stdin       |   24 ++++++++++++++++++++++++
 2 files changed, 26 insertions(+), 1 deletions(-)
 create mode 100755 tests/stdin

diff --git a/tests/Makefile.am b/tests/Makefile.am
index b42c905..6bcd255 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,7 +1,8 @@
 TESTS = \
   basic \
   help-version \
-  label-vs-func
+  label-vs-func        \
+  stdin

 EXTRA_DIST = \
   $(TESTS) init.sh t-local.sh
diff --git a/tests/stdin b/tests/stdin
new file mode 100755
index 0000000..673d8b0
--- /dev/null
+++ b/tests/stdin
@@ -0,0 +1,24 @@
+#!/bin/sh
+# Ensure that "-" means "standard input".
+: ${srcdir=.}
+. "$srcdir/init.sh"; path_prepend_ .
+
+fail=0
+
+cat <<EOF > exp || fail=1
+--- -
++++ b
+@@ -1 +1 @@
+-a
++b
+EOF
+
+echo a > a
+echo b > b
+
+diff -u - b < a > out 2> err; test $? = 1 || fail=1
+# Remove date and time.
+sed -e 's/^\([-+*][-+*][-+*] [^        ]*\)    .*/\1/' out > k; mv k out
+compare out exp || fail=1
+
+Exit $fail
--
1.6.6.511.gf46c4




reply via email to

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