Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(93)

Unified Diff: tools/tests/base_unittest.py

Issue 156173005: Create a common utility for finding and running binaries in out/ (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Lint Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/find_run_binary.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/tests/base_unittest.py
diff --git a/tools/tests/base_unittest.py b/tools/tests/base_unittest.py
index 096039915b12cc03c0737034cc4601a05d6db054..2adaed0b70d050b1769c6e207bf9809952470d5a 100755
--- a/tools/tests/base_unittest.py
+++ b/tools/tests/base_unittest.py
@@ -11,9 +11,14 @@ for various unittests within this directory.
"""
import os
-import subprocess
+import sys
import unittest
+# Set the PYTHONPATH to include the tools directory.
+sys.path.append(
+ os.path.join(os.path.dirname(os.path.realpath(__file__)), os.pardir))
+import find_run_binary
+
class TestCase(unittest.TestCase):
@@ -34,13 +39,7 @@ class TestCase(unittest.TestCase):
Raises:
Exception: the program exited with a nonzero return code.
"""
- proc = subprocess.Popen(args,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE)
- (stdout, stderr) = proc.communicate()
- if proc.returncode is not 0:
- raise Exception('command "%s" failed: %s' % (args, stderr))
- return stdout
+ return find_run_binary.run_command(args)
def find_path_to_program(self, program):
"""Returns path to an existing program binary.
@@ -54,19 +53,7 @@ class TestCase(unittest.TestCase):
Raises:
Exception: unable to find the program binary.
"""
- trunk_path = os.path.abspath(os.path.join(os.path.dirname(__file__),
- os.pardir, os.pardir))
- possible_paths = [os.path.join(trunk_path, 'out', 'Release', program),
- os.path.join(trunk_path, 'out', 'Debug', program),
- os.path.join(trunk_path, 'out', 'Release',
- program + '.exe'),
- os.path.join(trunk_path, 'out', 'Debug',
- program + '.exe')]
- for try_path in possible_paths:
- if os.path.isfile(try_path):
- return try_path
- raise Exception('cannot find %s in paths %s; maybe you need to '
- 'build %s?' % (program, possible_paths, program))
+ return find_run_binary.find_path_to_program(program)
def main(test_case_class):
« no previous file with comments | « tools/find_run_binary.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698