aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/patch/tests
diff options
context:
space:
mode:
authorKyle Evans <kevans@FreeBSD.org>2019-09-05 15:35:57 +0000
committerKyle Evans <kevans@FreeBSD.org>2019-09-05 15:35:57 +0000
commit89b5571e0b4083de499f2b835460349a7c3ebc2c (patch)
tree5f2ac525d99696e7e345d616b4205e6d093b62b6 /usr.bin/patch/tests
parent938cae327c01d64470e457ac68ff8561822cfe02 (diff)
Notes
Diffstat (limited to 'usr.bin/patch/tests')
-rwxr-xr-xusr.bin/patch/tests/unified_patch_test.sh15
1 files changed, 13 insertions, 2 deletions
diff --git a/usr.bin/patch/tests/unified_patch_test.sh b/usr.bin/patch/tests/unified_patch_test.sh
index 6b74b9d435ea..783681e94925 100755
--- a/usr.bin/patch/tests/unified_patch_test.sh
+++ b/usr.bin/patch/tests/unified_patch_test.sh
@@ -102,7 +102,8 @@ file_creation_body()
# commits. If a file is created by a diff, patch(1) will happily duplicate the
# contents as many times as you apply the diff. It should instead detect that
# a source of /dev/null creates the file, so it shouldn't exist. Furthermore,
-# the reverse of creation is deletion -- hence the next test.
+# the reverse of creation is deletion -- hence the next test, which ensures that
+# the file is removed if it's empty once the patch is reversed.
atf_test_case file_nodupe
file_nodupe_body()
{
@@ -126,8 +127,18 @@ file_removal_body()
echo "x" > foo
diff -u /dev/null foo > foo.diff
+ # Check that the file is removed completely if it was sourced from
+ # /dev/null
atf_check -x "patch -Rs < foo.diff"
- atf_check -s not-exit:0 -o ignore stat foo
+ atf_check -s not-exit:0 -e ignore stat foo
+
+ # But if it had been modified, we'll only remove the portion that the
+ # patch would have created. This makes us compatible with GNU patch's
+ # behavior, at least. Whether that is the sane action or not is a
+ # question for further study, and then this comment may be removed.
+ printf "x\ny\n" > foo
+ atf_check -x "patch -Rs < foo.diff"
+ atf_check -o inline:"y\n" cat foo
}
atf_init_test_cases()