Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8fa89d6

Browse files
authored
Merge pull request#27470 from QuLogic/fix-test-viz
Fix test visualization tool for non-PNG files
2 parentsd267a1d +e771206 commit8fa89d6

File tree

2 files changed

+37
-14
lines changed

2 files changed

+37
-14
lines changed

‎tools/triage_tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ def __init__(self, path, root, source):
241241
ifbasename.endswith(f'_{ext}'):
242242
display_extension=f'_{ext}'
243243
extension=ext
244-
basename=basename[:-4]
244+
basename=basename[:-len(display_extension)]
245245
break
246246
else:
247247
display_extension=''

‎tools/visualize_tests.py

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,14 @@
1010
importos
1111
fromcollectionsimportdefaultdict
1212

13-
14-
html_template="""<html><head><style media="screen" type="text/css">
13+
# Non-png image extensions
14+
NON_PNG_EXTENSIONS= ['pdf','svg','eps']
15+
16+
html_template="""<!DOCTYPE html>
17+
<html lang="en"><head>
18+
<meta charset="utf-8">
19+
<title>Matplotlib test result visualization</title>
20+
<style media="screen">
1521
img{{
1622
width:100%;
1723
max-width:800px;
@@ -24,14 +30,18 @@
2430
"""
2531

2632
subdir_template="""<h2>{subdir}</h2><table>
27-
<thead><td>name</td><td>actual</td><td>expected</td><td>diff</td></thead>
33+
<thead><tr><th>name</th><th>actual</th><th>expected</th><th>diff</th></tr></thead>
34+
<tbody>
2835
{rows}
36+
</tbody>
2937
</table>
3038
"""
3139

3240
failed_template="""<h2>Only Failed</h2><table>
33-
<thead><td>name</td><td>actual</td><td>expected</td><td>diff</td></thead>
41+
<thead><tr><th>name</th><th>actual</th><th>expected</th><th>diff</th></tr></thead>
42+
<tbody>
3443
{rows}
44+
</tbody>
3545
</table>
3646
"""
3747

@@ -68,28 +78,41 @@ def run(show_browser=True):
6878
fn,fext=os.path.splitext(file)
6979
iffext!=".png":
7080
continue
71-
# Always use / for URLs.
7281
if"-failed-diff"infn:
73-
pictures[fn[:-12]]["f"]="/".join((subdir,file))
82+
file_type='diff'
83+
test_name=fn[:-len('-failed-diff')]
7484
elif"-expected"infn:
75-
pictures[fn[:-9]]["e"]="/".join((subdir,file))
85+
forextinNON_PNG_EXTENSIONS:
86+
iffn.endswith(f'_{ext}'):
87+
display_extension=f'_{ext}'
88+
extension=ext
89+
fn=fn[:-len(display_extension)]
90+
break
91+
else:
92+
display_extension=''
93+
extension='png'
94+
file_type='expected'
95+
test_name=fn[:-len('-expected')]+display_extension
7696
else:
77-
pictures[fn]["c"]="/".join((subdir,file))
97+
file_type='actual'
98+
test_name=fn
99+
# Always use / for URLs.
100+
pictures[test_name][file_type]='/'.join((subdir,file))
78101

79102
subdir_rows= []
80103
forname,testinsorted(pictures.items()):
81-
expected_image=test.get('e','')
82-
actual_image=test.get('c','')
104+
expected_image=test.get('expected','')
105+
actual_image=test.get('actual','')
83106

84-
if'f'intest:
107+
if'diff'intest:
85108
# A real failure in the image generation, resulting in
86109
# different images.
87110
status=" (failed)"
88-
failed=f'<a href="{test["f"]}">diff</a>'
111+
failed=f'<a href="{test["diff"]}">diff</a>'
89112
current=linked_image_template.format(actual_image)
90113
failed_rows.append(row_template.format(name,"",current,
91114
expected_image,failed))
92-
elif'c'notintest:
115+
elif'actual'notintest:
93116
# A failure in the test, resulting in no current image
94117
status=" (failed)"
95118
failed='--'

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp