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

Unified Diff: gm/rebaseline_server/base_unittest.py

Issue 274623002: make compare_rendered_pictures_test.py run end-to-end test (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 7 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
Index: gm/rebaseline_server/base_unittest.py
diff --git a/gm/rebaseline_server/base_unittest.py b/gm/rebaseline_server/base_unittest.py
index eec0c8da0a4e836a97392482e2054baf02ad59c1..3df45a9ee71966b7126875a39c612ca3720bbf6e 100755
--- a/gm/rebaseline_server/base_unittest.py
+++ b/gm/rebaseline_server/base_unittest.py
@@ -13,10 +13,12 @@ for various unittests within this directory.
import filecmp
import os
import shutil
+import subprocess
import tempfile
import unittest
PARENT_DIR = os.path.dirname(os.path.realpath(__file__))
+TRUNK_DIR = os.path.dirname(os.path.dirname(PARENT_DIR))
TESTDATA_DIR = os.path.join(PARENT_DIR, 'testdata')
OUTPUT_DIR_ACTUAL = os.path.join(TESTDATA_DIR, 'outputs', 'actual')
OUTPUT_DIR_EXPECTED = os.path.join(TESTDATA_DIR, 'outputs', 'expected')
@@ -59,6 +61,51 @@ class TestCase(unittest.TestCase):
"""Tell unittest framework to not print docstrings for test cases."""
return None
+ def run_command(self, args):
borenet 2014/05/07 18:47:49 Why not just use subprocess.check_output which see
epoger 2014/05/07 19:27:49 Because I'm stupid, that's why.
+ """Runs a program from the command line and returns stdout.
+
+ Args:
+ args: Command line to run, as a list of string parameters. args[0] is the
+ binary to run.
+
+ Returns:
+ stdout from the program, as a single string.
+
+ 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
+
+ def find_path_to_program(self, program):
+ """Returns path to an existing program binary.
+
+ Args:
+ program: Basename of the program to find (e.g., 'render_pictures').
+
+ Returns:
+ Absolute path to the program binary, as a string.
+
+ Raises:
+ Exception: unable to find the program binary.
+ """
+ possible_paths = [os.path.join(TRUNK_DIR, 'out', 'Release', program),
+ os.path.join(TRUNK_DIR, 'out', 'Debug', program),
+ os.path.join(TRUNK_DIR, 'out', 'Release',
+ program + '.exe'),
+ os.path.join(TRUNK_DIR, '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))
+
def create_empty_dir(path):
"""Create an empty directory at the given path."""

Powered by Google App Engine
This is Rietveld 408576698