Commit e2d465d8 authored by dcampb's avatar dcampb Committed by Commit bot

Adds functionality to update-w3c-test-expectations

This cl adds functionality to the skip so that it skips adding
the failing test line if it already exists in TestExpectations.

BUG=625254

Review-Url: https://codereview.chromium.org/2174073002
Cr-Commit-Position: refs/heads/master@{#407349}
parent a3aa15c5
......@@ -230,11 +230,12 @@ class W3CExpectationsLineAdder(object):
to LayoutTest/TestExpectations. Checks the file for the string
'# Tests added from W3C auto import bot' and writes expectation
lines directly under it. If not found, it writes to the end of
the file.
the file. If the test name is already in LayoutTests/TestExpectations,
the line will be skipped.
Args:
host: A Host object.
path: The path to the file LayoutTest/TestExpectations.
path: The path to the file LayoutTests/TestExpectations.
line_list: A list of w3c test expectations lines.
Returns:
......@@ -245,6 +246,10 @@ class W3CExpectationsLineAdder(object):
w3c_comment_line_index = file_contents.find(comment_line)
all_lines = ''
for line in line_list:
end_bracket_index = line.split().index(']')
test_name = line.split()[end_bracket_index + 1]
if test_name in file_contents:
continue
all_lines += str(line) + '\n'
all_lines = all_lines[:-1]
if w3c_comment_line_index == -1:
......
......@@ -90,18 +90,28 @@ class UpdateW3CTestExpectationsTest(unittest.TestCase, W3CExpectationsLineAdder)
host = MockHost()
line_adder = W3CExpectationsLineAdder(host)
line_adder._host.filesystem.files = {'TestExpectations': '# Tests added from W3C auto import bot\n'}
line_list = ['fake crbug [foo] fake/file/path.html [Pass]']
line_list = ['fake crbug [ foo ] fake/file/path.html [Pass]']
path = 'TestExpectations'
line_adder.write_to_test_expectations(line_adder, path, line_list)
value = line_adder._host.filesystem.read_text_file(path)
self.assertEqual(value, '# Tests added from W3C auto import bot\nfake crbug [foo] fake/file/path.html [Pass]\n')
self.assertEqual(value, '# Tests added from W3C auto import bot\nfake crbug [ foo ] fake/file/path.html [Pass]\n')
def test_write_to_test_expectations_to_eof(self):
host = MockHost()
line_adder = W3CExpectationsLineAdder(host)
line_adder._host.filesystem.files['TestExpectations'] = 'not empty\n'
line_list = ['fake crbug [foo] fake/file/path.html [Pass]']
line_list = ['fake crbug [ foo ] fake/file/path.html [Pass]']
path = 'TestExpectations'
line_adder.write_to_test_expectations(line_adder, path, line_list)
value = line_adder.filesystem.read_text_file(path)
self.assertEqual(value, 'not empty\n\n# Tests added from W3C auto import bot\nfake crbug [foo] fake/file/path.html [Pass]')
self.assertEqual(value, 'not empty\n\n# Tests added from W3C auto import bot\nfake crbug [ foo ] fake/file/path.html [Pass]')
def test_write_to_test_expectations_skip_lines(self):
host = MockHost()
line_adder = W3CExpectationsLineAdder(host)
line_adder._host.filesystem.files['TestExpectations'] = 'dont copy me\n'
line_list = ['[ ] dont copy me', '[ ] but copy me']
path = 'TestExpectations'
line_adder.write_to_test_expectations(line_adder, path, line_list)
value = line_adder.filesystem.read_text_file(path)
self.assertEqual(value, 'dont copy me\n\n# Tests added from W3C auto import bot\n[ ] but copy me')
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment