diff options
author | Jim Meyering <meyering@redhat.com> | 2010-04-16 09:14:04 +0200 |
---|---|---|
committer | Jim Meyering <meyering@redhat.com> | 2010-04-16 11:28:46 +0200 |
commit | 6bb3d2900866c23da01a409aa3447ecf68627fc1 (patch) | |
tree | b073bf5ea8021bd07538a80a3bebb880375d5990 /tests | |
parent | f444711a2639b4974ff3e720c455a1f96f1109e8 (diff) | |
download | diffutils-6bb3d2900866c23da01a409aa3447ecf68627fc1.tar.gz |
tests: test for the no-newline-at-EOF bug
* tests/no-newline-at-eof: New file.
* tests/Makefile.am (TESTS): Add it.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Makefile.am | 1 | ||||
-rw-r--r-- | tests/no-newline-at-eof | 54 |
2 files changed, 55 insertions, 0 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am index a511b0b..6a4858c 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -4,6 +4,7 @@ TESTS = \ help-version \ function-line-vs-leading-space \ label-vs-func \ + no-newline-at-eof \ stdin EXTRA_DIST = \ diff --git a/tests/no-newline-at-eof b/tests/no-newline-at-eof new file mode 100644 index 0000000..c3694a1 --- /dev/null +++ b/tests/no-newline-at-eof @@ -0,0 +1,54 @@ +#!/bin/sh +# exercise the no-newline-at-EOF bug +# Before the April 2010 fix, the "\ No newline at end of file" +# line would not be printed. + +: ${srcdir=.} +. "$srcdir/init.sh"; path_prepend_ ../src + +printf '\n1' > a || framework_failure_ +printf '\n0\n\n1' > b || framework_failure_ +cat <<EOF > exp || framework_failure_ +@@ -1,2 +1,4 @@ + ++0 ++ + 1 +\ No newline at end of file +EOF + +cat <<EOF > exp2 || framework_failure_ +@@ -1,2 +1,4 @@ + +-1 ++0 ++ ++1 +\ No newline at end of file +EOF + +fail=0 + +# So we don't have to record trailing blanks in expected output above. +opt=--suppress-blank-empty + +diff $opt -U2 a b > out 2> err +test $? = 1 || fail=1 + +sed -n '/^@@/,$p' out > k && mv k out || fail=1 +compare out exp || fail=1 +# expect empty stderr +compare err /dev/null || fail=1 + +# Repeat, but with a newline at the end of "a". +echo >> a + +diff $opt -U2 a b > out 2> err +test $? = 1 || fail=1 + +sed -n '/^@@/,$p' out > k && mv k out || fail=1 +compare out exp2 || fail=1 +# expect empty stderr +compare err /dev/null || fail=1 + +Exit $fail |