-
Notifications
You must be signed in to change notification settings - Fork 14
/
firefox-delta.mjs
176 lines (159 loc) · 4.36 KB
/
firefox-delta.mjs
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
import { readdirSync, readFileSync, existsSync, writeFileSync } from 'fs';
function getParts(file) {
const parts = file.split('-');
if (parts.length === 1) {
parts.unshift('firefox');
}
parts[1] = parts[1].split('.').shift();
return parts;
}
const ignoredTests = new Set(
JSON.parse(readFileSync('ignored-tests.json', 'utf-8')),
);
const filterIgnored = (result) => !ignoredTests.has(result.fullTitle);
const files = readdirSync('./data');
const data = files
.filter(
(file) =>
file.endsWith('.json') &&
file.includes('firefox') &&
!file.includes('cdp'),
)
.sort()
.map((file, index) => {
const [browser, timestamp] = getParts(file);
const cdpFile = `./data/${browser}-cdp-${timestamp}.json`;
if (!existsSync(cdpFile)) {
return null;
}
const cdpPassBiDiFailTest = [];
const cdpFailBiDiPassTest = [];
const biDiTests = JSON.parse(
readFileSync(`./data/${browser}-${timestamp}.json`, 'utf-8'),
).tests;
const passingBiDiTests = new Set(
JSON.parse(
readFileSync(`./data/${browser}-${timestamp}.json`, 'utf-8'),
).passes.map((p) => p.fullTitle),
);
const passingCdpTests = new Set(
JSON.parse(readFileSync(cdpFile, 'utf-8')).passes.map((p) => p.fullTitle),
);
for (const test of biDiTests) {
if (
passingCdpTests.has(test.fullTitle) &&
!passingBiDiTests.has(test.fullTitle)
) {
cdpPassBiDiFailTest.push(test.fullTitle);
}
if (
!passingCdpTests.has(test.fullTitle) &&
passingBiDiTests.has(test.fullTitle)
) {
cdpFailBiDiPassTest.push(test.fullTitle);
}
}
return {
failing: cdpPassBiDiFailTest.length,
failingTests: cdpPassBiDiFailTest,
passing: cdpFailBiDiPassTest.length,
date: Number(timestamp) * 1000,
passingTests: cdpFailBiDiPassTest,
};
})
.filter((item) => item !== null);
// Keep only the failing and passing counts to support the firefox delta chart.
const countData = data.map((item) => {
return {
failing: item.failing,
passing: item.passing,
date: item.date,
};
});
writeFileSync('firefox-delta-count.json', JSON.stringify(countData, null, 2));
// Write the latest run data to firefox-delta.json, including the full list
// of passing vs failing tests.
writeFileSync('firefox-delta-all.json', JSON.stringify(data.at(-1), null, 2));
const { failingTests, passingTests, date } = data.at(-1);
const filteredFailingTests = failingTests.filter(
(test) => !ignoredTests.has(test),
);
const filteredPassingTests = passingTests.filter(
(test) => !ignoredTests.has(test),
);
const onlyRequiredData = {
failing: filteredFailingTests.length,
failingTests: filteredFailingTests,
passing: filteredPassingTests.length,
date,
passingTests: filteredPassingTests,
};
writeFileSync('firefox-delta.json', JSON.stringify(onlyRequiredData, null, 2));
const latestFirefox = files
.filter(
(file) =>
file.endsWith('.json') &&
file.includes('firefox') &&
!file.includes('cdp'),
)
.sort()
.at(-1);
const timestamp = getParts(latestFirefox)[1];
const latestFirefoxTests = JSON.parse(
readFileSync(`./data/firefox-${timestamp}.json`, 'utf-8'),
);
const latestChromeTests = JSON.parse(
readFileSync(`./data/chrome-${timestamp}.json`, 'utf-8'),
);
writeFileSync(
'firefox-failing.json',
JSON.stringify(
{
failing: latestFirefoxTests.failures
.filter(filterIgnored)
.map((t) => t.fullTitle),
pending: latestFirefoxTests.pending
.filter(filterIgnored)
.map((t) => t.fullTitle),
},
null,
2,
),
);
writeFileSync(
'chrome-failing.json',
JSON.stringify(
{
failing: latestChromeTests.failures
.filter(filterIgnored)
.map((t) => t.fullTitle),
pending: latestChromeTests.pending
.filter(filterIgnored)
.map((t) => t.fullTitle),
},
null,
2,
),
);
writeFileSync(
'firefox-failing-all.json',
JSON.stringify(
{
failing: latestFirefoxTests.failures.map((t) => t.fullTitle),
pending: latestFirefoxTests.pending.map((t) => t.fullTitle),
},
null,
2,
),
);
writeFileSync(
'chrome-failing-all.json',
JSON.stringify(
{
failing: latestChromeTests.failures.map((t) => t.fullTitle),
pending: latestChromeTests.pending.map((t) => t.fullTitle),
},
null,
2,
),
);