diff options
Diffstat (limited to 'deps/v8/tools/testrunner')
-rw-r--r-- | deps/v8/tools/testrunner/base_runner.py | 15 | ||||
-rw-r--r-- | deps/v8/tools/testrunner/local/android.py | 7 | ||||
-rw-r--r-- | deps/v8/tools/testrunner/local/command.py | 2 | ||||
-rw-r--r-- | deps/v8/tools/testrunner/local/pool.py | 3 | ||||
-rwxr-xr-x | deps/v8/tools/testrunner/num_fuzzer.py | 2 | ||||
-rw-r--r-- | deps/v8/tools/testrunner/objects/predictable.py | 3 | ||||
-rw-r--r-- | deps/v8/tools/testrunner/objects/testcase.py | 90 | ||||
-rwxr-xr-x | deps/v8/tools/testrunner/standard_runner.py | 2 | ||||
-rw-r--r-- | deps/v8/tools/testrunner/testproc/progress.py | 7 |
9 files changed, 107 insertions, 24 deletions
diff --git a/deps/v8/tools/testrunner/base_runner.py b/deps/v8/tools/testrunner/base_runner.py index 481cc10134..fcb2202f8a 100644 --- a/deps/v8/tools/testrunner/base_runner.py +++ b/deps/v8/tools/testrunner/base_runner.py @@ -73,13 +73,12 @@ TEST_MAP = { ], # This needs to stay in sync with test/d8_default.isolate. "d8_default": [ - # TODO(machenbach): uncomment after infra side lands. - #"debugger", + "debugger", "mjsunit", "webkit", - #"message", - #"preparser", - #"intl", + "message", + "preparser", + "intl", ], # This needs to stay in sync with test/optimize_for_size.isolate. "optimize_for_size": [ @@ -312,6 +311,9 @@ class BaseTestRunner(object): parser.add_option("--junitout", help="File name of the JUnit output") parser.add_option("--junittestsuite", default="v8tests", help="The testsuite name in the JUnit output file") + parser.add_option("--exit-after-n-failures", type="int", default=100, + help="Exit after the first N failures instead of " + "running all tests. Pass 0 to disable this feature.") # Rerun parser.add_option("--rerun-failures-count", default=0, type=int, @@ -745,6 +747,9 @@ class BaseTestRunner(object): self.mode_options.execution_mode)) return procs + def _create_result_tracker(self, options): + return progress.ResultsTracker(options.exit_after_n_failures) + def _create_timeout_proc(self, options): if not options.total_timeout_sec: return None diff --git a/deps/v8/tools/testrunner/local/android.py b/deps/v8/tools/testrunner/local/android.py index fb25bb5a17..707614f095 100644 --- a/deps/v8/tools/testrunner/local/android.py +++ b/deps/v8/tools/testrunner/local/android.py @@ -18,8 +18,9 @@ DEVICE_DIR = '/data/local/tmp/v8/' class TimeoutException(Exception): - def __init__(self, timeout): + def __init__(self, timeout, output=None): self.timeout = timeout + self.output = output class CommandFailedException(Exception): @@ -170,8 +171,8 @@ class _Driver(object): return '\n'.join(output) except device_errors.AdbCommandFailedError as e: raise CommandFailedException(e.status, e.output) - except device_errors.CommandTimeoutError: - raise TimeoutException(timeout) + except device_errors.CommandTimeoutError as e: + raise TimeoutException(timeout, e.output) if logcat_file: diff --git a/deps/v8/tools/testrunner/local/command.py b/deps/v8/tools/testrunner/local/command.py index 302d568e87..d176323d02 100644 --- a/deps/v8/tools/testrunner/local/command.py +++ b/deps/v8/tools/testrunner/local/command.py @@ -211,7 +211,7 @@ class AndroidCommand(BaseCommand): """ self.shell_name = os.path.basename(shell) self.shell_dir = os.path.dirname(shell) - self.files_to_push = resources_func() + self.files_to_push = (resources_func or (lambda: []))() # Make all paths in arguments relative and also prepare files from arguments # for pushing to the device. diff --git a/deps/v8/tools/testrunner/local/pool.py b/deps/v8/tools/testrunner/local/pool.py index 7c9a250bc3..9735f8ea66 100644 --- a/deps/v8/tools/testrunner/local/pool.py +++ b/deps/v8/tools/testrunner/local/pool.py @@ -26,6 +26,9 @@ def setup_testing(): from threading import Thread as Process # Monkeypatch threading Queue to look like multiprocessing Queue. Queue.cancel_join_thread = lambda self: None + # Monkeypatch os.kill and add fake pid property on Thread. + os.kill = lambda *args: None + Process.pid = property(lambda self: None) class NormalResult(): diff --git a/deps/v8/tools/testrunner/num_fuzzer.py b/deps/v8/tools/testrunner/num_fuzzer.py index b55dd2102d..3b76541604 100755 --- a/deps/v8/tools/testrunner/num_fuzzer.py +++ b/deps/v8/tools/testrunner/num_fuzzer.py @@ -138,7 +138,7 @@ class NumFuzzer(base_runner.BaseTestRunner): fuzzer_rng = random.Random(options.fuzzer_random_seed) combiner = self._create_combiner(fuzzer_rng, options) - results = ResultsTracker() + results = self._create_result_tracker(options) execproc = ExecutionProc(options.j) sigproc = self._create_signal_proc() indicators = self._create_progress_indicators(options) diff --git a/deps/v8/tools/testrunner/objects/predictable.py b/deps/v8/tools/testrunner/objects/predictable.py index 48279d625c..52d14ea460 100644 --- a/deps/v8/tools/testrunner/objects/predictable.py +++ b/deps/v8/tools/testrunner/objects/predictable.py @@ -45,5 +45,4 @@ class OutProc(outproc_base.BaseOutProc): class PredictableFilterProc(testproc_base.TestProcFilter): def _filter(self, test): - return (statusfile.FAIL in test.expected_outcomes or - test.output_proc.negative) + return test.skip_predictable() diff --git a/deps/v8/tools/testrunner/objects/testcase.py b/deps/v8/tools/testrunner/objects/testcase.py index 7416590dd0..de8bc561eb 100644 --- a/deps/v8/tools/testrunner/objects/testcase.py +++ b/deps/v8/tools/testrunner/objects/testcase.py @@ -37,6 +37,21 @@ from ..local import utils FLAGS_PATTERN = re.compile(r"//\s+Flags:(.*)") +# Patterns for additional resource files on Android. Files that are not covered +# by one of the other patterns below will be specified in the resources section. +RESOURCES_PATTERN = re.compile(r"//\s+Resources:(.*)") +# Pattern to auto-detect files to push on Android for statements like: +# load("path/to/file.js") +LOAD_PATTERN = re.compile( + r"(?:load|readbuffer|read)\((?:'|\")([^'\"]*)(?:'|\")\)") +# Pattern to auto-detect files to push on Android for statements like: +# import "path/to/file.js" +MODULE_RESOURCES_PATTERN_1 = re.compile( + r"(?:import|export)(?:\(| )(?:'|\")([^'\"]*)(?:'|\")") +# Pattern to auto-detect files to push on Android for statements like: +# import foobar from "path/to/file.js" +MODULE_RESOURCES_PATTERN_2 = re.compile( + r"(?:import|export).*from (?:'|\")([^'\"]*)(?:'|\")") class TestCase(object): @@ -143,7 +158,10 @@ class TestCase(object): def get_command(self): params = self._get_cmd_params() env = self._get_cmd_env() - shell, shell_flags = self._get_shell_with_flags() + shell = self.get_shell() + if utils.IsWindows(): + shell += '.exe' + shell_flags = self._get_shell_flags() timeout = self._get_timeout(params) return self._create_cmd(shell, shell_flags + params, env, timeout) @@ -207,14 +225,8 @@ class TestCase(object): def _get_suite_flags(self): return [] - def _get_shell_with_flags(self): - shell = self.get_shell() - shell_flags = [] - if shell == 'd8': - shell_flags.append('--test') - if utils.IsWindows(): - shell += '.exe' - return shell, shell_flags + def _get_shell_flags(self): + return [] def _get_timeout(self, params): timeout = self._test_config.timeout @@ -228,7 +240,7 @@ class TestCase(object): return timeout def get_shell(self): - return 'd8' + raise NotImplementedError() def _get_suffix(self): return '.js' @@ -269,6 +281,10 @@ class TestCase(object): """ return [] + def skip_predictable(self): + """Returns True if the test case is not suitable for predictable testing.""" + return True + @property def output_proc(self): if self.expected_outcomes is outproc.OUTCOMES_PASS: @@ -285,3 +301,57 @@ class TestCase(object): def __str__(self): return self.suite.name + '/' + self.name + + +class D8TestCase(TestCase): + def get_shell(self): + return "d8" + + def _get_shell_flags(self): + return ['--test'] + + def _get_resources_for_file(self, file): + """Returns for a given file a list of absolute paths of files needed by the + given file. + """ + with open(file) as f: + source = f.read() + result = [] + def add_path(path): + result.append(os.path.abspath(path.replace('/', os.path.sep))) + for match in RESOURCES_PATTERN.finditer(source): + # There are several resources per line. Relative to base dir. + for path in match.group(1).strip().split(): + add_path(path) + for match in LOAD_PATTERN.finditer(source): + # Files in load statements are relative to base dir. + add_path(match.group(1)) + for match in MODULE_RESOURCES_PATTERN_1.finditer(source): + # Imported files are relative to the file importing them. + add_path(os.path.join(os.path.dirname(file), match.group(1))) + for match in MODULE_RESOURCES_PATTERN_2.finditer(source): + # Imported files are relative to the file importing them. + add_path(os.path.join(os.path.dirname(file), match.group(1))) + return result + + def _get_resources(self): + """Returns the list of files needed by a test case.""" + if not self._get_source_path(): + return [] + result = set() + to_check = [self._get_source_path()] + # Recurse over all files until reaching a fixpoint. + while to_check: + next_resource = to_check.pop() + result.add(next_resource) + for resource in self._get_resources_for_file(next_resource): + # Only add files that exist on disc. The pattens we check for give some + # false positives otherwise. + if resource not in result and os.path.exists(resource): + to_check.append(resource) + return sorted(list(result)) + + def skip_predictable(self): + """Returns True if the test case is not suitable for predictable testing.""" + return (statusfile.FAIL in self.expected_outcomes or + self.output_proc.negative) diff --git a/deps/v8/tools/testrunner/standard_runner.py b/deps/v8/tools/testrunner/standard_runner.py index bd5df9b482..bf7d3f133d 100755 --- a/deps/v8/tools/testrunner/standard_runner.py +++ b/deps/v8/tools/testrunner/standard_runner.py @@ -282,7 +282,7 @@ class StandardTestRunner(base_runner.BaseTestRunner): print '>>> Running with test processors' loader = LoadProc() tests_counter = TestsCounter() - results = ResultsTracker() + results = self._create_result_tracker(options) indicators = self._create_progress_indicators(options) outproc_factory = None diff --git a/deps/v8/tools/testrunner/testproc/progress.py b/deps/v8/tools/testrunner/testproc/progress.py index 221c64bfdd..50b7307e1c 100644 --- a/deps/v8/tools/testrunner/testproc/progress.py +++ b/deps/v8/tools/testrunner/testproc/progress.py @@ -32,13 +32,15 @@ class TestsCounter(base.TestProcObserver): class ResultsTracker(base.TestProcObserver): - def __init__(self): + """Tracks number of results and stops to run tests if max_failures reached.""" + def __init__(self, max_failures): super(ResultsTracker, self).__init__() self._requirement = base.DROP_OUTPUT self.failed = 0 self.remaining = 0 self.total = 0 + self.max_failures = max_failures def _on_next_test(self, test): self.total += 1 @@ -48,6 +50,9 @@ class ResultsTracker(base.TestProcObserver): self.remaining -= 1 if result.has_unexpected_output: self.failed += 1 + if self.max_failures and self.failed >= self.max_failures: + print '>>> Too many failures, exiting...' + self.stop() class ProgressIndicator(base.TestProcObserver): |