patch/tests/line-numbers
Quentin Casasnovas c80b1a06a9 test-lib.sh: factorize require_* functions
Since the code is identical when just checking if a utility is present on
the system or not, we can factorize it.

Signed-off-by: Quentin Casasnovas <quentin.casasnovas@oracle.com>
2015-01-31 22:14:01 +01:00

66 lines
961 B
Plaintext

# Copyright (C) 2009, 2011-2012 Free Software Foundation, Inc.
#
# Copying and distribution of this file, with or without modification,
# in any medium, are permitted without royalty provided the copyright
# notice and this notice are preserved.
. $srcdir/test-lib.sh
require cat
require sed
use_local_patch
use_tmpdir
# ==============================================================
# Line number counting and reporting regression test
cat > a.diff <<EOF
--- a
+++ b
@@ -1 +1 @@
-1
+1b
@@ -3 +3,2 @@
-4
+4b
+4b
@@ -6 +0 @@
-6
+6b
EOF
seq 1 7 > a
check 'patch -f --verbose a < a.diff | grep ^Hunk' <<EOF
Hunk #1 succeeded at 1.
Hunk #2 succeeded at 4 (offset 1 line).
Hunk #3 succeeded at 7.
EOF
check 'cat a' <<EOF
1b
2
3
4b
4b
5
6b
7
EOF
seq 1 7 | sed -e '4d' > a
check 'patch -f --verbose a < a.diff | grep ^Hunk' <<EOF
Hunk #1 succeeded at 1.
Hunk #2 FAILED at 3.
Hunk #3 succeeded at 5 (offset -1 lines).
EOF
check 'cat a' <<EOF
1b
2
3
5
6b
7
EOF