patch/tests/global-reject-files
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

88 lines
1.4 KiB
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.
# More than one reject to the same file.
. $srcdir/test-lib.sh
require cat
use_local_patch
use_tmpdir
# ==============================================================
cat > ab.diff <<EOF
--- a
+++ a
@@ -1 +1 @@
-one
+two
--- b
+++ b
@@ -1 +1 @@
-three
+four
EOF
echo one > a
echo three > b
check 'patch -p0 < ab.diff' <<EOF
patching file a
patching file b
EOF
# ==============================================================
check 'patch -p0 -f < ab.diff || echo "Status: $?"' <<EOF
patching file a
Hunk #1 FAILED at 1.
1 out of 1 hunk FAILED -- saving rejects to file a.rej
patching file b
Hunk #1 FAILED at 1.
1 out of 1 hunk FAILED -- saving rejects to file b.rej
Status: 1
EOF
check 'cat a.rej' <<EOF
--- a
+++ a
@@ -1 +1 @@
-one
+two
EOF
check 'cat b.rej' <<EOF
--- b
+++ b
@@ -1 +1 @@
-three
+four
EOF
check 'patch -p0 -f -r ab.rej < ab.diff || echo "Status: $?"' <<EOF
patching file a
Hunk #1 FAILED at 1.
1 out of 1 hunk FAILED -- saving rejects to file ab.rej
patching file b
Hunk #1 FAILED at 1.
1 out of 1 hunk FAILED -- saving rejects to file ab.rej
Status: 1
EOF
check 'cat ab.rej' <<EOF
--- a
+++ a
@@ -1 +1 @@
-one
+two
--- b
+++ b
@@ -1 +1 @@
-three
+four
EOF