git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pete Wyckoff <pw@padd.com>
To: git@vger.kernel.org
Cc: Michael Horowitz <mike@horowitz.name>
Subject: [PATCH 2/3] git p4 test: refactor marshal_dump
Date: Wed,  4 Jul 2012 09:34:19 -0400	[thread overview]
Message-ID: <1341408860-26965-3-git-send-email-pw@padd.com> (raw)
In-Reply-To: <1341408860-26965-1-git-send-email-pw@padd.com>

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>
---
 t/lib-git-p4.sh         | 14 ++++++++++++++
 t/t9800-git-p4-basic.sh |  5 -----
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/t/lib-git-p4.sh b/t/lib-git-p4.sh
index 31d75ae..080b2c1 100644
--- a/t/lib-git-p4.sh
+++ b/t/lib-git-p4.sh
@@ -102,3 +102,17 @@ 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"
+}
+
diff --git a/t/t9800-git-p4-basic.sh b/t/t9800-git-p4-basic.sh
index 07c2e15..b7ad716 100755
--- a/t/t9800-git-p4-basic.sh
+++ b/t/t9800-git-p4-basic.sh
@@ -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.
-- 
1.7.11.1.125.g4a65fea

  parent reply	other threads:[~2012-07-04 13:35 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-04 13:34 [PATCH 0/3] git p4: notice Jobs: section in submit Pete Wyckoff
2012-07-04 13:34 ` [PATCH 1/3] git p4: remove unused P4Submit interactive setting Pete Wyckoff
2012-07-04 13:49   ` Pete Wyckoff
2012-07-05  7:20   ` Luke Diamand
2012-07-05 12:30     ` Pete Wyckoff
2012-07-14 13:53       ` Pete Wyckoff
2012-07-04 13:34 ` Pete Wyckoff [this message]
2012-07-04 13:34 ` [PATCH 3/3] git p4: notice Jobs lines in git commit messages Pete Wyckoff

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1341408860-26965-3-git-send-email-pw@padd.com \
    --to=pw@padd.com \
    --cc=git@vger.kernel.org \
    --cc=mike@horowitz.name \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).