Skip to content

Commit 798d598

Browse files
Pete Wyckoffgitster
authored andcommitted
git p4 test: refactor marshal_dump
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>
1 parent c47178d commit 798d598

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

t/lib-git-p4.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,16 @@ cleanup_git() {
102102
rm -rf "$git" &&
103103
mkdir "$git"
104104
}
105+
106+
marshal_dump() {
107+
what=$1 &&
108+
line=${2:-1} &&
109+
cat >"$TRASH_DIRECTORY/marshal-dump.py" <<-EOF &&
110+
import marshal
111+
import sys
112+
for i in range($line):
113+
d = marshal.load(sys.stdin)
114+
print d['$what']
115+
EOF
116+
"$PYTHON_PATH" "$TRASH_DIRECTORY/marshal-dump.py"
117+
}

t/t9800-git-p4-basic.sh

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,6 @@ test_expect_success 'clone bare' '
155155
)
156156
'
157157

158-
marshal_dump() {
159-
what=$1
160-
"$PYTHON_PATH" -c 'import marshal, sys; d = marshal.load(sys.stdin); print d["'$what'"]'
161-
}
162-
163158
# Sleep a bit so that the top-most p4 change did not happen "now". Then
164159
# import the repo and make sure that the initial import has the same time
165160
# as the top-most change.

0 commit comments

Comments
 (0)