minor, use sys.exit print shorthand
diff --git a/test/fuzzing/run-draw-fuzzer-tests.py b/test/fuzzing/run-draw-fuzzer-tests.py
index 9fd21b6..7f40cf8 100755
--- a/test/fuzzing/run-draw-fuzzer-tests.py
+++ b/test/fuzzing/run-draw-fuzzer-tests.py
@@ -28,9 +28,8 @@
if not os.path.exists (hb_draw_fuzzer):
if len (sys.argv) == 1 or not os.path.exists (sys.argv[1]):
- print ("""Failed to find hb-draw-fuzzer binary automatically,
+ sys.exit ("""Failed to find hb-draw-fuzzer binary automatically,
please provide it as the first argument to the tool""")
- sys.exit (1)
hb_draw_fuzzer = sys.argv[1]
@@ -42,8 +41,7 @@
if os.environ.get ('RUN_VALGRIND', ''):
valgrind = shutil.which ('valgrind')
if valgrind is None:
- print ("""Valgrind requested but not found.""")
- sys.exit (1)
+ sys.exit ("""Valgrind requested but not found.""")
if libtool is None:
print ("""Valgrind support is currently autotools only and needs libtool but not found.""")
@@ -69,5 +67,4 @@
if fails:
- print ("%i draw fuzzer related tests failed." % fails)
- sys.exit (1)
+ sys.exit ("%d draw fuzzer related tests failed." % fails)
diff --git a/test/fuzzing/run-shape-fuzzer-tests.py b/test/fuzzing/run-shape-fuzzer-tests.py
index 3c99942..7e2ef22 100755
--- a/test/fuzzing/run-shape-fuzzer-tests.py
+++ b/test/fuzzing/run-shape-fuzzer-tests.py
@@ -28,9 +28,8 @@
if not os.path.exists (hb_shape_fuzzer):
if len (sys.argv) == 1 or not os.path.exists (sys.argv[1]):
- print ("""Failed to find hb-shape-fuzzer binary automatically,
+ sys.exit ("""Failed to find hb-shape-fuzzer binary automatically,
please provide it as the first argument to the tool""")
- sys.exit (1)
hb_shape_fuzzer = sys.argv[1]
@@ -42,8 +41,7 @@
if os.environ.get ('RUN_VALGRIND', ''):
valgrind = shutil.which ('valgrind')
if valgrind is None:
- print ("""Valgrind requested but not found.""")
- sys.exit (1)
+ sys.exit ("""Valgrind requested but not found.""")
if libtool is None:
print ("""Valgrind support is currently autotools only and needs libtool but not found.""")
@@ -68,5 +66,4 @@
if fails:
- print ("%i shape fuzzer related tests failed." % fails)
- sys.exit (1)
+ sys.exit ("%d shape fuzzer related tests failed." % fails)
diff --git a/test/fuzzing/run-subset-fuzzer-tests.py b/test/fuzzing/run-subset-fuzzer-tests.py
index 75eba78..5fd547d 100755
--- a/test/fuzzing/run-subset-fuzzer-tests.py
+++ b/test/fuzzing/run-subset-fuzzer-tests.py
@@ -28,9 +28,8 @@
if not os.path.exists (hb_subset_fuzzer):
if len (sys.argv) < 2 or not os.path.exists (sys.argv[1]):
- print ("""Failed to find hb-subset-fuzzer binary automatically,
+ sys.exit ("""Failed to find hb-subset-fuzzer binary automatically,
please provide it as the first argument to the tool""")
- sys.exit (1)
hb_subset_fuzzer = sys.argv[1]
@@ -42,8 +41,7 @@
if os.environ.get('RUN_VALGRIND', ''):
valgrind = shutil.which ('valgrind')
if valgrind is None:
- print ("""Valgrind requested but not found.""")
- sys.exit (1)
+ sys.exit ("""Valgrind requested but not found.""")
if libtool is None:
print ("""Valgrind support is currently autotools only and needs libtool but not found.""")
@@ -75,5 +73,4 @@
run_dir (os.path.join (srcdir, "fonts"))
if fails:
- print ("%i subset fuzzer related tests failed." % fails)
- sys.exit (1)
+ sys.exit ("%d subset fuzzer related tests failed." % fails)
diff --git a/test/shaping/data/text-rendering-tests/extract-tests.py b/test/shaping/data/text-rendering-tests/extract-tests.py
index 7f26329..61566fc 100755
--- a/test/shaping/data/text-rendering-tests/extract-tests.py
+++ b/test/shaping/data/text-rendering-tests/extract-tests.py
@@ -57,4 +57,5 @@
opts = '--variations=%s' % variations
print ("../fonts/%s:%s:%s:*" % (font, opts, unistr(text)))
-sys.exit(0 if found else 1)
+if not found:
+ sys.exit (1)
diff --git a/test/shaping/hb-diff b/test/shaping/hb-diff
index 4c33bab..15a1e27 100755
--- a/test/shaping/hb-diff
+++ b/test/shaping/hb-diff
@@ -4,7 +4,6 @@
import sys, os
if len (sys.argv) < 2:
- print ("usage: %s FILES..." % sys.argv[0])
- sys.exit (1)
+ sys.exit ("usage: %s FILES..." % sys.argv[0])
ZipDiffer.diff_files (FileHelpers.open_file_or_stdin (f) for f in sys.argv[1:])
diff --git a/test/shaping/hb_test_tools.py b/test/shaping/hb_test_tools.py
index b1fb0bb..a9368ad 100644
--- a/test/shaping/hb_test_tools.py
+++ b/test/shaping/hb_test_tools.py
@@ -145,8 +145,7 @@
sys.stdout.writelines ([symbols[i], l])
except IOError as e:
if e.errno != errno.EPIPE:
- print ("%s: %s: %s" % (sys.argv[0], e.filename, e.strerror), file=sys.stderr)
- sys.exit (1)
+ sys.exit ("%s: %s: %s" % (sys.argv[0], e.filename, e.strerror))
class DiffFilters:
@@ -321,8 +320,7 @@
def process_multiple_files (callback, mnemonic = "FILE"):
if "--help" in sys.argv:
- print ("Usage: %s %s..." % (sys.argv[0], mnemonic))
- sys.exit (1)
+ sys.exit ("Usage: %s %s..." % (sys.argv[0], mnemonic))
try:
files = sys.argv[1:] if len (sys.argv) > 1 else ['-']
@@ -330,23 +328,20 @@
callback (FileHelpers.open_file_or_stdin (s))
except IOError as e:
if e.errno != errno.EPIPE:
- print ("%s: %s: %s" % (sys.argv[0], e.filename, e.strerror), file=sys.stderr)
- sys.exit (1)
+ sys.exit ("%s: %s: %s" % (sys.argv[0], e.filename, e.strerror))
@staticmethod
def process_multiple_args (callback, mnemonic):
if len (sys.argv) == 1 or "--help" in sys.argv:
- print ("Usage: %s %s..." % (sys.argv[0], mnemonic))
- sys.exit (1)
+ sys.exit ("Usage: %s %s..." % (sys.argv[0], mnemonic))
try:
for s in sys.argv[1:]:
callback (s)
except IOError as e:
if e.errno != errno.EPIPE:
- print ("%s: %s: %s" % (sys.argv[0], e.filename, e.strerror), file=sys.stderr)
- sys.exit (1)
+ sys.exit ("%s: %s: %s" % (sys.argv[0], e.filename, e.strerror))
@staticmethod
def filter_multiple_strings_or_stdin (callback, mnemonic, \
@@ -354,9 +349,12 @@
concat_separator = False):
if "--help" in sys.argv:
- print ("Usage:\n %s %s...\nor:\n %s\n\nWhen called with no arguments, input is read from standard input." \
- % (sys.argv[0], mnemonic, sys.argv[0]))
- sys.exit (1)
+ sys.exit ("""Usage:
+ %s %s...
+or:
+ %s
+When called with no arguments, input is read from standard input.
+""" % (sys.argv[0], mnemonic, sys.argv[0]))
try:
if len (sys.argv) == 1:
@@ -374,8 +372,7 @@
print (separator.join (callback (x) for x in (args)))
except IOError as e:
if e.errno != errno.EPIPE:
- print ("%s: %s: %s" % (sys.argv[0], e.filename, e.strerror), file=sys.stderr)
- sys.exit (1)
+ sys.exit ("%s: %s: %s" % (sys.argv[0], e.filename, e.strerror))
class Unicode:
@@ -448,8 +445,7 @@
if not os.path.exists (s):
if strict:
- print ("%s: %s does not exist" % (sys.argv[0], s), file=sys.stderr)
- sys.exit (1)
+ sys.exit ("%s: %s does not exist" % (sys.argv[0], s))
return
s = os.path.normpath (s)
@@ -464,8 +460,7 @@
yield p
except IOError:
if strict:
- print ("%s: %s does not exist" % (sys.argv[0], os.path.join (s, "MANIFEST")), file=sys.stderr)
- sys.exit (1)
+ sys.exit ("%s: %s does not exist" % (sys.argv[0], os.path.join (s, "MANIFEST")))
return
else:
yield s
diff --git a/test/shaping/run-tests.py b/test/shaping/run-tests.py
index 33ceac8..292bd7f 100755
--- a/test/shaping/run-tests.py
+++ b/test/shaping/run-tests.py
@@ -11,8 +11,7 @@
args = args[1:]
if not args or args[0].find('hb-shape') == -1 or not os.path.exists (args[0]):
- print ("""First argument does not seem to point to usable hb-shape.""")
- sys.exit (1)
+ sys.exit ("""First argument does not seem to point to usable hb-shape.""")
hb_shape, args = args[0], args[1:]
def cmd(command):
diff --git a/test/subset/run-tests.py b/test/subset/run-tests.py
index 4846aea..5ec2978 100755
--- a/test/subset/run-tests.py
+++ b/test/subset/run-tests.py
@@ -127,13 +127,11 @@
args = sys.argv[1:]
if not args or sys.argv[1].find ('hb-subset') == -1 or not os.path.exists (sys.argv[1]):
- print ("First argument does not seem to point to usable hb-subset.")
- sys.exit (1)
+ sys.exit ("First argument does not seem to point to usable hb-subset.")
hb_subset, args = args[0], args[1:]
if not len (args):
- print ("No tests supplied.")
- sys.exit (1)
+ sys.exit ("No tests supplied.")
has_ots = has_ots()
@@ -146,7 +144,6 @@
fails += run_test (test, has_ots)
if fails != 0:
- print (str (fails) + " test(s) failed.")
- sys.exit(1)
+ sys.exit ("%d test(s) failed." % fails)
else:
print ("All tests passed.")