diff options
Diffstat (limited to 'tests/no-newline-at-eof')
-rwxr-xr-x | tests/no-newline-at-eof | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/tests/no-newline-at-eof b/tests/no-newline-at-eof new file mode 100755 index 0000000..f503718 --- /dev/null +++ b/tests/no-newline-at-eof @@ -0,0 +1,59 @@ +#!/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=.}/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 -U1 a b > out 2> err +test $? = 1 || fail=1 + +sed -n '/^@@/,$p' out > k && mv k out || fail=1 +compare exp out || fail=1 +# expect empty stderr +compare /dev/null err || fail=1 + +# Repeat, but with a newline at the end of "a". +echo >> a + +diff $opt -U1 a b > out 2> err +test $? = 1 || fail=1 + +sed -n '/^@@/,$p' out > k && mv k out || fail=1 +compare exp2 out || fail=1 +# expect empty stderr +compare /dev/null err || fail=1 + +# Test for Bug#18402. +printf a > a +printf b > b +diff -B a b > out 2>err +test $? = 1 || fail=1 + +Exit $fail |