patch/tests/remember-backup-files
Andreas Gruenbacher 910fecf695 Add missing feature tests to the test suite
Check for chmod, hardlink, symlink, and special character support to
prevent test suite failures in feature constrained environments.

Thanks to Bruno Haible and Nelson H. F. Beebe for their testing and
analysis.

* tests/test-lib.sh: Add new feature tests.
* tests/hardlinks: Split this hardlinks related test off from
tests/remember-backup-files.
* tests/Makefile.am (TESTS): Add new hardlinks test here.
* tests/file-create-modes, tests/file-modes, tests/read-only-files,
tests/preserve-mode-and-timestamp, tests/no-mode-change-git-diff: These
tests require chmod support.
* tests/hardlinks, tests/unmodified-files: These tests require hardlink
support.
* tests/symlinks: This test requires symlink support.
* tests/quoted-filenames: This test requires special character support
in filenames.
2024-11-11 22:21:27 +01:00

78 lines
1.2 KiB
Plaintext

# Copyright 2009-2024 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.
# Patch must not overwrite backup files it has created itself.
# (Backup file tests for symlinks are in tests/symlinks.)
. $srcdir/test-lib.sh
require cat
use_local_patch
use_tmpdir
# ==============================================================
echo one > f
cat > f.diff <<EOF
--- f.orig
+++ f
@@ -2 +2 @@
-one
+two
--- f.orig
+++ f
@@ -2 +2 @@
-two
+three
--- f.orig
+++ f
@@ -2 +2 @@
-three
+four
EOF
check 'patch -p0 < f.diff' <<EOF
patching file f
Hunk #1 succeeded at 1 (offset -1 lines).
patching file f
Hunk #1 succeeded at 1 (offset -1 lines).
patching file f
Hunk #1 succeeded at 1 (offset -1 lines).
EOF
check 'cat f.orig' <<EOF
one
EOF
# ==============================================================
echo one > f
cat > f.diff <<EOF
--- f
+++ /dev/null
@@ -1 +0,0 @@
-one
--- /dev/null
+++ f
@@ -0,0 +1 @@
+two
EOF
check 'patch --backup -p0 < f.diff' <<EOF
patching file f
patching file f
EOF
check 'cat f.orig' <<EOF
one
EOF
check 'cat f' <<EOF
two
EOF