summaryrefslogtreecommitdiffstats
path: root/Tools/Scripts/webkitpy/layout_tests/layout_package
diff options
context:
space:
mode:
Diffstat (limited to 'Tools/Scripts/webkitpy/layout_tests/layout_package')
-rw-r--r--Tools/Scripts/webkitpy/layout_tests/layout_package/dump_render_tree_thread.py18
-rw-r--r--Tools/Scripts/webkitpy/layout_tests/layout_package/json_layout_results_generator.py10
-rw-r--r--Tools/Scripts/webkitpy/layout_tests/layout_package/json_results_generator.py27
-rw-r--r--Tools/Scripts/webkitpy/layout_tests/layout_package/json_results_generator_unittest.py8
-rw-r--r--Tools/Scripts/webkitpy/layout_tests/layout_package/message_broker.py14
-rw-r--r--Tools/Scripts/webkitpy/layout_tests/layout_package/printing.py6
-rw-r--r--Tools/Scripts/webkitpy/layout_tests/layout_package/printing_unittest.py8
-rw-r--r--Tools/Scripts/webkitpy/layout_tests/layout_package/test_expectations.py23
-rw-r--r--Tools/Scripts/webkitpy/layout_tests/layout_package/test_expectations_unittest.py5
-rw-r--r--Tools/Scripts/webkitpy/layout_tests/layout_package/test_failures.py6
-rw-r--r--Tools/Scripts/webkitpy/layout_tests/layout_package/test_failures_unittest.py6
-rw-r--r--Tools/Scripts/webkitpy/layout_tests/layout_package/test_runner.py88
-rw-r--r--Tools/Scripts/webkitpy/layout_tests/layout_package/test_runner_unittest.py6
13 files changed, 113 insertions, 112 deletions
diff --git a/Tools/Scripts/webkitpy/layout_tests/layout_package/dump_render_tree_thread.py b/Tools/Scripts/webkitpy/layout_tests/layout_package/dump_render_tree_thread.py
index 2bb2d02..050eefa 100644
--- a/Tools/Scripts/webkitpy/layout_tests/layout_package/dump_render_tree_thread.py
+++ b/Tools/Scripts/webkitpy/layout_tests/layout_package/dump_render_tree_thread.py
@@ -36,9 +36,6 @@ the output. When there are no more URLs to process in the shared queue, the
thread exits.
"""
-from __future__ import with_statement
-
-import codecs
import copy
import logging
import os
@@ -86,6 +83,7 @@ def _process_output(port, options, test_input, test_types, test_args,
Returns: a TestResult object
"""
failures = []
+ fs = port._filesystem
if test_output.crash:
failures.append(test_failures.FailureCrash())
@@ -96,11 +94,10 @@ def _process_output(port, options, test_input, test_types, test_args,
if test_output.crash:
_log.debug("%s Stacktrace for %s:\n%s" % (worker_name, test_name,
test_output.error))
- filename = os.path.join(options.results_directory, test_name)
- filename = os.path.splitext(filename)[0] + "-stack.txt"
- port.maybe_make_directory(os.path.split(filename)[0])
- with codecs.open(filename, "wb", "utf-8") as file:
- file.write(test_output.error)
+ filename = fs.join(options.results_directory, test_name)
+ filename = fs.splitext(filename)[0] + "-stack.txt"
+ fs.maybe_make_directory(fs.dirname(filename))
+ fs.write_text_file(filename, test_output.error)
elif test_output.error:
_log.debug("%s %s output stderr lines:\n%s" % (worker_name, test_name,
test_output.error))
@@ -385,10 +382,9 @@ class TestShellThread(WatchableThread):
# Append tests we're running to the existing tests_run.txt file.
# This is created in run_webkit_tests.py:_PrepareListsAndPrintOutput.
- tests_run_filename = os.path.join(self._options.results_directory,
+ tests_run_filename = self._port._filesystem.join(self._options.results_directory,
"tests_run.txt")
- tests_run_file = codecs.open(tests_run_filename, "a", "utf-8")
-
+ tests_run_file = self._port._filesystem.open_text_file_for_writing(tests_run_filename, append=False)
while True:
if self._canceled:
_log.debug('Testing cancelled')
diff --git a/Tools/Scripts/webkitpy/layout_tests/layout_package/json_layout_results_generator.py b/Tools/Scripts/webkitpy/layout_tests/layout_package/json_layout_results_generator.py
index b054c5b..3267fb7 100644
--- a/Tools/Scripts/webkitpy/layout_tests/layout_package/json_layout_results_generator.py
+++ b/Tools/Scripts/webkitpy/layout_tests/layout_package/json_layout_results_generator.py
@@ -27,7 +27,6 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import logging
-import os
from webkitpy.layout_tests.layout_package import json_results_generator
from webkitpy.layout_tests.layout_package import test_expectations
@@ -66,12 +65,11 @@ class JSONLayoutResultsGenerator(json_results_generator.JSONResultsGeneratorBase
results.
"""
super(JSONLayoutResultsGenerator, self).__init__(
- builder_name, build_name, build_number, results_file_base_path,
+ port, builder_name, build_name, build_number, results_file_base_path,
builder_base_url, {}, port.test_repository_paths(),
generate_incremental_results, test_results_server,
test_type, master_name)
- self._port = port
self._expectations = expectations
# We want relative paths to LayoutTest root for JSON output.
@@ -181,9 +179,9 @@ class JSONLayoutResultsGenerator(json_results_generator.JSONResultsGeneratorBase
test, test_name, tests)
# Remove tests that don't exist anymore.
- full_path = os.path.join(self._port.layout_tests_dir(), test_name)
- full_path = os.path.normpath(full_path)
- if not os.path.exists(full_path):
+ full_path = self._fs.join(self._port.layout_tests_dir(), test_name)
+ full_path = self._fs.normpath(full_path)
+ if not self._fs.exists(full_path):
del tests[test_name]
def _get_failure_summary_entry(self, timeline):
diff --git a/Tools/Scripts/webkitpy/layout_tests/layout_package/json_results_generator.py b/Tools/Scripts/webkitpy/layout_tests/layout_package/json_results_generator.py
index 12e65b2..32ffd71 100644
--- a/Tools/Scripts/webkitpy/layout_tests/layout_package/json_results_generator.py
+++ b/Tools/Scripts/webkitpy/layout_tests/layout_package/json_results_generator.py
@@ -26,11 +26,7 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-from __future__ import with_statement
-
-import codecs
import logging
-import os
import subprocess
import sys
import time
@@ -118,7 +114,7 @@ class JSONResultsGeneratorBase(object):
URL_FOR_TEST_LIST_JSON = \
"http://%s/testfile?builder=%s&name=%s&testlistjson=1&testtype=%s"
- def __init__(self, builder_name, build_name, build_number,
+ def __init__(self, port, builder_name, build_name, build_number,
results_file_base_path, builder_base_url,
test_results_map, svn_repositories=None,
generate_incremental_results=False,
@@ -129,6 +125,7 @@ class JSONResultsGeneratorBase(object):
if it is not found locally.
Args
+ port: port-specific wrapper
builder_name: the builder name (e.g. Webkit).
build_name: the build name (e.g. webkit-rel).
build_number: the build number.
@@ -146,14 +143,16 @@ class JSONResultsGeneratorBase(object):
test_type: test type string (e.g. 'layout-tests').
master_name: the name of the buildbot master.
"""
+ self._port = port
+ self._fs = port._filesystem
self._builder_name = builder_name
self._build_name = build_name
self._build_number = build_number
self._builder_base_url = builder_base_url
self._results_directory = results_file_base_path
- self._results_file_path = os.path.join(results_file_base_path,
+ self._results_file_path = self._fs.join(results_file_base_path,
self.RESULTS_FILENAME)
- self._incremental_results_file_path = os.path.join(
+ self._incremental_results_file_path = self._fs.join(
results_file_base_path, self.INCREMENTAL_RESULTS_FILENAME)
self._test_results_map = test_results_map
@@ -254,7 +253,7 @@ class JSONResultsGeneratorBase(object):
("testtype", self._test_type),
("master", self._master_name)]
- files = [(file, os.path.join(self._results_directory, file))
+ files = [(file, self._fs.join(self._results_directory, file))
for file in json_files]
uploader = test_results_uploader.TestResultsUploader(
@@ -273,10 +272,7 @@ class JSONResultsGeneratorBase(object):
# Specify separators in order to get compact encoding.
json_data = simplejson.dumps(json, separators=(',', ':'))
json_string = self.JSON_PREFIX + json_data + self.JSON_SUFFIX
-
- results_file = codecs.open(file_path, "w", "utf-8")
- results_file.write(json_string)
- results_file.close()
+ self._fs.write_text_file(file_path, json_string)
def _get_test_timing(self, test_name):
"""Returns test timing data (elapsed time) in second
@@ -330,7 +326,7 @@ class JSONResultsGeneratorBase(object):
Args:
in_directory: The directory where svn is to be run.
"""
- if os.path.exists(os.path.join(in_directory, '.svn')):
+ if self._fs.exists(self._fs.join(in_directory, '.svn')):
# Note: Not thread safe: http://bugs.python.org/issue2320
output = subprocess.Popen(["svn", "info", "--xml"],
cwd=in_directory,
@@ -358,9 +354,8 @@ class JSONResultsGeneratorBase(object):
old_results = None
error = None
- if os.path.exists(self._results_file_path) and not for_incremental:
- with codecs.open(self._results_file_path, "r", "utf-8") as file:
- old_results = file.read()
+ if self._fs.exists(self._results_file_path) and not for_incremental:
+ old_results = self._fs.read_text_file(self._results_file_path)
elif self._builder_base_url or for_incremental:
if for_incremental:
if not self._test_results_server:
diff --git a/Tools/Scripts/webkitpy/layout_tests/layout_package/json_results_generator_unittest.py b/Tools/Scripts/webkitpy/layout_tests/layout_package/json_results_generator_unittest.py
index dad549a..ce99765 100644
--- a/Tools/Scripts/webkitpy/layout_tests/layout_package/json_results_generator_unittest.py
+++ b/Tools/Scripts/webkitpy/layout_tests/layout_package/json_results_generator_unittest.py
@@ -31,11 +31,11 @@
import unittest
import optparse
import random
-import shutil
-import tempfile
+from webkitpy.common.system import filesystem_mock
from webkitpy.layout_tests.layout_package import json_results_generator
from webkitpy.layout_tests.layout_package import test_expectations
+from webkitpy.thirdparty.mock import Mock
class JSONGeneratorTest(unittest.TestCase):
@@ -83,7 +83,9 @@ class JSONGeneratorTest(unittest.TestCase):
failed=(test in failed_tests),
elapsed_time=test_timings[test])
- generator = json_results_generator.JSONResultsGeneratorBase(
+ port = Mock()
+ port._filesystem = filesystem_mock.MockFileSystem()
+ generator = json_results_generator.JSONResultsGeneratorBase(port,
self.builder_name, self.build_name, self.build_number,
'',
None, # don't fetch past json results archive
diff --git a/Tools/Scripts/webkitpy/layout_tests/layout_package/message_broker.py b/Tools/Scripts/webkitpy/layout_tests/layout_package/message_broker.py
index e0ca8db..481c617 100644
--- a/Tools/Scripts/webkitpy/layout_tests/layout_package/message_broker.py
+++ b/Tools/Scripts/webkitpy/layout_tests/layout_package/message_broker.py
@@ -144,6 +144,13 @@ class MultiThreadedBroker(WorkerMessageBroker):
some_thread_is_alive = False
t = time.time()
for thread in threads:
+ if thread.isAlive():
+ some_thread_is_alive = True
+ next_timeout = thread.next_timeout()
+ if next_timeout and t > next_timeout:
+ log_wedged_worker(thread.getName(), thread.id())
+ thread.clear_next_timeout()
+
exception_info = thread.exception_info()
if exception_info is not None:
# Re-raise the thread's exception here to make it
@@ -152,13 +159,6 @@ class MultiThreadedBroker(WorkerMessageBroker):
# to have passed.
raise exception_info[0], exception_info[1], exception_info[2]
- if thread.isAlive():
- some_thread_is_alive = True
- next_timeout = thread.next_timeout()
- if next_timeout and t > next_timeout:
- log_wedged_worker(thread.getName(), thread.id())
- thread.clear_next_timeout()
-
self._test_runner.update()
if some_thread_is_alive:
diff --git a/Tools/Scripts/webkitpy/layout_tests/layout_package/printing.py b/Tools/Scripts/webkitpy/layout_tests/layout_package/printing.py
index 7a6aad1..e10ad99 100644
--- a/Tools/Scripts/webkitpy/layout_tests/layout_package/printing.py
+++ b/Tools/Scripts/webkitpy/layout_tests/layout_package/printing.py
@@ -31,8 +31,6 @@
import logging
import optparse
-import os
-import pdb
from webkitpy.layout_tests.layout_package import metered_stream
from webkitpy.layout_tests.layout_package import test_expectations
@@ -411,7 +409,7 @@ class Printer(object):
return
next_test = test_list[self._current_test_number]
- next_dir = os.path.dirname(
+ next_dir = self._port._filesystem.dirname(
self._port.relative_test_filename(next_test))
if self._current_progress_str == "":
self._current_progress_str = "%s: " % (next_dir)
@@ -437,7 +435,7 @@ class Printer(object):
break
next_test = test_list[self._current_test_number]
- next_dir = os.path.dirname(
+ next_dir = self._port._filesystem.dirname(
self._port.relative_test_filename(next_test))
if result_summary.remaining:
diff --git a/Tools/Scripts/webkitpy/layout_tests/layout_package/printing_unittest.py b/Tools/Scripts/webkitpy/layout_tests/layout_package/printing_unittest.py
index 9280b02..12a786e 100644
--- a/Tools/Scripts/webkitpy/layout_tests/layout_package/printing_unittest.py
+++ b/Tools/Scripts/webkitpy/layout_tests/layout_package/printing_unittest.py
@@ -29,10 +29,7 @@
"""Unit tests for printing.py."""
-import os
import optparse
-import pdb
-import sys
import unittest
import logging
@@ -117,6 +114,7 @@ class TestUtilityFunctions(unittest.TestCase):
class Testprinter(unittest.TestCase):
def get_printer(self, args=None, single_threaded=False,
is_fully_parallel=False):
+ args = args or []
printing_options = printing.print_options()
option_parser = optparse.OptionParser(option_list=printing_options)
options, args = option_parser.parse_args(args)
@@ -138,11 +136,11 @@ class Testprinter(unittest.TestCase):
failures = [test_failures.FailureTimeout()]
elif result_type == test_expectations.CRASH:
failures = [test_failures.FailureCrash()]
- path = os.path.join(self._port.layout_tests_dir(), test)
+ path = self._port._filesystem.join(self._port.layout_tests_dir(), test)
return test_results.TestResult(path, failures=failures, test_run_time=run_time)
def get_result_summary(self, tests, expectations_str):
- test_paths = [os.path.join(self._port.layout_tests_dir(), test) for
+ test_paths = [self._port._filesystem.join(self._port.layout_tests_dir(), test) for
test in tests]
expectations = test_expectations.TestExpectations(
self._port, test_paths, expectations_str,
diff --git a/Tools/Scripts/webkitpy/layout_tests/layout_package/test_expectations.py b/Tools/Scripts/webkitpy/layout_tests/layout_package/test_expectations.py
index 8645fc1..806b663 100644
--- a/Tools/Scripts/webkitpy/layout_tests/layout_package/test_expectations.py
+++ b/Tools/Scripts/webkitpy/layout_tests/layout_package/test_expectations.py
@@ -32,9 +32,7 @@ for layout tests.
"""
import logging
-import os
import re
-import sys
import webkitpy.thirdparty.simplejson as simplejson
@@ -322,6 +320,7 @@ class TestExpectationsFile:
"""
self._port = port
+ self._fs = port._filesystem
self._expectations = expectations
self._full_test_list = full_test_list
self._test_platform_name = test_platform_name
@@ -690,9 +689,9 @@ class TestExpectationsFile:
'indefinitely, then it should be just timeout.',
test_list_path)
- full_path = os.path.join(self._port.layout_tests_dir(),
- test_list_path)
- full_path = os.path.normpath(full_path)
+ full_path = self._fs.join(self._port.layout_tests_dir(),
+ test_list_path)
+ full_path = self._fs.normpath(full_path)
# WebKit's way of skipping tests is to add a -disabled suffix.
# So we should consider the path existing if the path or the
# -disabled version exists.
@@ -736,11 +735,11 @@ class TestExpectationsFile:
# lists to represent the tree of tests, leaves being test
# files and nodes being categories.
- path = os.path.join(self._port.layout_tests_dir(), test_list_path)
- path = os.path.normpath(path)
- if self._port.path_isdir(path):
+ path = self._fs.join(self._port.layout_tests_dir(), test_list_path)
+ path = self._fs.normpath(path)
+ if self._fs.isdir(path):
# this is a test category, return all the tests of the category.
- path = os.path.join(path, '')
+ path = self._fs.join(path, '')
return [test for test in self._full_test_list if test.startswith(path)]
@@ -817,7 +816,7 @@ class TestExpectationsFile:
self._remove_from_sets(test, self._timeline_to_tests)
self._remove_from_sets(test, self._result_type_to_tests)
- self._test_list_paths[test] = os.path.normpath(test_list_path)
+ self._test_list_paths[test] = self._fs.normpath(test_list_path)
def _remove_from_sets(self, test, dict):
"""Removes the given test from the sets in the dictionary.
@@ -838,7 +837,7 @@ class TestExpectationsFile:
return False
prev_base_path = self._test_list_paths[test]
- if (prev_base_path == os.path.normpath(test_list_path)):
+ if (prev_base_path == self._fs.normpath(test_list_path)):
if (not allow_overrides or test in self._overridding_tests):
if allow_overrides:
expectation_source = "override"
@@ -854,7 +853,7 @@ class TestExpectationsFile:
return False
# Check if we've already seen a more precise path.
- return prev_base_path.startswith(os.path.normpath(test_list_path))
+ return prev_base_path.startswith(self._fs.normpath(test_list_path))
def _add_error(self, lineno, msg, path):
"""Reports an error that will prevent running the tests. Does not
diff --git a/Tools/Scripts/webkitpy/layout_tests/layout_package/test_expectations_unittest.py b/Tools/Scripts/webkitpy/layout_tests/layout_package/test_expectations_unittest.py
index 34771f3..8f9e5dd 100644
--- a/Tools/Scripts/webkitpy/layout_tests/layout_package/test_expectations_unittest.py
+++ b/Tools/Scripts/webkitpy/layout_tests/layout_package/test_expectations_unittest.py
@@ -29,8 +29,6 @@
"""Unit tests for test_expectations.py."""
-import os
-import sys
import unittest
from webkitpy.layout_tests import port
@@ -82,11 +80,12 @@ class FunctionsTest(unittest.TestCase):
class Base(unittest.TestCase):
def __init__(self, testFunc, setUp=None, tearDown=None, description=None):
self._port = port.get('test', None)
+ self._fs = self._port._filesystem
self._exp = None
unittest.TestCase.__init__(self, testFunc)
def get_test(self, test_name):
- return os.path.join(self._port.layout_tests_dir(), test_name)
+ return self._fs.join(self._port.layout_tests_dir(), test_name)
def get_basic_tests(self):
return [self.get_test('failures/expected/text.html'),
diff --git a/Tools/Scripts/webkitpy/layout_tests/layout_package/test_failures.py b/Tools/Scripts/webkitpy/layout_tests/layout_package/test_failures.py
index 2b8190b..eb59d36 100644
--- a/Tools/Scripts/webkitpy/layout_tests/layout_package/test_failures.py
+++ b/Tools/Scripts/webkitpy/layout_tests/layout_package/test_failures.py
@@ -29,7 +29,6 @@
"""Classes for failures that occur during tests."""
-import os
import test_expectations
import cPickle
@@ -121,7 +120,10 @@ class TestFailure(object):
Return:
The relative windows path to the output filename
"""
- return os.path.splitext(filename)[0] + modifier
+ # FIXME: technically this breaks if files don't use ".ext" to indicate
+ # the extension, but passing in a Filesystem object here is a huge
+ # hassle.
+ return filename[:filename.rfind('.')] + modifier
class FailureWithType(TestFailure):
diff --git a/Tools/Scripts/webkitpy/layout_tests/layout_package/test_failures_unittest.py b/Tools/Scripts/webkitpy/layout_tests/layout_package/test_failures_unittest.py
index b2698d1..c5aa2d6 100644
--- a/Tools/Scripts/webkitpy/layout_tests/layout_package/test_failures_unittest.py
+++ b/Tools/Scripts/webkitpy/layout_tests/layout_package/test_failures_unittest.py
@@ -89,6 +89,12 @@ class Test(unittest.TestCase):
crash_set = set([FailureCrash(), "FailureCrash"])
self.assertEqual(len(crash_set), 2)
+ def test_relative_output_filename(self):
+ # This could be any Failure* object, since we're testing a method
+ # on the base class.
+ failure_obj = FailureTextMismatch()
+ actual_filename = failure_obj.relative_output_filename("fast/html/article-element.html", "-actual.txt")
+ self.assertEquals(actual_filename, "fast/html/article-element-actual.txt")
if __name__ == '__main__':
unittest.main()
diff --git a/Tools/Scripts/webkitpy/layout_tests/layout_package/test_runner.py b/Tools/Scripts/webkitpy/layout_tests/layout_package/test_runner.py
index 5b02a00..6c07850 100644
--- a/Tools/Scripts/webkitpy/layout_tests/layout_package/test_runner.py
+++ b/Tools/Scripts/webkitpy/layout_tests/layout_package/test_runner.py
@@ -37,14 +37,11 @@ create a final report.
from __future__ import with_statement
-import codecs
import errno
import logging
import math
-import os
import Queue
import random
-import shutil
import sys
import time
@@ -68,8 +65,6 @@ _log = logging.getLogger("webkitpy.layout_tests.run_webkit_tests")
# Builder base URL where we have the archived test results.
BUILDER_BASE_URL = "http://build.chromium.org/buildbot/layout_test_results/"
-LAYOUT_TESTS_DIRECTORY = "LayoutTests" + os.sep
-
TestExpectationsFile = test_expectations.TestExpectationsFile
@@ -160,8 +155,6 @@ class TestRunner:
"""A class for managing running a series of tests on a series of layout
test files."""
- HTTP_SUBDIR = os.sep.join(['', 'http', ''])
- WEBSOCKET_SUBDIR = os.sep.join(['', 'websocket', ''])
# The per-test timeout in milliseconds, if no --time-out-ms option was
# given to run_webkit_tests. This should correspond to the default timeout
@@ -177,10 +170,16 @@ class TestRunner:
printer: a Printer object to record updates to.
"""
self._port = port
+ self._fs = port._filesystem
self._options = options
self._printer = printer
self._message_broker = None
+ self.HTTP_SUBDIR = self._fs.join('', 'http', '')
+ self.WEBSOCKET_SUBDIR = self._fs.join('', 'websocket', '')
+ self.LAYOUT_TESTS_DIRECTORY = "LayoutTests" + self._fs.sep
+
+
# disable wss server. need to install pyOpenSSL on buildbots.
# self._websocket_secure_server = websocket_server.PyWebSocket(
# options.results_directory, use_tls=True, port=9323)
@@ -199,15 +198,18 @@ class TestRunner:
last_unexpected_results: list of unexpected results to retest, if any
"""
- paths = [self._strip_test_dir_prefix(arg) for arg in args if arg and arg != '']
+ paths = self._strip_test_dir_prefixes(args)
paths += last_unexpected_results
if self._options.test_list:
- paths += read_test_files(self._options.test_list)
+ paths += self._strip_test_dir_prefixes(read_test_files(self._fs, self._options.test_list))
self._test_files = self._port.tests(paths)
+ def _strip_test_dir_prefixes(self, paths):
+ return [self._strip_test_dir_prefix(path) for path in paths if path]
+
def _strip_test_dir_prefix(self, path):
- if path.startswith(LAYOUT_TESTS_DIRECTORY):
- return path[len(LAYOUT_TESTS_DIRECTORY):]
+ if path.startswith(self.LAYOUT_TESTS_DIRECTORY):
+ return path[len(self.LAYOUT_TESTS_DIRECTORY):]
return path
def lint(self):
@@ -339,10 +341,9 @@ class TestRunner:
self._printer.print_expected(extra_msg)
tests_run_msg += "\n" + extra_msg
files.extend(test_files[0:extra])
- tests_run_filename = os.path.join(self._options.results_directory,
+ tests_run_filename = self._fs.join(self._options.results_directory,
"tests_run.txt")
- with codecs.open(tests_run_filename, "w", "utf-8") as file:
- file.write(tests_run_msg + "\n")
+ self._fs.write_text_file(tests_run_filename, tests_run_msg)
len_skip_chunk = int(len(files) * len(skipped) /
float(len(self._test_files)))
@@ -390,15 +391,20 @@ class TestRunner:
result_summary.add(result, expected=True)
self._printer.print_expected('')
+ # Check to make sure we didn't filter out all of the tests.
+ if not len(self._test_files):
+ _log.info("All tests are being skipped")
+ return None
+
return result_summary
def _get_dir_for_test_file(self, test_file):
"""Returns the highest-level directory by which to shard the given
test file."""
- index = test_file.rfind(os.sep + LAYOUT_TESTS_DIRECTORY)
+ index = test_file.rfind(self._fs.sep + self.LAYOUT_TESTS_DIRECTORY)
- test_file = test_file[index + len(LAYOUT_TESTS_DIRECTORY):]
- test_file_parts = test_file.split(os.sep, 1)
+ test_file = test_file[index + len(self.LAYOUT_TESTS_DIRECTORY):]
+ test_file_parts = test_file.split(self._fs.sep, 1)
directory = test_file_parts[0]
test_file = test_file_parts[1]
@@ -408,10 +414,10 @@ class TestRunner:
# what made them stable on linux/mac.
return_value = directory
while ((directory != 'http' or sys.platform in ('darwin', 'linux2'))
- and test_file.find(os.sep) >= 0):
- test_file_parts = test_file.split(os.sep, 1)
+ and test_file.find(self._fs.sep) >= 0):
+ test_file_parts = test_file.split(self._fs.sep, 1)
directory = test_file_parts[0]
- return_value = os.path.join(return_value, directory)
+ return_value = self._fs.join(return_value, directory)
test_file = test_file_parts[1]
return return_value
@@ -427,7 +433,7 @@ class TestRunner:
def _test_requires_lock(self, test_file):
"""Return True if the test needs to be locked when
running multiple copies of NRWTs."""
- split_path = test_file.split(os.sep)
+ split_path = test_file.split(self._port._filesystem.sep)
return 'http' in split_path or 'websocket' in split_path
def _test_is_slow(self, test_file):
@@ -757,10 +763,9 @@ class TestRunner:
layout_tests_dir = self._port.layout_tests_dir()
possible_dirs = self._port.test_dirs()
for dirname in possible_dirs:
- if os.path.isdir(os.path.join(layout_tests_dir, dirname)):
- shutil.rmtree(os.path.join(self._options.results_directory,
- dirname),
- ignore_errors=True)
+ if self._fs.isdir(self._fs.join(layout_tests_dir, dirname)):
+ self._fs.rmtree(self._fs.join(self._options.results_directory,
+ dirname))
def _get_failures(self, result_summary, include_crashes):
"""Filters a dict of results and returns only the failures.
@@ -803,17 +808,17 @@ class TestRunner:
"""
results_directory = self._options.results_directory
_log.debug("Writing JSON files in %s." % results_directory)
- unexpected_json_path = os.path.join(results_directory, "unexpected_results.json")
- with codecs.open(unexpected_json_path, "w", "utf-8") as file:
+ unexpected_json_path = self._fs.join(results_directory, "unexpected_results.json")
+ with self._fs.open_text_file_for_writing(unexpected_json_path) as file:
simplejson.dump(unexpected_results, file, sort_keys=True, indent=2)
# Write a json file of the test_expectations.txt file for the layout
# tests dashboard.
- expectations_path = os.path.join(results_directory, "expectations.json")
+ expectations_path = self._fs.join(results_directory, "expectations.json")
expectations_json = \
self._expectations.get_expectations_json_for_all_platforms()
- with codecs.open(expectations_path, "w", "utf-8") as file:
- file.write(u"ADD_EXPECTATIONS(%s);" % expectations_json)
+ self._fs.write_text_file(expectations_path,
+ u"ADD_EXPECTATIONS(%s);" % expectations_json)
generator = json_layout_results_generator.JSONLayoutResultsGenerator(
self._port, self._options.builder_name, self._options.build_name,
@@ -1184,9 +1189,9 @@ class TestRunner:
if not len(test_files):
return False
- out_filename = os.path.join(self._options.results_directory,
- "results.html")
- with codecs.open(out_filename, "w", "utf-8") as results_file:
+ out_filename = self._fs.join(self._options.results_directory,
+ "results.html")
+ with self._fs.open_text_file_for_writing(out_filename) as results_file:
html = self._results_html(test_files, result_summary.failures, results_title)
results_file.write(html)
@@ -1194,21 +1199,20 @@ class TestRunner:
def _show_results_html_file(self):
"""Shows the results.html page."""
- results_filename = os.path.join(self._options.results_directory,
- "results.html")
+ results_filename = self._fs.join(self._options.results_directory,
+ "results.html")
self._port.show_results_html_file(results_filename)
-def read_test_files(files):
+def read_test_files(fs, files):
tests = []
for file in files:
try:
- with codecs.open(file, 'r', 'utf-8') as file_contents:
- # FIXME: This could be cleaner using a list comprehension.
- for line in file_contents:
- line = test_expectations.strip_comments(line)
- if line:
- tests.append(line)
+ file_contents = fs.read_text_file(file).split('\n')
+ for line in file_contents:
+ line = test_expectations.strip_comments(line)
+ if line:
+ tests.append(line)
except IOError, e:
if e.errno == errno.ENOENT:
_log.critical('')
diff --git a/Tools/Scripts/webkitpy/layout_tests/layout_package/test_runner_unittest.py b/Tools/Scripts/webkitpy/layout_tests/layout_package/test_runner_unittest.py
index 3c564ae..97f8630 100644
--- a/Tools/Scripts/webkitpy/layout_tests/layout_package/test_runner_unittest.py
+++ b/Tools/Scripts/webkitpy/layout_tests/layout_package/test_runner_unittest.py
@@ -32,6 +32,7 @@
import unittest
+from webkitpy.common.system import filesystem_mock
from webkitpy.thirdparty.mock import Mock
import test_runner
@@ -45,6 +46,7 @@ class TestRunnerWrapper(test_runner.TestRunner):
class TestRunnerTest(unittest.TestCase):
def test_results_html(self):
mock_port = Mock()
+ mock_port._filesystem = filesystem_mock.MockFileSystem()
mock_port.relative_test_filename = lambda name: name
mock_port.filename_to_uri = lambda name: name
@@ -66,7 +68,9 @@ class TestRunnerTest(unittest.TestCase):
def test_shard_tests(self):
# Test that _shard_tests in test_runner.TestRunner really
# put the http tests first in the queue.
- runner = TestRunnerWrapper(port=Mock(), options=Mock(),
+ port = Mock()
+ port._filesystem = filesystem_mock.MockFileSystem()
+ runner = TestRunnerWrapper(port=port, options=Mock(),
printer=Mock())
test_list = [