Skip to content

Commit 49f4fd9

Browse files
pks-tgitster
authored andcommitted
t98xx: fix Perforce tests with p4d r23 and newer
Some of the tests in t98xx modify the Perforce depot in ways that the tool wouldn't normally allow. This is done to test behaviour of git-p4 in certain edge cases that we have observed in the wild, but which should in theory not be possible. Naturally, modifying the depot on disk directly is quite intimate with the tool and thus prone to breakage when Perforce updates the way that data is stored. And indeed, those tests are broken nowadays with r23 of Perforce. While a file revision was previously stored as a plain file "depot/file,v", it is now stored in a directory "depot/file,d" with compression. Adapt those tests to handle both old- and new-style depot layouts. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d19b6cd commit 49f4fd9

File tree

3 files changed

+48
-8
lines changed

3 files changed

+48
-8
lines changed

t/t9800-git-p4-basic.sh

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,20 @@ test_expect_success 'exit when p4 fails to produce marshaled output' '
297297
# p4 changes, files, or describe; just in p4 print. If P4CLIENT is unset, the
298298
# message will include "Librarian checkout".
299299
test_expect_success 'exit gracefully for p4 server errors' '
300-
test_when_finished "mv \"$db\"/depot/file1,v,hidden \"$db\"/depot/file1,v" &&
301-
mv "$db"/depot/file1,v "$db"/depot/file1,v,hidden &&
300+
# Note that newer Perforce versions started to store files
301+
# compressed in directories. The case statement handles both
302+
# old and new layout.
303+
case "$(echo "$db"/depot/file1*)" in
304+
*,v)
305+
test_when_finished "mv \"$db\"/depot/file1,v,hidden \"$db\"/depot/file1,v" &&
306+
mv "$db"/depot/file1,v "$db"/depot/file1,v,hidden;;
307+
*,d)
308+
path="$(echo "$db"/depot/file1,d/*.gz)" &&
309+
test_when_finished "mv \"$path\",hidden \"$path\"" &&
310+
mv "$path" "$path",hidden;;
311+
*)
312+
BUG "unhandled p4d layout";;
313+
esac &&
302314
test_when_finished cleanup_git &&
303315
test_expect_code 1 git p4 clone --dest="$git" //depot@1 >out 2>err &&
304316
test_grep "Error from p4 print" err

t/t9802-git-p4-filetype.sh

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,10 +300,22 @@ test_expect_success SYMLINKS 'empty symlink target' '
300300
# text
301301
# @@
302302
#
303+
# Note that newer Perforce versions started to store files
304+
# compressed in directories. The case statement handles both
305+
# old and new layout.
303306
cd "$db/depot" &&
304-
sed "/@target1/{; s/target1/@/; n; d; }" \
305-
empty-symlink,v >empty-symlink,v.tmp &&
306-
mv empty-symlink,v.tmp empty-symlink,v
307+
case "$(echo empty-symlink*)" in
308+
empty-symlink,v)
309+
sed "/@target1/{; s/target1/@/; n; d; }" \
310+
empty-symlink,v >empty-symlink,v.tmp &&
311+
mv empty-symlink,v.tmp empty-symlink,v;;
312+
empty-symlink,d)
313+
path="empty-symlink,d/$(ls empty-symlink,d/ | tail -n1)" &&
314+
rm "$path" &&
315+
gzip </dev/null >"$path";;
316+
*)
317+
BUG "unhandled p4d layout";;
318+
esac
307319
) &&
308320
(
309321
# Make sure symlink really is empty. Asking

t/t9825-git-p4-handle-utf16-without-bom.sh

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,25 @@ test_expect_success 'init depot with UTF-16 encoded file and artificially remove
2222
cd db &&
2323
p4d -jc &&
2424
# P4D automatically adds a BOM. Remove it here to make the file invalid.
25-
sed -e "\$d" depot/file1,v >depot/file1,v.new &&
26-
mv depot/file1,v.new depot/file1,v &&
27-
printf "@$UTF16@" >>depot/file1,v &&
25+
#
26+
# Note that newer Perforce versions started to store files
27+
# compressed in directories. The case statement handles both
28+
# old and new layout.
29+
case "$(echo depot/file1*)" in
30+
depot/file1,v)
31+
sed -e "\$d" depot/file1,v >depot/file1,v.new &&
32+
mv depot/file1,v.new depot/file1,v &&
33+
printf "@$UTF16@" >>depot/file1,v;;
34+
depot/file1,d)
35+
path="$(echo depot/file1,d/*.gz)" &&
36+
gunzip -c "$path" >"$path.unzipped" &&
37+
sed -e "\$d" "$path.unzipped" >"$path.new" &&
38+
printf "$UTF16" >>"$path.new" &&
39+
gzip -c "$path.new" >"$path" &&
40+
rm "$path.unzipped" "$path.new";;
41+
*)
42+
BUG "unhandled p4d layout";;
43+
esac &&
2844
p4d -jrF checkpoint.1
2945
)
3046
'

0 commit comments

Comments
 (0)