]> git.ipfire.org Git - thirdparty/git.git/commitdiff
git p4 test: refactor marshal_dump
authorPete Wyckoff <pw@padd.com>
Wed, 4 Jul 2012 13:34:19 +0000 (09:34 -0400)
committerJunio C Hamano <gitster@pobox.com>
Fri, 6 Jul 2012 06:22:00 +0000 (23:22 -0700)
This function will be useful in future tests.  Move it to
the git-p4 test library.  Let it accept an optional argument
to pick a certain marshaled object out of the input stream.

Signed-off-by: Pete Wyckoff <pw@padd.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/lib-git-p4.sh
t/t9800-git-p4-basic.sh

index 31d75ae0434221ba50f805eee718b910a9cf677a..2d753ab7e118e0905e63860cc4ee6ae4932f16c4 100644 (file)
@@ -102,3 +102,16 @@ cleanup_git() {
        rm -rf "$git" &&
        mkdir "$git"
 }
+
+marshal_dump() {
+       what=$1 &&
+       line=${2:-1} &&
+       cat >"$TRASH_DIRECTORY/marshal-dump.py" <<-EOF &&
+       import marshal
+       import sys
+       for i in range($line):
+           d = marshal.load(sys.stdin)
+       print d['$what']
+       EOF
+       "$PYTHON_PATH" "$TRASH_DIRECTORY/marshal-dump.py"
+}
index 07c2e157cb3b2320e62618a7c387948749522b1a..b7ad716b09facbc068a23c48cdbfe68a87f52d4c 100755 (executable)
@@ -155,11 +155,6 @@ test_expect_success 'clone bare' '
        )
 '
 
-marshal_dump() {
-       what=$1
-       "$PYTHON_PATH" -c 'import marshal, sys; d = marshal.load(sys.stdin); print d["'$what'"]'
-}
-
 # Sleep a bit so that the top-most p4 change did not happen "now".  Then
 # import the repo and make sure that the initial import has the same time
 # as the top-most change.