remote-testgit: properly check for errors
'feature done' was missing, which allowed fast-import exit properly, and transport-helper to continue checking for refs and what not when in fact the remote-helper died. Let's enable that, and make sure the error paths are triggered. Now transport-helper correctly detects the errors from fast-import, unfortunately, not from fast-export because it might finish before detecting a SIGPIPE. This means transport-helper will quit silently and the user will not see any errors, which is bad. Hopefully the helper will print the error before dying anyway, so not all is lost. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Jeff King <peff@peff.net>
Felipe Contreras committed
Oct 22, 2012 at 22:56 UTC
6c323322682abed3bb2a3904596b529ebccddb1c
2 files changed
+29
git-remote-testgit.py
+8
@@ -159,6 +159,11 @@ def do_import(repo, args):
159
ref = line[7:].strip()
160
refs.append(ref)
161
162
+ print "feature done"
163
+
164
+ if os.environ.get("GIT_REMOTE_TESTGIT_FAILURE"):
165
+ die('Told to fail')
166
+
167
repo = update_local_repo(repo)
168
repo.exporter.export_repo(repo.gitdir, refs)
169
@@ -172,6 +177,9 @@ def do_export(repo, args):
177
if not repo.gitdir:
178
die("Need gitdir to export")
179
180
+ if os.environ.get("GIT_REMOTE_TESTGIT_FAILURE"):
181
+ die('Told to fail')
182
+
183
update_local_repo(repo)
184
changed = repo.importer.do_import(repo.gitdir)
185
t/t5800-remote-helpers.sh
+21
@@ -145,4 +145,25 @@ test_expect_failure 'push new branch with old:new refspec' '
145
compare_refs clone HEAD server refs/heads/new-refspec
146
'
147
148
+test_expect_success 'proper failure checks for fetching' '
149
+ (GIT_REMOTE_TESTGIT_FAILURE=1 &&
150
+ export GIT_REMOTE_TESTGIT_FAILURE &&
151
+ cd localclone &&
152
+ test_must_fail git fetch 2>&1 | \
153
+ grep "Error while running fast-import"
154
+ )
155
+'
156
+
157
+# We sleep to give fast-export a chance to catch the SIGPIPE
158
+test_expect_failure 'proper failure checks for pushing' '
159
+ (GIT_REMOTE_TESTGIT_FAILURE=1 &&
160
+ export GIT_REMOTE_TESTGIT_FAILURE &&
161
+ GIT_REMOTE_TESTGIT_SLEEPY=1 &&
162
+ export GIT_REMOTE_TESTGIT_SLEEPY &&
163
+ cd localclone &&
164
+ test_must_fail git push --all 2>&1 | \
165
+ grep "Error while running fast-export"
166
+ )
167
+'
168
+
169
test_done