You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by ju...@apache.org on 2013/02/08 02:27:44 UTC
svn commit: r1443815 -
/subversion/trunk/subversion/tests/cmdline/patch_tests.py
Author: julianfoad
Date: Fri Feb 8 01:27:44 2013
New Revision: 1443815
URL: http://svn.apache.org/r1443815
Log:
* subversion/tests/cmdline/patch_tests.py
(patch_lacking_trailing_eol_on_context): New test, for an issue I have
just discovered.
Modified:
subversion/trunk/subversion/tests/cmdline/patch_tests.py
Modified: subversion/trunk/subversion/tests/cmdline/patch_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/patch_tests.py?rev=1443815&r1=1443814&r2=1443815&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/patch_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/patch_tests.py Fri Feb 8 01:27:44 2013
@@ -4563,6 +4563,61 @@ def patch_apply_no_fuz(sbox):
if not filecmp.cmp(sbox.ospath('test.txt'), sbox.ospath('test_v2.txt')):
raise svntest.Failure("Patch result not identical")
+@XFail()
+def patch_lacking_trailing_eol_on_context(sbox):
+ "patch file lacking trailing eol on context"
+
+ # Apply a patch where a hunk (the only hunk, in this case) ends with a
+ # context line that has no EOL, where this context line is going to
+ # match an existing line that *does* have an EOL.
+ #
+ # Around trunk@1443700, 'svn patch' wrongly removed an EOL from the
+ # target file at that position.
+
+ sbox.build(read_only = True)
+ wc_dir = sbox.wc_dir
+
+ patch_file_path = make_patch_path(sbox)
+
+ # Prepare
+ expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
+ expected_disk = svntest.main.greek_state.copy()
+
+ # Prepare the patch
+ unidiff_patch = [
+ "Index: iota\n",
+ "===================================================================\n",
+ "--- iota\t(revision 1)\n",
+ "+++ iota\t(working copy)\n",
+ # TODO: -1 +1
+ "@@ -1 +1,2 @@\n",
+ "+Some more bytes\n",
+ " This is the file 'iota'.", # No trailing \n on this context line!
+ ]
+ svntest.main.file_write(patch_file_path, ''.join(unidiff_patch))
+
+ iota_contents = "This is the file 'iota'.\n"
+
+ expected_output = [ 'U %s\n' % sbox.ospath('iota') ]
+
+ # Test where the no-EOL context line is the last line in the target.
+ expected_disk.tweak('iota', contents="Some more bytes\n" + iota_contents)
+ expected_status.tweak('iota', status='M ')
+ expected_skip = wc.State('', { })
+ svntest.actions.run_and_verify_patch(wc_dir, os.path.abspath(patch_file_path),
+ expected_output, expected_disk,
+ expected_status, expected_skip)
+
+ # Test where the no-EOL context line is a non-last line in the target.
+ sbox.simple_revert('iota')
+ sbox.simple_append('iota', "Another line.\n")
+ expected_disk.tweak('iota', contents="Some more bytes\n" + iota_contents +
+ "Another line.\n")
+ expected_output = [ 'G %s\n' % sbox.ospath('iota') ]
+ svntest.actions.run_and_verify_patch(wc_dir, os.path.abspath(patch_file_path),
+ expected_output, expected_disk,
+ expected_status, expected_skip)
+
########################################################################
#Run the tests
@@ -4614,6 +4669,7 @@ test_list = [ None,
single_line_mismatch,
patch_empty_file,
patch_apply_no_fuz,
+ patch_lacking_trailing_eol_on_context,
]
if __name__ == '__main__':