diff options
author | Kyle Evans <kevans@FreeBSD.org> | 2019-11-04 03:07:01 +0000 |
---|---|---|
committer | Kyle Evans <kevans@FreeBSD.org> | 2019-11-04 03:07:01 +0000 |
commit | 50dacbf6c2a3d32f7e3f20ca98cda23f38817e7f (patch) | |
tree | 437dcfd9f3bec678f1401ffc4a37a774a403f349 /usr.bin/patch/tests/unified_patch_test.sh | |
parent | 69fac7c3af9903ba2e6bedd29a969667b0367133 (diff) | |
download | src-50dacbf6c2a3d32f7e3f20ca98cda23f38817e7f.tar.gz src-50dacbf6c2a3d32f7e3f20ca98cda23f38817e7f.zip |
patch(1): give /dev/null patches special treatment
We have a bad habit of duplicating contents of files that are sourced from
/dev/null and applied more than once... take the more sane (in most ways)
GNU route and complain if the file exists and offer reversal options.
This still falls short a little bit as selecting "don't reverse, apply
anyway" will still give you duplicated file contents. There's probably other
issues as well, but awareness is the first step to happiness.
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D21535
Notes
Notes:
svn path=/head/; revision=354328
Diffstat (limited to 'usr.bin/patch/tests/unified_patch_test.sh')
-rwxr-xr-x | usr.bin/patch/tests/unified_patch_test.sh | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/usr.bin/patch/tests/unified_patch_test.sh b/usr.bin/patch/tests/unified_patch_test.sh index 783681e94925..afd4b457f8d2 100755 --- a/usr.bin/patch/tests/unified_patch_test.sh +++ b/usr.bin/patch/tests/unified_patch_test.sh @@ -103,27 +103,28 @@ file_creation_body() # 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, which ensures that -# the file is removed if it's empty once the patch is reversed. +# the file is removed if it's empty once the patch is reversed. The size checks +# are scattered throughout to make sure that we didn't get some kind of false +# error, and the first size check is merely a sanity check that should be +# trivially true as this is executed in a sandbox. atf_test_case file_nodupe file_nodupe_body() { - # WIP - atf_expect_fail "patch(1) erroneously duplicates created files" echo "x" > foo diff -u /dev/null foo > foo.diff - atf_check -x "patch -s < foo.diff" - atf_check -s not-exit:0 -x "patch -fs < foo.diff" + atf_check -o inline:"2\n" stat -f "%z" foo + atf_check -s not-exit:0 -o ignore -x "patch -Ns < foo.diff" + atf_check -o inline:"2\n" stat -f "%z" foo + atf_check -s not-exit:0 -o ignore -x "patch -fs < foo.diff" + atf_check -o inline:"2\n" stat -f "%z" foo } atf_test_case file_removal file_removal_body() { - # WIP - atf_expect_fail "patch(1) does not yet recognize /dev/null as creation" - echo "x" > foo diff -u /dev/null foo > foo.diff |