Index: tools/testing/test_case.py |
=================================================================== |
--- tools/testing/test_case.py (revision 1427) |
+++ tools/testing/test_case.py (working copy) |
@@ -60,7 +60,29 @@ |
if not self.context.keep_temporary_files: |
self.run_arch.Cleanup() |
+ def BeforeRunHelper(self, command): |
Siggi Cherem (dart-lang)
2011/11/11 00:06:02
I'm not sure why this refactoring needed?
Emily Fortuna
2011/11/11 00:58:41
Because I wanted to be able to compile tests, but
|
+ """Helper method to merge shared code between StandardTestCase and |
+ BrowserTestCase""" |
+ if command: |
+ # We change the directory where dartc/frog will be launched because |
+ # it is not predictable on the location of the compiled file. In |
+ # case the test is a web test, we make sure the app file is not |
+ # in a subdirectory. |
+ cwd = None |
+ if self.run_arch.is_web_test: cwd = self.run_arch.temp_dir |
+ command = command[:1] + self.context.flags + command[1:] |
+ test_output = self.RunCommand(command, cwd=cwd, cleanup=False) |
+ # If errors were found, fail fast and show compile errors: |
+ if test_output.output.exit_code != 0: |
+ return test_output |
+ |
+ def BeforeRun(self): |
+ """Optionally compile tests.""" |
+ command = self.run_arch.GetCompileCommand() |
+ return self.BeforeRunHelper(command) |
+ |
+ |
class MultiTestCase(StandardTestCase): |
"""Multiple test cases defined within a single *Test.dart file.""" |
@@ -93,7 +115,7 @@ |
class BrowserTestCase(StandardTestCase): |
- """A test case that executes inside a browser (or DumpRenderTree).""" |
+ """A test case that executes inside DumpRenderTree.""" |
def __init__(self, context, path, filename, |
fatal_static_type_errors, mode, arch, component, vm_options=None): |
@@ -101,23 +123,13 @@ |
context, path, filename, mode, arch, component, vm_options) |
self.fatal_static_type_errors = fatal_static_type_errors |
- def Run(self): |
- """Optionally compiles and then runs the specified test.""" |
+ def BeforeRun(self): |
command = self.run_arch.GetCompileCommand(self.fatal_static_type_errors) |
Jennifer Messerly
2011/11/10 23:57:08
as long as this looks good to Siggi it works for m
|
- if command: |
- # We change the directory where dartc will be launched because |
- # it is not predictable on the location of the compiled file. In |
- # case the test is a web test, we make sure the app file is not |
- # in a subdirectory. |
- cwd = None |
- if self.run_arch.is_web_test: cwd = self.run_arch.temp_dir |
- command = command[:1] + self.context.flags + command[1:] |
- test_output = self.RunCommand(command, cwd=cwd, cleanup=False) |
+ return self.BeforeRunHelper(command) |
- # If errors were found, fail fast and show compile errors: |
- if test_output.output.exit_code != 0: |
- return test_output |
- |
+ def Run(self): |
+ """Runs the specified test, with an update to the exit code to compensate |
+ for DumpRenderTree.""" |
command = self.run_arch.GetRunCommand() |
test_output = self.RunCommand(command) |
# The return value of DumpRenderedTree does not indicate test failing, but |