~ubuntu-branches/ubuntu/natty/diffutils/natty

« back to all changes in this revision

Viewing changes to tests/no-newline-at-eof

  • Committer: Bazaar Package Importer
  • Author(s): Santiago Vila
  • Date: 2010-05-04 20:38:00 UTC
  • mfrom: (2.1.7 sid)
  • Revision ID: james.westby@ubuntu.com-20100504203800-f67xd9rsa9xl9qqj
Tags: 1:3.0-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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=.}
 
7
. "$srcdir/init.sh"; path_prepend_ ../src
 
8
 
 
9
printf '\n1'      > a || framework_failure_
 
10
printf '\n0\n\n1' > b || framework_failure_
 
11
cat <<EOF > exp || framework_failure_
 
12
@@ -1,2 +1,4 @@
 
13
 
 
14
+0
 
15
+
 
16
 1
 
17
\ No newline at end of file
 
18
EOF
 
19
 
 
20
cat <<EOF > exp2 || framework_failure_
 
21
@@ -1,2 +1,4 @@
 
22
 
 
23
-1
 
24
+0
 
25
+
 
26
+1
 
27
\ No newline at end of file
 
28
EOF
 
29
 
 
30
fail=0
 
31
 
 
32
# So we don't have to record trailing blanks in expected output above.
 
33
opt=--suppress-blank-empty
 
34
 
 
35
diff $opt -U1 a b > out 2> err
 
36
test $? = 1 || fail=1
 
37
 
 
38
sed -n '/^@@/,$p' out > k && mv k out || fail=1
 
39
compare out exp || fail=1
 
40
# expect empty stderr
 
41
compare err /dev/null || fail=1
 
42
 
 
43
# Repeat, but with a newline at the end of "a".
 
44
echo >> a
 
45
 
 
46
diff $opt -U1 a b > out 2> err
 
47
test $? = 1 || fail=1
 
48
 
 
49
sed -n '/^@@/,$p' out > k && mv k out || fail=1
 
50
compare out exp2 || fail=1
 
51
# expect empty stderr
 
52
compare err /dev/null || fail=1
 
53
 
 
54
Exit $fail