diffutils/tests/no-newline-at-eof
Jim Meyering a9cc55101c tests: use "returns_" rather than explicit comparison with "$?"
* tests/colors: Use "returns_ 1" rather than testing $? = 1
* tests/basic: Likewise.
* tests/binary: Likewise.
* tests/filename-quoting: Likewise.
* tests/function-line-vs-leading-space: Likewise.
* tests/ignore-matching-lines: Likewise.
* tests/label-vs-func: Likewise.
* tests/new-file: Likewise.
* tests/no-dereference: Likewise.
* tests/no-newline-at-eof: Likewise.
* tests/stdin: Likewise.
2016-11-08 18:28:04 -08:00

57 lines
1.1 KiB
Bash
Executable File

#!/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
returns_ 1 diff $opt -U1 a b > out 2> err || 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
returns_ 1 diff $opt -U1 a b > out 2> err || 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
returns_ 1 diff -B a b > out 2>err || fail=1
Exit $fail