Skip to content

Commit cc36624

Browse files
committed
patch: test for unified diffs with spaces in filenames
The older GNU patch that we had in base did not properly handle spaces in filenames in unified diffs, but bsdpatch seems to have handled this fine at least since the version we imported into base initially. Add a test with spaces in the filename specifically to be sure. PR: 181272
1 parent f97b6a8 commit cc36624

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

usr.bin/patch/tests/unified_patch_test.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,23 @@ file_removal_body()
161161
atf_check -o inline:"y\n" cat foo
162162
}
163163

164+
atf_test_case namespace
165+
namespace_head()
166+
{
167+
atf_set "descr" "Test that patch(1) handles files with spaces in the name"
168+
}
169+
namespace_body()
170+
{
171+
echo "ABC" > "with spaces.orig"
172+
echo "ZYX" > "with spaces"
173+
174+
atf_check -s not-exit:0 -o save:spaces.diff \
175+
diff -u "with spaces.orig" "with spaces"
176+
177+
atf_check mv "with spaces.orig" "with spaces"
178+
atf_check -o not-empty patch < spaces.diff
179+
}
180+
164181
atf_test_case plinelen
165182
plinelen_body()
166183
{
@@ -187,5 +204,6 @@ atf_init_test_cases()
187204
atf_add_test_case file_creation
188205
atf_add_test_case file_nodupe
189206
atf_add_test_case file_removal
207+
atf_add_test_case namespace
190208
atf_add_test_case plinelen
191209
}

0 commit comments

Comments
 (0)