summaryrefslogtreecommitdiff
path: root/tests/no-newline-at-eof
blob: 60522061ae639ca23c81faa22e01d45d557e98c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/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 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 -U1 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