Date: Thu, 5 Sep 2019 15:35:58 +0000 (UTC) From: Kyle Evans <kevans@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r351866 - head/usr.bin/patch/tests Message-ID: <201909051535.x85FZwHq045508@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: kevans Date: Thu Sep 5 15:35:57 2019 New Revision: 351866 URL: https://svnweb.freebsd.org/changeset/base/351866 Log: patch(1): fix the file removal test, strengthen it a bit To remain compatible with GNU patch, we should ensure that once we're removing empty files after a reversed /dev/null patch we don't remove files that have been modified. GNU patch leaves these intact and just reverses the hunk that created the file, effectively implying --remove-empty-files for reversed /dev/null patches. Modified: head/usr.bin/patch/tests/unified_patch_test.sh Modified: head/usr.bin/patch/tests/unified_patch_test.sh ============================================================================== --- head/usr.bin/patch/tests/unified_patch_test.sh Thu Sep 5 15:06:30 2019 (r351865) +++ head/usr.bin/patch/tests/unified_patch_test.sh Thu Sep 5 15:35:57 2019 (r351866) @@ -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()
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201909051535.x85FZwHq045508>