Debian Codegraph @

tests/no-newline-at-eof

raw
1 #!/bin/sh
2 # exercise the no-newline-at-EOF bug
3 # Before the April 2010 fix, the "\ No newline at end of file"
4 # line would not be printed.
5
6 . "${srcdir=.}/init.sh"; path_prepend_ ../src
7
8 printf '\n1' > a || framework_failure_
9 printf '\n0\n\n1' > b || framework_failure_
10 cat <<EOF > exp || framework_failure_
11 @@ -1,2 +1,4 @@
12
13 +0
14 +
15 1
16 \ No newline at end of file
17 EOF
18
19 cat <<EOF > exp2 || framework_failure_
20 @@ -1,2 +1,4 @@
21
22 -1
23 +0
24 +
25 +1
26 \ No newline at end of file
27 EOF
28
29 fail=0
30
31 # So we don't have to record trailing blanks in expected output above.
32 opt=--suppress-blank-empty
33
34 returns_ 1 diff $opt -U1 a b > out 2> err || fail=1
35
36 sed -n '/^@@/,$p' out > k && mv k out || fail=1
37 compare exp out || fail=1
38 # expect empty stderr
39 compare /dev/null err || fail=1
40
41 # Repeat, but with a newline at the end of "a".
42 echo >> a
43
44 returns_ 1 diff $opt -U1 a b > out 2> err || fail=1
45
46 sed -n '/^@@/,$p' out > k && mv k out || fail=1
47 compare exp2 out || fail=1
48 # expect empty stderr
49 compare /dev/null err || fail=1
50
51 # Test for Bug#18402.
52 printf a > a
53 printf b > b
54 returns_ 1 diff -B a b > out 2>err || fail=1
55
56 Exit $fail