Patchwork [2,of,4] run-tests: use return values instead of sys.exit

login
register
mail settings
Submitter Gregory Szorc
Date March 25, 2014, 5:12 a.m.
Message ID <9c1dd166d28cb1f0dd4d.1395724374@77.1.168.192.in-addr.arpa>
Download mbox | patch
Permalink /patch/4057/
State Accepted
Commit 84d3451fc8c3f62b2d6e497dad5df921a3bc4617
Headers show

Comments

Gregory Szorc - March 25, 2014, 5:12 a.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1395722516 25200
#      Mon Mar 24 21:41:56 2014 -0700
# Node ID 9c1dd166d28cb1f0dd4d3fa36d4afe150fe7efee
# Parent  b7d99c46e39a0871297c38bbd292a2764fccb1f1
run-tests: use return values instead of sys.exit

Patch

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -1223,17 +1223,18 @@  def main(args):
     TESTDIR = os.environ["TESTDIR"] = os.getcwd()
     if options.tmpdir:
         options.keep_tmpdir = True
         tmpdir = options.tmpdir
         if os.path.exists(tmpdir):
             # Meaning of tmpdir has changed since 1.3: we used to create
             # HGTMP inside tmpdir; now HGTMP is tmpdir.  So fail if
             # tmpdir already exists.
-            sys.exit("error: temp dir %r already exists" % tmpdir)
+            print "error: temp dir %r already exists" % tmpdir
+            return 1
 
             # Automatically removing tmpdir sounds convenient, but could
             # really annoy anyone in the habit of using "--tmpdir=/tmp"
             # or "--tmpdir=$HOME".
             #vlog("# Removing temp dir", tmpdir)
             #shutil.rmtree(tmpdir)
         os.makedirs(tmpdir)
     else:
@@ -1288,15 +1289,15 @@  def main(args):
     COVERAGE_FILE = os.path.join(TESTDIR, ".coverage")
 
     vlog("# Using TESTDIR", TESTDIR)
     vlog("# Using HGTMP", HGTMP)
     vlog("# Using PATH", os.environ["PATH"])
     vlog("# Using", IMPL_PATH, os.environ[IMPL_PATH])
 
     try:
-        sys.exit(runtests(options, tests) or 0)
+        return runtests(options, tests) or 0
     finally:
         time.sleep(.1)
         cleanup(options)
 
 if __name__ == '__main__':
-    main(sys.argv[1:])
+    sys.exit(main(sys.argv[1:]))