Index: tools/testing/test_case.py |
diff --git a/tools/testing/test_case.py b/tools/testing/test_case.py |
index 99af9d566fafc4041925dc61a6fa7970999e6454..e7013f0138011cc823670610274ad32dd351cee4 100644 |
--- a/tools/testing/test_case.py |
+++ b/tools/testing/test_case.py |
@@ -2,29 +2,23 @@ |
# for details. All rights reserved. Use of this source code is governed by a |
# BSD-style license that can be found in the LICENSE file. |
-import atexit |
-import fileinput |
+"""Common TestCase subclasses used to define a single test.""" |
+ |
import os |
-import test |
-import platform |
-import re |
-import sys |
import tempfile |
-import architecture |
import test |
-import utils |
- |
-from os.path import join, exists, basename |
+from testing import architecture |
-import utils |
class Error(Exception): |
pass |
class StandardTestCase(test.TestCase): |
- def __init__(self, context, path, filename, mode, arch, vm_options = []): |
+ """A test case defined by a *Test.dart file.""" |
+ |
+ def __init__(self, context, path, filename, mode, arch, vm_options=None): |
super(StandardTestCase, self).__init__(context, path) |
self.filename = filename |
self.mode = mode |
@@ -34,17 +28,18 @@ class StandardTestCase(test.TestCase): |
for flag in context.flags: |
self.run_arch.vm_options.append(flag) |
- for flag in vm_options: |
- self.run_arch.vm_options.append(flag) |
+ if vm_options: |
+ for flag in vm_options: |
+ self.run_arch.vm_options.append(flag) |
def IsNegative(self): |
- return self.GetName().endswith("NegativeTest") |
+ return self.GetName().endswith('NegativeTest') |
def GetLabel(self): |
- return "%s%s %s" % (self.mode, self.arch, '/'.join(self.path)) |
+ return '%s%s %s' % (self.mode, self.arch, '/'.join(self.path)) |
def GetCommand(self): |
- return self.run_arch.GetRunCommand(); |
+ return self.run_arch.GetRunCommand() |
def GetName(self): |
return self.path[-1] |
@@ -58,20 +53,30 @@ class StandardTestCase(test.TestCase): |
def Cleanup(self): |
# TODO(ngeoffray): We run out of space on the build bots for these tests if |
# the temp directories are not removed right after running the test. |
- if not self.context.keep_temporary_files: self.run_arch.Cleanup() |
+ if not self.context.keep_temporary_files: |
+ self.run_arch.Cleanup() |
class MultiTestCase(StandardTestCase): |
+ """Multiple test cases defined within a single *Test.dart file.""" |
def __init__(self, context, path, filename, kind, mode, arch): |
super(MultiTestCase, self).__init__(context, path, filename, mode, arch) |
self.kind = kind |
def GetCommand(self): |
+ """Returns a commandline to execute to perform the test.""" |
return self.run_arch.GetRunCommand( |
- fatal_static_type_errors=(self.kind == 'static type error')); |
+ fatal_static_type_errors=(self.kind == 'static type error')) |
def IsNegative(self): |
+ """Determine if this is a negative test. by looking at @ directives. |
+ |
+ A negative test is considered to pas if its outcome is FAIL. |
+ |
+ Returns: |
+ True if this is a negative test. |
+ """ |
if self.kind == 'compile-time error': |
return True |
if self.kind == 'runtime error': |
@@ -80,16 +85,19 @@ class MultiTestCase(StandardTestCase): |
return self.run_arch.HasFatalTypeErrors() |
return False |
+ |
class BrowserTestCase(StandardTestCase): |
+ """A test case that executes inside a browser (or DumpRenderTree).""" |
+ |
def __init__(self, context, path, filename, |
fatal_static_type_errors, mode, arch): |
super(BrowserTestCase, self).__init__(context, path, filename, mode, arch) |
self.fatal_static_type_errors = fatal_static_type_errors |
- |
def Run(self): |
+ """Optionally compiles and then runs the specified test.""" |
command = self.run_arch.GetCompileCommand(self.fatal_static_type_errors) |
- if command != None: |
+ 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 |
@@ -103,7 +111,7 @@ class BrowserTestCase(StandardTestCase): |
if test_output.output.exit_code != 0: |
return test_output |
- command = self.run_arch.GetRunCommand(); |
+ command = self.run_arch.GetRunCommand() |
test_output = self.RunCommand(command) |
# The return value of DumpRenderedTree does not indicate test failing, but |
# the output does. |
@@ -114,7 +122,8 @@ class BrowserTestCase(StandardTestCase): |
class CompilationTestCase(test.TestCase): |
- """ Run the dartc compiler on a given top level dart file """ |
+ """Run the dartc compiler on a given top level .dart file.""" |
+ |
def __init__(self, path, context, filename, mode, arch): |
super(CompilationTestCase, self).__init__(context, path) |
self.filename = filename |
@@ -128,10 +137,11 @@ class CompilationTestCase(test.TestCase): |
return False |
def GetLabel(self): |
- return "%s/%s %s" % (self.mode, self.arch, '/'.join(self.path)) |
+ return '%s/%s %s' % (self.mode, self.arch, '/'.join(self.path)) |
def GetCommand(self): |
- cmd = self.context.GetDartC(self.mode, self.arch); |
+ """Returns a command line to run the test.""" |
+ cmd = self.context.GetDartC(self.mode, self.arch) |
cmd += self.context.flags |
cmd += ['-check-only', |
'-fatal-type-errors', |