diff --git a/test/fuzzing/run-draw-fuzzer-tests.py b/test/fuzzing/run-draw-fuzzer-tests.py index 4085649a4..b0a2fd0ea 100755 --- a/test/fuzzing/run-draw-fuzzer-tests.py +++ b/test/fuzzing/run-draw-fuzzer-tests.py @@ -1,24 +1,6 @@ #!/usr/bin/env python3 -import sys, os, subprocess, tempfile, threading - - -def which (program): - # https://stackoverflow.com/a/377028 - def is_exe (fpath): - return os.path.isfile (fpath) and os.access (fpath, os.X_OK) - - fpath, _ = os.path.split (program) - if fpath: - if is_exe (program): - return program - else: - for path in os.environ["PATH"].split (os.pathsep): - exe_file = os.path.join (path, program) - if is_exe (exe_file): - return exe_file - - return None +import sys, os, subprocess, tempfile, threading, shutil def cmd (command): @@ -74,7 +56,7 @@ fails = 0 libtool = os.environ.get ('LIBTOOL') valgrind = None if os.environ.get ('RUN_VALGRIND', ''): - valgrind = which ('valgrind') + valgrind = shutil.which ('valgrind') if valgrind is None: print ("""Valgrind requested but not found.""") sys.exit (1) diff --git a/test/fuzzing/run-shape-fuzzer-tests.py b/test/fuzzing/run-shape-fuzzer-tests.py index a44065f0f..011b986a4 100755 --- a/test/fuzzing/run-shape-fuzzer-tests.py +++ b/test/fuzzing/run-shape-fuzzer-tests.py @@ -1,24 +1,6 @@ #!/usr/bin/env python3 -import sys, os, subprocess, tempfile, threading - - -def which (program): - # https://stackoverflow.com/a/377028 - def is_exe (fpath): - return os.path.isfile (fpath) and os.access (fpath, os.X_OK) - - fpath, _ = os.path.split (program) - if fpath: - if is_exe (program): - return program - else: - for path in os.environ["PATH"].split (os.pathsep): - exe_file = os.path.join (path, program) - if is_exe (exe_file): - return exe_file - - return None +import sys, os, subprocess, tempfile, threading, shutil def cmd (command): @@ -74,7 +56,7 @@ fails = 0 libtool = os.environ.get ('LIBTOOL') valgrind = None if os.environ.get ('RUN_VALGRIND', ''): - valgrind = which ('valgrind') + valgrind = shutil.which ('valgrind') if valgrind is None: print ("""Valgrind requested but not found.""") sys.exit (1) diff --git a/test/fuzzing/run-subset-fuzzer-tests.py b/test/fuzzing/run-subset-fuzzer-tests.py index 071c64428..a29f44ea2 100755 --- a/test/fuzzing/run-subset-fuzzer-tests.py +++ b/test/fuzzing/run-subset-fuzzer-tests.py @@ -1,24 +1,6 @@ #!/usr/bin/env python3 -import sys, os, subprocess, tempfile, threading - - -def which(program): - # https://stackoverflow.com/a/377028 - def is_exe(fpath): - return os.path.isfile(fpath) and os.access(fpath, os.X_OK) - - fpath, _ = os.path.split(program) - if fpath: - if is_exe(program): - return program - else: - for path in os.environ["PATH"].split(os.pathsep): - exe_file = os.path.join(path, program) - if is_exe(exe_file): - return exe_file - - return None +import sys, os, subprocess, tempfile, threading, shutil def cmd(command): @@ -74,7 +56,7 @@ fails = 0 libtool = os.environ.get('LIBTOOL') valgrind = None if os.environ.get('RUN_VALGRIND', ''): - valgrind = which ('valgrind') + valgrind = shutil.which ('valgrind') if valgrind is None: print ("""Valgrind requested but not found.""") sys.exit (1) diff --git a/test/subset/run-tests.py b/test/subset/run-tests.py index 7d183507b..1593e620a 100755 --- a/test/subset/run-tests.py +++ b/test/subset/run-tests.py @@ -10,28 +10,12 @@ import re import subprocess import sys import tempfile +import shutil from subset_test_suite import SubsetTestSuite -# https://stackoverflow.com/a/377028 -def which (program): - def is_exe (fpath): - return os.path.isfile (fpath) and os.access (fpath, os.X_OK) - - fpath, _ = os.path.split (program) - if fpath: - if is_exe (program): - return program - else: - for path in os.environ["PATH"].split (os.pathsep): - exe_file = os.path.join (path, program) - if is_exe (exe_file): - return exe_file - - return None - -fonttools = which ("fonttools") -ots_sanitize = which ("ots-sanitize") +fonttools = shutil.which ("fonttools") +ots_sanitize = shutil.which ("ots-sanitize") if not fonttools: print ("fonttools is not present, skipping test.")