remote-testgit: properly check for errors
authorFelipe Contreras <felipe.contreras@gmail.com>
Mon, 22 Oct 2012 20:56:34 +0000 (22:56 +0200)
committerJeff King <peff@peff.net>
Mon, 29 Oct 2012 08:01:00 +0000 (04:01 -0400)
'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>
git-remote-testgit.py
t/t5800-remote-helpers.sh
index 5f3ebd244dac3ca28298ece9df914102b8155660..b8707e6cc4ea4f4a8a8c9fc89058ec239de5cf8d 100644 (file)
@@ -159,6 +159,11 @@ def do_import(repo, args):
         ref = line[7:].strip()
         refs.append(ref)
 
+    print "feature done"
+
+    if os.environ.get("GIT_REMOTE_TESTGIT_FAILURE"):
+        die('Told to fail')
+
     repo = update_local_repo(repo)
     repo.exporter.export_repo(repo.gitdir, refs)
 
@@ -172,6 +177,9 @@ def do_export(repo, args):
     if not repo.gitdir:
         die("Need gitdir to export")
 
+    if os.environ.get("GIT_REMOTE_TESTGIT_FAILURE"):
+        die('Told to fail')
+
     update_local_repo(repo)
     changed = repo.importer.do_import(repo.gitdir)
 
index e7dc668cef22719a778fb0447534466b88aaa245..446cc8e0171ab70cc38c6c4affbc824fd8594d6f 100755 (executable)
@@ -145,4 +145,25 @@ test_expect_failure 'push new branch with old:new refspec' '
        compare_refs clone HEAD server refs/heads/new-refspec
 '
 
+test_expect_success 'proper failure checks for fetching' '
+       (GIT_REMOTE_TESTGIT_FAILURE=1 &&
+       export GIT_REMOTE_TESTGIT_FAILURE &&
+       cd localclone &&
+       test_must_fail git fetch 2>&1 | \
+               grep "Error while running fast-import"
+       )
+'
+
+# We sleep to give fast-export a chance to catch the SIGPIPE
+test_expect_failure 'proper failure checks for pushing' '
+       (GIT_REMOTE_TESTGIT_FAILURE=1 &&
+       export GIT_REMOTE_TESTGIT_FAILURE &&
+       GIT_REMOTE_TESTGIT_SLEEPY=1 &&
+       export GIT_REMOTE_TESTGIT_SLEEPY &&
+       cd localclone &&
+       test_must_fail git push --all 2>&1 | \
+               grep "Error while running fast-export"
+       )
+'
+
 test_done