forked from web-platform-tests/wpt.fyi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-file-results-table-terse.js
129 lines (119 loc) · 3.54 KB
/
test-file-results-table-terse.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/**
* Copyright 2018 The WPT Dashboard Project. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
import '../node_modules/@polymer/polymer/lib/elements/dom-repeat.js';
import { html } from '../node_modules/@polymer/polymer/polymer-element.js';
import { AbstractTestFileResultsTable } from './abstract-test-file-results-table.js';
class TestFileResultsTableTerse extends AbstractTestFileResultsTable {
static get template() {
return html`
<style>
td {
position: relative;
}
td.sub-test-name {
font-family: monospace;
background-color: white;
}
td code {
box-sizing: border-box;
height: 100%;
left: 0;
overflow: hidden;
position: absolute;
text-overflow: ellipsis;
top: 0;
white-space: nowrap;
width: 100%;
}
td code:hover {
z-index: 1;
text-overflow: initial;
background-color: inherit;
width: -moz-max-content;
width: max-content;
}
</style>
${super.template}
`;
}
static get is() {
return 'test-file-results-table-terse';
}
static get properties() {
return {
matchers: {
type: Array,
value: [
{
re: /^assert_equals:.* expected ("(\\"|[^"])*"|[^ ]*) but got ("(\\"|[^"])*"|[^ ]*)$/,
getMessage: match => `!EQ(${match[1]}, ${match[3]})`,
},
{
re: /^assert_approx_equals:.* expected ("(\\"|[^"])*"| [+][/][-] |[^:]*) but got ("(\\"|[^"])*"| [+][/][-] |[^:]*):.*$/,
getMessage: match => `!~EQ(${match[1]}, ${match[3]})`,
},
{
re: /^assert ("(\\"|[^"])*"|[^ ]*) == ("(\\"|[^"])*"|[^ ]*)$/,
getMessage: match => `!EQ(${match[1]}, ${match[3]})`,
},
{
re: /^assert_array_equals:.*$/,
getMessage: () => '!ARRAY_EQ(a, b)',
},
{
re: /^Uncaught [^ ]*Error:.*$/,
getMessage: () => 'UNCAUGHT_ERROR',
},
{
re: /^([^ ]*) is not ([a-zA-Z0-9 ]*)$/,
getMessage: match => `NOT_${match[2].toUpperCase().replace(/\s/g, '_')}(${match[1]})`,
},
{
re: /^promise_test: Unhandled rejection with value: (.*)$/,
getMessage: match => `PROMISE_REJECT(${match[1]})`,
},
{
re: /^assert_true: .*$/,
getMessage: () => '!TRUE',
},
{
re: /^assert_own_property: [^"]*"([^"]*)".*$/,
getMessage: match => `!OWN_PROPERTY(${match[1]})`,
},
{
re: /^assert_inherits: [^"]*"([^"]*)".*$/,
getMessage: match => `!INHERITS(${match[1]})`,
},
],
},
};
}
subtestMessage(result) {
let msg = super.subtestMessage(result);
if (msg) {
return msg;
}
// Terse table only: Display "ERROR" without message on harness error.
if (result.status === 'ERROR') {
return 'ERROR';
}
return this.parseFailureMessage(result.message);
}
parseFailureMessage(msg) {
let matchedMsg = '';
for (const matcher of this.matchers) {
const match = msg.match(matcher.re);
if (match !== null) {
matchedMsg = matcher.getMessage(match);
break;
}
}
return matchedMsg ? matchedMsg : 'FAIL';
}
}
window.customElements.define(
TestFileResultsTableTerse.is, TestFileResultsTableTerse);
export { TestFileResultsTableTerse };