Modified: trunk/Tools/Scripts/webkitpy/common/host_mock.py (103013 => 103014)
--- trunk/Tools/Scripts/webkitpy/common/host_mock.py 2011-12-16 03:05:08 UTC (rev 103013)
+++ trunk/Tools/Scripts/webkitpy/common/host_mock.py 2011-12-16 03:41:12 UTC (rev 103014)
@@ -36,11 +36,13 @@
# New-style ports need to move down into webkitpy.common.
from webkitpy.layout_tests.port.factory import PortFactory
+from webkitpy.layout_tests.port.test import add_unit_tests_to_mock_filesystem
class MockHost(MockSystemHost):
def __init__(self, log_executive=False, executive_throws_when_run=None):
MockSystemHost.__init__(self, log_executive, executive_throws_when_run)
+ add_unit_tests_to_mock_filesystem(self.filesystem)
self.web = MockWeb()
self._checkout = MockCheckout()
Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/test.py (103013 => 103014)
--- trunk/Tools/Scripts/webkitpy/layout_tests/port/test.py 2011-12-16 03:05:08 UTC (rev 103013)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/test.py 2011-12-16 03:41:12 UTC (rev 103014)
@@ -35,7 +35,6 @@
from webkitpy.layout_tests.port import Port, Driver, DriverOutput
from webkitpy.layout_tests.models.test_configuration import TestConfiguration
-from webkitpy.common.host_mock import MockHost
from webkitpy.common.system.filesystem_mock import MockFileSystem
@@ -227,35 +226,11 @@
# Here we synthesize an in-memory filesystem from the test list
# in order to fully control the test output and to demonstrate that
# we don't need a real filesystem to run the tests.
-
-def unit_test_filesystem(files=None):
- """Return the FileSystem object used by the unit tests."""
- test_list = unit_test_list()
- files = files or {}
-
- def add_test_file(files, test, suffix, contents):
- dirname = test.name[0:test.name.rfind('/')]
- base = test.base
- add_file(files, dirname + '/' + base + suffix, contents)
-
- def add_file(files, file_name, contents):
- files[LAYOUT_TEST_DIR + '/' + file_name] = contents
-
- # Add each test and the expected output, if any.
- for test in test_list.tests.values():
- add_test_file(files, test, '.html', '')
- if test.is_reftest:
- continue
- if test.actual_audio:
- add_test_file(files, test, '-expected.wav', test.expected_audio)
- continue
-
- add_test_file(files, test, '-expected.txt', test.expected_text)
- add_test_file(files, test, '-expected.png', test.expected_image)
-
-
+def add_unit_tests_to_mock_filesystem(filesystem):
# Add the test_expectations file.
- files[LAYOUT_TEST_DIR + '/platform/test/test_expectations.txt'] = """
+ filesystem.maybe_make_directory(LAYOUT_TEST_DIR + '/platform/test')
+ if not filesystem.exists(LAYOUT_TEST_DIR + '/platform/test/test_expectations.txt'):
+ filesystem.write_text_file(LAYOUT_TEST_DIR + '/platform/test/test_expectations.txt', """
WONTFIX : failures/expected/checksum.html = IMAGE
WONTFIX : failures/expected/crash.html = CRASH
WONTFIX : failures/expected/image.html = IMAGE
@@ -275,9 +250,10 @@
WONTFIX SKIP : failures/expected/hang.html = TIMEOUT
WONTFIX SKIP : failures/expected/keyboard.html = CRASH
WONTFIX SKIP : failures/expected/exception.html = CRASH
-"""
+""")
- add_file(files, 'reftests/foo/reftest.list', """
+ filesystem.maybe_make_directory(LAYOUT_TEST_DIR + '/reftests/foo')
+ filesystem.write_text_file(LAYOUT_TEST_DIR + '/reftests/foo/reftest.list', """
== test.html test-ref.html
== multiple-match-success.html mismatching-ref.html
@@ -301,8 +277,32 @@
# Add in a file should be ignored by port.find_test_files().
#files[LAYOUT_TEST_DIR + '/userscripts/resources/iframe.html'] = 'iframe'
+ def add_file(test, suffix, contents):
+ dirname = filesystem.join(LAYOUT_TEST_DIR, test.name[0:test.name.rfind('/')])
+ base = test.base
+ filesystem.maybe_make_directory(dirname)
+ filesystem.write_binary_file(filesystem.join(dirname, base + suffix), contents)
+
+ # Add each test and the expected output, if any.
+ test_list = unit_test_list()
+ for test in test_list.tests.values():
+ add_file(test, '.html', '')
+ if test.is_reftest:
+ continue
+ if test.actual_audio:
+ add_file(test, '-expected.wav', test.expected_audio)
+ continue
+ add_file(test, '-expected.txt', test.expected_text)
+ add_file(test, '-expected.png', test.expected_image)
+
+ # Clear the list of written files so that we can watch what happens during testing.
+ filesystem.clear_written_files()
+
+
+def unit_test_filesystem(files=None):
+ files = files or {}
fs = MockFileSystem(files, dirs=set(['/mock-checkout'])) # Make sure at least the checkout_root exists as a directory.
- fs._tests = test_list
+ add_unit_tests_to_mock_filesystem(fs)
return fs
@@ -324,14 +324,16 @@
if not port_name or port_name == 'test':
port_name = 'test-mac-leopard'
+ # FIXME: we import this here instead of at the top-level in order to avoid
+ # a circular import. This should be removed when host become a required parameter.
+ from webkitpy.common.host_mock import MockHost
host = host or MockHost()
filesystem = self._set_default_overriding_none(kwargs, 'filesystem', unit_test_filesystem())
Port.__init__(self, host, port_name=port_name, **kwargs)
self._results_directory = None
- assert filesystem._tests
- self._tests = filesystem._tests
+ self._tests = unit_test_list()
self._operating_system = 'mac'
if port_name.startswith('test-win'):