| Differences between
and this patch
- Tools/ChangeLog +38 lines
Lines 1-3 Tools/ChangeLog_sec1
1
2011-11-30  Ryosuke Niwa  <rniwa@webkit.org>
2
3
        Parse reftest.list and extract types of ref tests
4
        https://bugs.webkit.org/show_bug.cgi?id=66837
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        Add support for reftest.list to base port.
9
10
        * Scripts/webkitpy/layout_tests/controllers/single_test_runner.py:
11
        (SingleTestRunner.__init__):
12
        * Scripts/webkitpy/layout_tests/port/base.py:
13
        (Port.__init__): Initialize self._reftest_list. It's a dictionary mapping from a test directory
14
        to a dictionary of {test path: ("==" or "!=", reference file path)}
15
        (Port._get_reftest_list): Added; calls test_file.parse_reftest_list to fill self._reftest_list.
16
        (Port._reference_file_for): Added; obtains the reference file name given a test name.
17
        (Port.reftest_expected_filename): Calls _reference_file_for.
18
        (Port.reftest_expected_mismatch_filename): Ditto.
19
        * Scripts/webkitpy/layout_tests/port/test.py:
20
        (unit_test_filesystem.add_test_file):
21
        (unit_test_filesystem.add_file):
22
        (unit_test_filesystem):
23
        * Scripts/webkitpy/layout_tests/port/test_files.py:
24
        (is_reference_html_file): Treat any file that starts with ref- or notref- or ends with (regardless of extension)
25
        -expected, -expected-mismach, -ref, or -notref as a reference file.
26
        (_is_test_file):
27
        (parse_reftest_list): Added.
28
        * Scripts/webkitpy/layout_tests/port/test_files_unittest.py:
29
        (TestFilesTest.test_find_with_skipped_directories):
30
        (TestFilesTest.test_is_test_file):
31
        (TestFilesTest):
32
        (TestFilesTest.test_parse_reftest_list):
33
        * Scripts/webkitpy/layout_tests/run_webkit_tests_integrationtest.py:
34
        (get_tests_run.RecordingTestDriver.run_test):
35
        (MainTest.test_unexpected_failures):
36
        (MainTest.test_missing_and_unexpected_results):
37
        (EndToEndTest.test_end_to_end):
38
1
2011-11-30  nduca@chromium.org  <nduca@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
39
2011-11-30  nduca@chromium.org  <nduca@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
2
40
3
        [chromium] Enable threaded compositing via CCThreadProxy::hasThread only
41
        [chromium] Enable threaded compositing via CCThreadProxy::hasThread only
