patch/tests/criss-cross
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

87 lines
1.4 KiB
Plaintext

# Copyright (C) 2010-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.
# git diffs: criss-cross renames
. $srcdir/test-lib.sh
require cat
use_local_patch
use_tmpdir
# ==============================================================
# Criss-cross rename
echo 1 > f
echo 2 > g
cat > criss-cross-rename.diff <<EOF
diff --git a/g b/f
similarity index 100%
rename from g
rename to f
diff --git a/f b/g
similarity index 100%
rename from f
rename to g
EOF
check 'patch -p1 < criss-cross-rename.diff || echo "Status: $?"' <<EOF
patching file f (renamed from g)
patching file g (renamed from f)
EOF
check 'cat f' <<EOF
2
EOF
check 'cat g' <<EOF
1
EOF
# ==============================================================
# Copy-after-modify test case
ncheck 'seq 1 1000 > a'
cat > modified-twice.diff <<EOF
diff --git a/a b/a
index 1179824..912fcbd 100644
--- a/a
+++ b/a
@@ -998,3 +998,4 @@
998
999
1000
+a
diff --git a/a b/b
similarity index 99%
copy from a
copy to b
index 1179824..1c5afa7 100644
--- a/a
+++ b/b
@@ -998,3 +998,4 @@
998
999
1000
+b
EOF
check 'patch -p1 < modified-twice.diff || echo "Status: $?"' <<EOF
patching file a
patching file b (copied from a)
EOF
check 'cat a' <<EOF
`seq 1 1000`
a
EOF
check 'cat b' <<EOF
`seq 1 1000`
b
EOF