Skip to content

Commit 063bf7d

Browse files
Rakib M. HasanChromium LUCI CQ
Rakib M. Hasan
authored and
Chromium LUCI CQ
committed
wpt diffing: Escape commas in test names
Escape commas in test names by surrounding the test name in quotes. Bug: 1079015 Change-Id: Iefa3ab8d4bee1955f118f0c6cd0adcf96f356688 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2787314 Reviewed-by: Luke Z <lpz@chromium.org> Commit-Queue: Rakib Hasan <rmhasan@google.com> Cr-Commit-Position: refs/heads/master@{#867299}
1 parent 8e91f0a commit 063bf7d

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

third_party/blink/tools/diff_wpt_results.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,11 @@ def create_csv(actual_results_map, baseline_results_map, csv_output):
4343
file_output = 'Test name, Test Result, Baseline Result, Result Comparison\n'
4444

4545
for test in sorted(super_set):
46-
line = [test]
46+
if ',' in test:
47+
line = ['"%s"' % test]
48+
else:
49+
line = [test]
50+
4751
for result_mp in [actual_results_map, baseline_results_map]:
4852
line.append(result_mp.get(test, {'actual': 'MISSING'})
4953
.get('actual').split()[-1])

third_party/blink/tools/diff_wpt_results_unittest.py

+9
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,15 @@ def test_compress_json(self):
4141

4242

4343
class CreateCsvTest(unittest.TestCase):
44+
def test_name_with_comma_escaped_in_csv(self):
45+
actual_mp = {'test, name.html': {'actual': 'PASS'}}
46+
with io.BytesIO() as csv_out:
47+
create_csv(actual_mp, actual_mp, csv_out)
48+
csv_out.seek(0)
49+
content = csv_out.read()
50+
self.assertEquals(content, CSV_HEADING + '\n' +
51+
'"test, name.html",PASS,PASS,SAME RESULTS\n')
52+
4453
def test_create_csv_with_same_result(self):
4554
actual_mp = {'test.html': {'actual': 'PASS'}}
4655
with io.BytesIO() as csv_out:

0 commit comments

Comments
 (0)