- Tools/Scripts/webkitpy/layout_tests/run_webkit_tests_integrationtest.py -6 / +21 lines
Lines 166-172 def get_tests_run(extra_args=None, tests Tools/Scripts/webkitpy/layout_tests/run_webkit_tests_integrationtest.py_sec1
166
            # In case of reftest, one test calls the driver's run_test() twice.
166
            # In case of reftest, one test calls the driver's run_test() twice.
167
            # We should not add a reference html used by reftests to tests unless include_reference_html parameter
167
            # We should not add a reference html used by reftests to tests unless include_reference_html parameter
168
            # is explicitly given.
168
            # is explicitly given.
169
            if include_reference_html or not is_reference_html_file(test_input.test_name):
169
            filesystem = self._port.host.filesystem
170
            dirname, filename = filesystem.split(test_name)
171
            if include_reference_html or not is_reference_html_file(filesystem, dirname, filename):
170
                self._current_test_batch.append(test_name)
172
                self._current_test_batch.append(test_name)
171
            return TestDriver.run_test(self, test_input)
173
            return TestDriver.run_test(self, test_input)
172
174
Lines 426-432 class MainTest(unittest.TestCase): Tools/Scripts/webkitpy/layout_tests/run_webkit_tests_integrationtest.py_sec2
426
428
427
        # Update this magic number if you add an unexpected test to webkitpy.layout_tests.port.test
429
        # Update this magic number if you add an unexpected test to webkitpy.layout_tests.port.test
428
        # FIXME: It's nice to have a routine in port/test.py that returns this number.
430
        # FIXME: It's nice to have a routine in port/test.py that returns this number.
429
        unexpected_tests_count = 7
431
        unexpected_tests_count = 8
430
432
431
        self.assertEqual(res, unexpected_tests_count)
433
        self.assertEqual(res, unexpected_tests_count)
432
        self.assertFalse(out.empty())
434
        self.assertFalse(out.empty())
Lines 448-455 class MainTest(unittest.TestCase): Tools/Scripts/webkitpy/layout_tests/run_webkit_tests_integrationtest.py_sec3
448
        expected_token = '"unexpected":{"text-image-checksum.html":{"expected":"PASS","actual":"TEXT"},"missing_text.html":{"expected":"PASS","is_missing_text":true,"actual":"MISSING"}'
450
        expected_token = '"unexpected":{"text-image-checksum.html":{"expected":"PASS","actual":"TEXT"},"missing_text.html":{"expected":"PASS","is_missing_text":true,"actual":"MISSING"}'
449
        json_string = fs.read_text_file('/tmp/layout-test-results/full_results.json')
451
        json_string = fs.read_text_file('/tmp/layout-test-results/full_results.json')
450
        self.assertTrue(json_string.find(expected_token) != -1)
452
        self.assertTrue(json_string.find(expected_token) != -1)
451
        self.assertTrue(json_string.find('"num_regression":1') == -1)
453
        self.assertTrue(json_string.find('"num_regressions":1') != -1)
452
        self.assertTrue(json_string.find('"num_flaky":1') == -1)
454
        self.assertTrue(json_string.find('"num_flaky":0') != -1)
455
        self.assertTrue(json_string.find('"num_missing":1') != -1)
456
457
    def test_missing_and_unexpected_results(self):
458
        # Test that we update expectations in place. If the expectation
459
        # is missing, update the expected generic location.
460
        fs = unit_test_filesystem()
461
        res, out, err, _ = logging_run(['--no-show-results', 'reftests/foo/'], tests_included=True, filesystem=fs, record_results=True)
462
        file_list = fs.written_files.keys()
463
        file_list.remove('/tmp/layout-test-results/tests_run0.txt')
464
        self.assertEquals(res, 1)
465
        json_string = fs.read_text_file('/tmp/layout-test-results/full_results.json')
466
        self.assertTrue(json_string.find('"unlistedtest.html":{"expected":"PASS","is_missing_text":true,"actual":"MISSING","is_missing_image":true}') != -1)
467
        self.assertTrue(json_string.find('"num_regressions":1') != -1)
468
        self.assertTrue(json_string.find('"num_flaky":0') != -1)
453
        self.assertTrue(json_string.find('"num_missing":1') != -1)
469
        self.assertTrue(json_string.find('"num_missing":1') != -1)
454
470
455
    def test_missing_and_unexpected_results_with_custom_exit_code(self):
471
    def test_missing_and_unexpected_results_with_custom_exit_code(self):
Lines 757-764 class EndToEndTest(unittest.TestCase): Tools/Scripts/webkitpy/layout_tests/run_webkit_tests_integrationtest.py_sec4
757
        fs = unit_test_filesystem()
773
        fs = unit_test_filesystem()
758
        res, out, err, user = logging_run(record_results=True, tests_included=True, filesystem=fs)
774
        res, out, err, user = logging_run(record_results=True, tests_included=True, filesystem=fs)
759
775
760
        # Seven tests should fail, so the return code should be 7.
776
        self.assertEquals(res, unexpected_tests_count)
761
        self.assertEquals(res, 7)
762
        results = self.parse_full_results(fs.files['/tmp/layout-test-results/full_results.json'])
777
        results = self.parse_full_results(fs.files['/tmp/layout-test-results/full_results.json'])
763
778
764
        # Check to ensure we're passing back image diff %age correctly.
779
        # Check to ensure we're passing back image diff %age correctly.
- Tools/Scripts/webkitpy/layout_tests/controllers/single_test_runner.py -2 / +2 lines
Lines 68-79 class SingleTestRunner: Tools/Scripts/webkitpy/layout_tests/controllers/single_test_runner.py_sec1
68
            return
68
            return
69
69
70
        reftest_expected_filename = port.reftest_expected_filename(self._test_name)
70
        reftest_expected_filename = port.reftest_expected_filename(self._test_name)
71
        if fs.exists(reftest_expected_filename):
71
        if reftest_expected_filename and fs.exists(reftest_expected_filename):
72
            self._is_reftest = True
72
            self._is_reftest = True
73
            self._reference_filename = reftest_expected_filename
73
            self._reference_filename = reftest_expected_filename
74
74
75
        reftest_expected_mismatch_filename = port.reftest_expected_mismatch_filename(self._test_name)
75
        reftest_expected_mismatch_filename = port.reftest_expected_mismatch_filename(self._test_name)
76
        if fs.exists(reftest_expected_mismatch_filename):
76
        if reftest_expected_mismatch_filename and fs.exists(reftest_expected_mismatch_filename):
77
            if self._is_reftest:
77
            if self._is_reftest:
78
                _log.error('It is not allowed that one test file has both'
78
                _log.error('It is not allowed that one test file has both'
79
                           ' expected.html file and expected-mismatch.html file'
79
                           ' expected.html file and expected-mismatch.html file'
- Tools/Scripts/webkitpy/layout_tests/port/base.py -2 / +27 lines
Lines 58-63 from webkitpy.layout_tests.port import t Tools/Scripts/webkitpy/layout_tests/port/base.py_sec1
58
from webkitpy.layout_tests.servers import apache_http_server
58
from webkitpy.layout_tests.servers import apache_http_server
59
from webkitpy.layout_tests.servers import http_server
59
from webkitpy.layout_tests.servers import http_server
60
from webkitpy.layout_tests.servers import websocket_server
60
from webkitpy.layout_tests.servers import websocket_server
61
from webkitpy.layout_tests.port.test_files import parse_reftest_list
61
62
62
_log = logutils.get_logger(__file__)
63
_log = logutils.get_logger(__file__)
63
64
Lines 147-152 class Port(object): Tools/Scripts/webkitpy/layout_tests/port/base.py_sec2
147
148
148
        self.set_option_default('configuration', self.default_configuration())
149
        self.set_option_default('configuration', self.default_configuration())
149
        self._test_configuration = None
150
        self._test_configuration = None
151
        self._reftest_list = dict()
150
        self._multiprocessing_is_available = (multiprocessing is not None)
152
        self._multiprocessing_is_available = (multiprocessing is not None)
151
        self._results_directory = None
153
        self._results_directory = None
152
154
Lines 424-436 class Port(object): Tools/Scripts/webkitpy/layout_tests/port/base.py_sec3
424
        text = self._filesystem.read_binary_file(baseline_path)
426
        text = self._filesystem.read_binary_file(baseline_path)
425
        return text.replace("\r\n", "\n")
427
        return text.replace("\r\n", "\n")
426
428
429
    def _get_reftest_list(self, test_name):
430
        dirname = self._filesystem.join(self.layout_tests_dir(), self._filesystem.dirname(test_name))
431
        if dirname not in self._reftest_list:
432
            self._reftest_list[dirname] = parse_reftest_list(self._filesystem, dirname)
433
        return self._reftest_list[dirname]
434
435
    def _reference_file_for(self, test_name, expectation):
436
        dirname = self._filesystem.join(self.layout_tests_dir(), self._filesystem.dirname(test_name))
437
        if dirname not in self._reftest_list:
438
            self._reftest_list[dirname] = parse_reftest_list(self._filesystem, dirname)
439
        if not self._reftest_list[dirname]:
440
            if expectation == '==':
441
                return self.expected_filename(test_name, '.html')
442
            else:
443
                return self.expected_filename(test_name, '-mismatch.html')
444
445
        reftest_list = self._reftest_list[dirname]
446
        print reftest_list
447
        filename = self._filesystem.join(self.layout_tests_dir(), test_name)
448
        if filename not in reftest_list or reftest_list[filename][0] != expectation:
449
            return None
450
        return reftest_list[filename][1]
451
427
    def reftest_expected_filename(self, test_name):
452
    def reftest_expected_filename(self, test_name):
428
        """Return the filename of reference we expect the test matches."""
453
        """Return the filename of reference we expect the test matches."""
429
        return self.expected_filename(test_name, '.html')
454
        return self._reference_file_for(test_name, '==')
430
455
431
    def reftest_expected_mismatch_filename(self, test_name):
456
    def reftest_expected_mismatch_filename(self, test_name):
432
        """Return the filename of reference we don't expect the test matches."""
457
        """Return the filename of reference we don't expect the test matches."""
433
        return self.expected_filename(test_name, '-mismatch.html')
458
        return self._reference_file_for(test_name, '!=')
434
459
435
    def test_to_uri(self, test_name):
460
    def test_to_uri(self, test_name):
436
        """Convert a test name to a URI."""
461
        """Convert a test name to a URI."""
- Tools/Scripts/webkitpy/layout_tests/port/test.py -7 / +20 lines
Lines 187-192 layer at (0,0) size 800x34 Tools/Scripts/webkitpy/layout_tests/port/test.py_sec1
187
    tests.add_reftest('failures/unexpected/reftest.html', 'failures/unexpected/reftest-expected.html', same_image=False)
187
    tests.add_reftest('failures/unexpected/reftest.html', 'failures/unexpected/reftest-expected.html', same_image=False)
188
    tests.add_reftest('failures/unexpected/mismatch.html', 'failures/unexpected/mismatch-expected-mismatch.html', same_image=True)
188
    tests.add_reftest('failures/unexpected/mismatch.html', 'failures/unexpected/mismatch-expected-mismatch.html', same_image=True)
189
    # FIXME: Add a reftest which crashes.
189
    # FIXME: Add a reftest which crashes.
190
    tests.add('reftests/foo/test.html')
191
    tests.add('reftests/foo/test-ref.html')
192
193
    # The following files shouldn't be treated as reftests
194
    tests.add_reftest('reftests/foo/unlistedtest.html', 'reftests/foo/unlistedtest-expected.html', same_image=True)
195
    tests.add('reftests/foo/reference/bar/common.html')
196
    tests.add('reftests/foo/reftest/bar/shared.html')
190
197
191
    tests.add('websocket/tests/passes/text.html')
198
    tests.add('websocket/tests/passes/text.html')
192
199
Lines 213-235 def unit_test_filesystem(files=None): Tools/Scripts/webkitpy/layout_tests/port/test.py_sec2
213
    test_list = unit_test_list()
220
    test_list = unit_test_list()
214
    files = files or {}
221
    files = files or {}
215
222
216
    def add_file(files, test, suffix, contents):
223
    def add_test_file(files, test, suffix, contents):
217
        dirname = test.name[0:test.name.rfind('/')]
224
        dirname = test.name[0:test.name.rfind('/')]
218
        base = test.base
225
        base = test.base
219
        path = LAYOUT_TEST_DIR + '/' + dirname + '/' + base + suffix
226
        add_file(files, dirname + '/' + base + suffix, contents)
220
        files[path] = contents
227
228
    def add_file(files, file_name, contents):
229
        files[LAYOUT_TEST_DIR + '/' + file_name] = contents
221
230
222
    # Add each test and the expected output, if any.
231
    # Add each test and the expected output, if any.
223
    for test in test_list.tests.values():
232
    for test in test_list.tests.values():
224
        add_file(files, test, '.html', '')
233
        add_test_file(files, test, '.html', '')
225
        if test.is_reftest:
234
        if test.is_reftest:
226
            continue
235
            continue
227
        if test.actual_audio:
236
        if test.actual_audio:
228
            add_file(files, test, '-expected.wav', test.expected_audio)
237
            add_test_file(files, test, '-expected.wav', test.expected_audio)
229
            continue
238
            continue
230
239
231
        add_file(files, test, '-expected.txt', test.expected_text)
240
        add_test_file(files, test, '-expected.txt', test.expected_text)
232
        add_file(files, test, '-expected.png', test.expected_image)
241
        add_test_file(files, test, '-expected.png', test.expected_image)
233
242
234
243
235
    # Add the test_expectations file.
244
    # Add the test_expectations file.
Lines 255-260 WONTFIX SKIP : failures/expected/keyboar Tools/Scripts/webkitpy/layout_tests/port/test.py_sec3
255
WONTFIX SKIP : failures/expected/exception.html = CRASH
264
WONTFIX SKIP : failures/expected/exception.html = CRASH
256
"""
265
"""
257
266
267
    add_file(files, 'reftests/foo/reftest.list', """
268
== test.html test-ref.html
269
""")
270
258
    # FIXME: This test was only being ignored because of missing a leading '/'.
271
    # FIXME: This test was only being ignored because of missing a leading '/'.
259
    # Fixing the typo causes several tests to assert, so disabling the test entirely.
272
    # Fixing the typo causes several tests to assert, so disabling the test entirely.
260
    # Add in a file should be ignored by test_files.find().
273
    # Add in a file should be ignored by test_files.find().
- Tools/Scripts/webkitpy/layout_tests/port/test_files.py -4 / +28 lines
Lines 35-40 i.e. calling find(["LayoutTests/fast"]) Tools/Scripts/webkitpy/layout_tests/port/test_files.py_sec1
35
under that directory."""
35
under that directory."""
36
36
37
import time
37
import time
38
import re
38
39
39
from webkitpy.common.system import logutils
40
from webkitpy.common.system import logutils
40
41
Lines 46-52 _log = logutils.get_logger(__file__) Tools/Scripts/webkitpy/layout_tests/port/test_files.py_sec2
46
_supported_file_extensions = set(['.html', '.shtml', '.xml', '.xhtml', '.pl',
47
_supported_file_extensions = set(['.html', '.shtml', '.xml', '.xhtml', '.pl',
47
                                  '.htm', '.php', '.svg', '.mht'])
48
                                  '.htm', '.php', '.svg', '.mht'])
48
# When collecting test cases, skip these directories
49
# When collecting test cases, skip these directories
49
_skipped_directories = set(['.svn', '_svn', 'resources', 'script-tests'])
50
_skipped_directories = set(['.svn', '_svn', 'resources', 'script-tests', 'reference', 'reftest'])
50
51
51
52
52
def find(port, paths=None):
53
def find(port, paths=None):
Lines 103-111 def _has_supported_extension(filesystem, Tools/Scripts/webkitpy/layout_tests/port/test_files.py_sec3
103
    return extension in _supported_file_extensions
104
    return extension in _supported_file_extensions
104
105
105
106
106
def is_reference_html_file(filename):
107
def is_reference_html_file(filesystem, dirname, filename):
107
    return filename.endswith('-expected.html') or filename.endswith('-expected-mismatch.html')
108
    if filename.startswith('ref-') or filename.endswith('notref-'):
109
        return True
110
    filename_wihout_ext, unused = filesystem.splitext(filename)
111
    for suffix in ['-expected', '-expected-mismatch', '-ref', '-notref']:
112
        if filename_wihout_ext.endswith(suffix):
113
            return True
114
    return False
108
115
109
116
110
def _is_test_file(filesystem, dirname, filename):
117
def _is_test_file(filesystem, dirname, filename):
111
    return _has_supported_extension(filesystem, filename) and not is_reference_html_file(filename)
118
    return _has_supported_extension(filesystem, filename) and not is_reference_html_file(filesystem, dirname, filename)
119
120
121
def parse_reftest_list(filesystem, test_dirpath):
122
    reftest_list_path = filesystem.join(test_dirpath, 'reftest.list')
123
    if not filesystem.isfile(reftest_list_path):
124
        return None
125
    reftest_list_file = filesystem.read_text_file(reftest_list_path)
126
127
    parsed_list = dict()
128
    for line in reftest_list_file.split('\n'):
129
        line = re.sub('#.+$', '', line)
130
        split_line = line.split()
131
        if len(split_line) < 3:
132
            continue
133
        expectation_type, test_file, ref_file = split_line
134
        parsed_list[filesystem.join(test_dirpath, test_file)] = (expectation_type, filesystem.join(test_dirpath, ref_file))
135
    return parsed_list
- Tools/Scripts/webkitpy/layout_tests/port/test_files_unittest.py +23 lines
Lines 54-59 class TestFilesTest(unittest.TestCase): Tools/Scripts/webkitpy/layout_tests/port/test_files_unittest.py_sec1
54
        tests = port.tests('userscripts')
54
        tests = port.tests('userscripts')
55
        self.assertTrue('userscripts/resources/iframe.html' not in tests)
55
        self.assertTrue('userscripts/resources/iframe.html' not in tests)
56
56
57
        tests = test_files.find(port, ['reftests/foo'])
58
        self.assertEqual(tests, set(['/test.checkout/LayoutTests/reftests/foo/test.html', '/test.checkout/LayoutTests/reftests/foo/unlistedtest.html']))
59
57
    def test_find_with_skipped_directories_2(self):
60
    def test_find_with_skipped_directories_2(self):
58
        port = test.TestPort()
61
        port = test.TestPort()
59
        tests = test_files.find(port, ['userscripts/resources'])
62
        tests = test_files.find(port, ['userscripts/resources'])
Lines 64-72 class TestFilesTest(unittest.TestCase): Tools/Scripts/webkitpy/layout_tests/port/test_files_unittest.py_sec2
64
        fs = port._filesystem
67
        fs = port._filesystem
65
        self.assertTrue(test_files._is_test_file(fs, '', 'foo.html'))
68
        self.assertTrue(test_files._is_test_file(fs, '', 'foo.html'))
66
        self.assertTrue(test_files._is_test_file(fs, '', 'foo.shtml'))
69
        self.assertTrue(test_files._is_test_file(fs, '', 'foo.shtml'))
70
        self.assertTrue(test_files._is_test_file(fs, '', 'test-ref-test.html'))
67
        self.assertFalse(test_files._is_test_file(fs, '', 'foo.png'))
71
        self.assertFalse(test_files._is_test_file(fs, '', 'foo.png'))
68
        self.assertFalse(test_files._is_test_file(fs, '', 'foo-expected.html'))
72
        self.assertFalse(test_files._is_test_file(fs, '', 'foo-expected.html'))
69
        self.assertFalse(test_files._is_test_file(fs, '', 'foo-expected-mismatch.html'))
73
        self.assertFalse(test_files._is_test_file(fs, '', 'foo-expected-mismatch.html'))
74
        self.assertFalse(test_files._is_test_file(fs, '', 'foo-ref.html'))
75
        self.assertFalse(test_files._is_test_file(fs, '', 'foo-notref.html'))
76
        self.assertFalse(test_files._is_test_file(fs, '', 'foo-notref.xht'))
77
        self.assertFalse(test_files._is_test_file(fs, '', 'foo-ref.xhtml'))
78
        self.assertFalse(test_files._is_test_file(fs, '', 'ref-foo.html'))
79
        self.assertFalse(test_files._is_test_file(fs, '', 'notref-foo.xhr'))
80
81
    def test_parse_reftest_list(self):
82
        port = test.TestPort()
83
        port.host.filesystem.files['bar/reftest.list'] = """== test.html test-ref.html
84
85
# some comment
86
!= test-2.html test-notref.html # more comments
87
== test-3.html test-ref.html"""
88
89
        reftest_list = test_files.parse_reftest_list(port.host.filesystem, 'bar')
90
        self.assertEqual(reftest_list, {'bar/test.html': ('==', 'bar/test-ref.html'),
91
            'bar/test-2.html': ('!=', 'bar/test-notref.html'),
92
            'bar/test-3.html': ('==', 'bar/test-ref.html')})
70
93
71
94
72
class MockWinFileSystem(object):
95
class MockWinFileSystem(object):

Return to Bug 66837