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

Side by Side Diff: tools/tests/base_unittest.py

Issue 283123002: render_pictures: add --mismatchPath flag (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix SkDebuggerGUI 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 unified diff | Download patch
« no previous file with comments | « tools/render_pictures_main.cpp ('k') | tools/tests/render_pictures_test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 2
3 """ 3 """
4 Copyright 2014 Google Inc. 4 Copyright 2014 Google Inc.
5 5
6 Use of this source code is governed by a BSD-style license that can be 6 Use of this source code is governed by a BSD-style license that can be
7 found in the LICENSE file. 7 found in the LICENSE file.
8 8
9 A wrapper around the standard Python unittest library, adding features we need 9 A wrapper around the standard Python unittest library, adding features we need
10 for various unittests within this directory. 10 for various unittests within this directory.
11 """ 11 """
12 12
13 import errno
13 import os 14 import os
15 import shutil
14 import sys 16 import sys
15 import unittest 17 import unittest
16 18
17 # Set the PYTHONPATH to include the tools directory. 19 # Set the PYTHONPATH to include the tools directory.
18 sys.path.append( 20 sys.path.append(
19 os.path.join(os.path.dirname(os.path.realpath(__file__)), os.pardir)) 21 os.path.join(os.path.dirname(os.path.realpath(__file__)), os.pardir))
20 import find_run_binary 22 import find_run_binary
21 23
22 24
23 class TestCase(unittest.TestCase): 25 class TestCase(unittest.TestCase):
24 26
25 def shortDescription(self): 27 def shortDescription(self):
26 """Tell unittest framework to not print docstrings for test cases.""" 28 """Tell unittest framework to not print docstrings for test cases."""
27 return None 29 return None
28 30
31 def create_empty_dir(self, path):
32 """Creates an empty directory at path and returns path.
33
34 Args:
35 path: path on local disk
36 """
37 shutil.rmtree(path=path, ignore_errors=True)
38 try:
39 os.makedirs(path)
40 except OSError as exc:
41 if exc.errno != errno.EEXIST:
42 raise
43 return path
44
29 def run_command(self, args): 45 def run_command(self, args):
30 """Runs a program from the command line and returns stdout. 46 """Runs a program from the command line and returns stdout.
31 47
32 Args: 48 Args:
33 args: Command line to run, as a list of string parameters. args[0] is the 49 args: Command line to run, as a list of string parameters. args[0] is the
34 binary to run. 50 binary to run.
35 51
36 Returns: 52 Returns:
37 stdout from the program, as a single string. 53 stdout from the program, as a single string.
38 54
(...skipping 24 matching lines...) Expand all
63 context of run_all.py, which depends on that Exception to signal failures). 79 context of run_all.py, which depends on that Exception to signal failures).
64 80
65 TODO(epoger): Make all of our unit tests use the Python unittest framework, 81 TODO(epoger): Make all of our unit tests use the Python unittest framework,
66 so we can leverage its ability to run *all* the tests and report failures at 82 so we can leverage its ability to run *all* the tests and report failures at
67 the end. 83 the end.
68 """ 84 """
69 suite = unittest.TestLoader().loadTestsFromTestCase(test_case_class) 85 suite = unittest.TestLoader().loadTestsFromTestCase(test_case_class)
70 results = unittest.TextTestRunner(verbosity=2).run(suite) 86 results = unittest.TextTestRunner(verbosity=2).run(suite)
71 if not results.wasSuccessful(): 87 if not results.wasSuccessful():
72 raise Exception('failed unittest %s' % test_case_class) 88 raise Exception('failed unittest %s' % test_case_class)
OLDNEW
« no previous file with comments | « tools/render_pictures_main.cpp ('k') | tools/tests/render_pictures_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698