Diff
Modified: trunk/Tools/ChangeLog (288877 => 288878)
--- trunk/Tools/ChangeLog 2022-02-01 16:11:32 UTC (rev 288877)
+++ trunk/Tools/ChangeLog 2022-02-01 16:35:37 UTC (rev 288878)
@@ -1,3 +1,38 @@
+2022-02-01 Sam Sneddon <gsnedd...@apple.com>
+
+ Migrate LayoutTestFinder tests from FileSystemMock to pyfakefs
+ https://bugs.webkit.org/show_bug.cgi?id=235370
+ <rdar://problem/87785236>
+
+ Reviewed by Jonathan Bedard.
+
+ * Scripts/webkitpy/__init__.py:
+ Register pyfakefs (last Python 2 supporting version).
+ * Scripts/webkitpy/common/host_mock.py:
+ (MockHost.__init__):
+ Pass **kwargs through to MockSystemHost.
+ * Scripts/webkitpy/layout_tests/controllers/layout_test_finder_legacy_unittest.py:
+ (LayoutTestFinderTests):
+ (LayoutTestFinderTests.setUp):
+ Setup the MockHost with pyfakefs.
+ (LayoutTestFinderTests.test_find_glob_b):
+ Uncomment now we don't need to mitigate FileSystemMock bugs.
+ (LayoutTestFinderTests.test_find_glob_c):
+ Uncomment now we don't need to mitigate FileSystemMock bugs.
+ (LayoutTestFinderTests.test_is_w3c_resource_file):
+ Ensure the directory exists before writing.
+ * Scripts/webkitpy/layout_tests/run_webkit_tests_integrationtest.py:
+ (RebaselineTest.test_reset_results):
+ Call fs.clear_written_files before test.
+ (RebaselineTest.test_missing_results):
+ Call fs.clear_written_files before test.
+ (RebaselineTest.test_new_baseline):
+ Call fs.clear_written_files before test.
+ * Scripts/webkitpy/port/test.py:
+ (add_unit_tests_to_mock_filesystem):
+ Fix this with the real FileSystem class, conditionally deleting files. Remove mock-only
+ fs.clear_written_files call.
+
2022-01-28 Jonathan Bedard <jbed...@apple.com>
[EWS] Trigger embedded builders on pull-requests
Modified: trunk/Tools/Scripts/webkitpy/__init__.py (288877 => 288878)
--- trunk/Tools/Scripts/webkitpy/__init__.py 2022-02-01 16:11:32 UTC (rev 288877)
+++ trunk/Tools/Scripts/webkitpy/__init__.py 2022-02-01 16:35:37 UTC (rev 288878)
@@ -71,6 +71,7 @@
AutoInstall.register(Package('pluggy', Version(0, 13, 1)))
AutoInstall.register(Package('py', Version(1, 5, 2)))
AutoInstall.register(Package('pycodestyle', Version(2, 5, 0)))
+AutoInstall.register(Package('pyfakefs', Version(3, 7, 2)))
AutoInstall.register(Package('scandir', Version(1, 10, 0)))
AutoInstall.register(Package('soupsieve', Version(1, 9, 6)))
AutoInstall.register(Package('selenium', Version(3, 141, 0)))
Modified: trunk/Tools/Scripts/webkitpy/common/host_mock.py (288877 => 288878)
--- trunk/Tools/Scripts/webkitpy/common/host_mock.py 2022-02-01 16:11:32 UTC (rev 288877)
+++ trunk/Tools/Scripts/webkitpy/common/host_mock.py 2022-02-01 16:35:37 UTC (rev 288878)
@@ -40,8 +40,8 @@
class MockHost(MockSystemHost):
- def __init__(self, log_executive=False, executive_throws_when_run=None, initialize_scm_by_default=True, web=None, create_stub_repository_files=False):
- MockSystemHost.__init__(self, log_executive, executive_throws_when_run)
+ def __init__(self, log_executive=False, executive_throws_when_run=None, initialize_scm_by_default=True, web=None, create_stub_repository_files=False, **kwargs):
+ MockSystemHost.__init__(self, log_executive, executive_throws_when_run, **kwargs)
add_unit_tests_to_mock_filesystem(self.filesystem)
if create_stub_repository_files:
add_checkout_information_json_to_mock_filesystem(self.filesystem)
Modified: trunk/Tools/Scripts/webkitpy/layout_tests/controllers/layout_test_finder_legacy_unittest.py (288877 => 288878)
--- trunk/Tools/Scripts/webkitpy/layout_tests/controllers/layout_test_finder_legacy_unittest.py 2022-02-01 16:11:32 UTC (rev 288877)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/controllers/layout_test_finder_legacy_unittest.py 2022-02-01 16:35:37 UTC (rev 288878)
@@ -28,7 +28,10 @@
from collections import OrderedDict
+from pyfakefs.fake_filesystem_unittest import TestCaseMixin
+
from webkitpy.common.host_mock import MockHost
+from webkitpy.common.system.filesystem import FileSystem
from webkitpy.common.system.filesystem_mock import MockFileSystem
from webkitpy.layout_tests.controllers.layout_test_finder_legacy import (
LayoutTestFinder,
@@ -44,7 +47,7 @@
return [path for path in paths if path.endswith('.html')]
-class LayoutTestFinderTests(unittest.TestCase):
+class LayoutTestFinderTests(unittest.TestCase, TestCaseMixin):
def __init__(self, *args, **kwargs):
super(LayoutTestFinderTests, self).__init__(*args, **kwargs)
self.port = None
@@ -51,7 +54,9 @@
self.finder = None
def setUp(self):
- host = MockHost(create_stub_repository_files=True)
+ self.setUpPyfakefs()
+ self.fs.is_windows_fs = False
+ host = MockHost(create_stub_repository_files=True, filesystem=FileSystem())
add_unit_tests_to_mock_filesystem(host.filesystem)
self.port = TestPort(host)
self.finder = LayoutTestFinder(self.port, None)
@@ -182,16 +187,15 @@
tests, ['failures/expected/image.html', 'failures/expected/image_checksum.html']
)
- # these are commented out as MockFileSystem doesn't support anything but *
- # def test_find_glob_b(self):
- # finder = self.finder
- # tests = [t.test_path for t in finder.find_tests_by_path(['failures/expected/i?age.html'])]
- # self.assertEqual(tests, ['failures/expected/image.html'])
+ def test_find_glob_b(self):
+ finder = self.finder
+ tests = [t.test_path for t in finder.find_tests_by_path(['failures/expected/i?age.html'])]
+ self.assertEqual(tests, ['failures/expected/image.html'])
- # def test_find_glob_c(self):
- # finder = self.finder
- # tests = [t.test_path for t in finder.find_tests_by_path(['failures/expected/i[m]age.html'])]
- # self.assertEqual(tests, ['failures/expected/image.html'])
+ def test_find_glob_c(self):
+ finder = self.finder
+ tests = [t.test_path for t in finder.find_tests_by_path(['failures/expected/i[m]age.html'])]
+ self.assertEqual(tests, ['failures/expected/image.html'])
def test_find_glob_mixed_file_type_sorted(self):
finder = self.finder
@@ -386,7 +390,10 @@
def test_is_w3c_resource_file(self):
finder = self.finder
- finder._filesystem.write_text_file(finder._port.layout_tests_dir() + "/imported/w3c/resources/resource-files.json", """
+ path = finder._port.layout_tests_dir() + "/imported/w3c/resources/resource-files.json"
+
+ finder._filesystem.maybe_make_directory(finder._filesystem.dirname(path))
+ finder._filesystem.write_text_file(path, """
{"directories": [
"web-platform-tests/common",
"web-platform-tests/dom/nodes/Document-createElement-namespace-tests",
Modified: trunk/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests_integrationtest.py (288877 => 288878)
--- trunk/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests_integrationtest.py 2022-02-01 16:11:32 UTC (rev 288877)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests_integrationtest.py 2022-02-01 16:35:37 UTC (rev 288878)
@@ -1047,6 +1047,7 @@
# Test that we update expectations in place. If the expectation
# is missing, update the expected generic location.
host = MockHost()
+ host.filesystem.clear_written_files()
details, err, _ = logging_run(
['--pixel-tests', '--reset-results', 'passes/image.html', 'failures/expected/missing_image.html'],
tests_included=True, host=host, new_results=True)
@@ -1060,6 +1061,7 @@
# Test that we update expectations in place. If the expectation
# is missing, update the expected generic location.
host = MockHost()
+ host.filesystem.clear_written_files()
details, err, _ = logging_run(['--no-show-results',
'failures/unexpected/missing_text.html',
'failures/unexpected/missing_image.html',
@@ -1077,6 +1079,7 @@
# Test that we update the platform expectations in the version-specific directories
# for both existing and new baselines.
host = MockHost()
+ host.filesystem.clear_written_files()
details, err, _ = logging_run(
['--pixel-tests', '--new-baseline', 'passes/image.html', 'failures/expected/missing_image.html'],
tests_included=True, host=host, new_results=True)
Modified: trunk/Tools/Scripts/webkitpy/port/test.py (288877 => 288878)
--- trunk/Tools/Scripts/webkitpy/port/test.py 2022-02-01 16:11:32 UTC (rev 288877)
+++ trunk/Tools/Scripts/webkitpy/port/test.py 2022-02-01 16:35:37 UTC (rev 288878)
@@ -322,8 +322,14 @@
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)
+ path = filesystem.join(dirname, base + suffix)
+ if contents is None:
+ if filesystem.exists(path):
+ filesystem.remove(path)
+ else:
+ filesystem.write_binary_file(path, contents)
+
# Add each test and the expected output, if any.
test_list = unit_test_list()
for test in test_list.tests.values():
@@ -336,10 +342,7 @@
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 add_checkout_information_json_to_mock_filesystem(filesystem):
if not filesystem.exists(TEST_DIR):
filesystem.maybe_make_directory(TEST_DIR)