diff options
-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 |