Skip to content

Commit 9b15ff0

Browse files
committed
Rework test suite
1 parent 314c5da commit 9b15ff0

1 file changed

Lines changed: 72 additions & 65 deletions

File tree

tests/wpt.ts

Lines changed: 72 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,14 @@ const enum DataType {
2424
Result,
2525
}
2626

27+
interface TestDescriptor {
28+
test: string;
29+
subtest: string;
30+
}
31+
2732
interface ResultData {
2833
type: DataType.Result;
29-
result: [number, number];
34+
result: [TestDescriptor[], TestDescriptor[]];
3035
}
3136

3237
interface FetchDescriptorData {
@@ -92,7 +97,7 @@ const SUBTEST_FILTERS: Array<RegExp> = [
9297
const CHROME_DEFINITION: BrowserDefinition = {
9398
name: 'Chrome',
9499
logo: 'https://unpkg.com/@browser-logos/chrome@2.0.0/chrome.svg',
95-
versions: Array.from({length: 104 - 79})
100+
versions: Array.from({length: 104 - 102 /*79*/})
96101
.map((_, i) => 79 + i)
97102
.filter(version => ![82].includes(version))
98103
.map(version => `${version}.0`)
@@ -117,14 +122,14 @@ const SAFARI_IOS_DEFINITION: BrowserDefinition = {
117122
logo: 'https://unpkg.com/@browser-logos/safari-ios@1.0.15/safari-ios.svg',
118123
versions: (
119124
[
120-
['13.7', '13.7'],
121-
['14.0', '14'],
122-
['14.1', '14'],
123-
['15.0', '15'],
124-
['15.2', '15'],
125-
['15.4', '15'],
126-
['15.5', '15'],
127-
['15.6', '15'],
125+
// ['13.7', '13.7'],
126+
// ['14.0', '14'],
127+
// ['14.1', '14'],
128+
// ['15.0', '15'],
129+
// ['15.2', '15'],
130+
// ['15.4', '15'],
131+
// ['15.5', '15'],
132+
// ['15.6', '15'],
128133
] as Array<[string, string]>
129134
).map(([browserVersion, osVersion]) => ({
130135
name: browserVersion,
@@ -147,9 +152,9 @@ const SAFARI_MACOS_DEFINITION: BrowserDefinition = {
147152
logo: 'https://unpkg.com/@browser-logos/safari-ios@1.0.15/safari-ios.svg',
148153
versions: (
149154
[
150-
['13.1', 'Catalina'],
151-
['14.1', 'Big Sur'],
152-
['15.3', 'Monterey'],
155+
// ['13.1', 'Catalina'],
156+
// ['14.1', 'Big Sur'],
157+
// ['15.3', 'Monterey'],
153158
] as Array<[string, string]>
154159
).map(([browserVersion, osVersion]) => ({
155160
name: browserVersion,
@@ -170,7 +175,7 @@ const SAFARI_MACOS_DEFINITION: BrowserDefinition = {
170175
const EDGE_DEFINITION: BrowserDefinition = {
171176
name: 'Edge',
172177
logo: 'https://unpkg.com/@browser-logos/edge@2.0.5/edge.svg',
173-
versions: Array.from({length: 104 - 80})
178+
versions: Array.from({length: 104 - 104/*80*/})
174179
.map((_, i) => 80 + i)
175180
.filter(version => ![82].includes(version))
176181
.map(version => `${version}.0`)
@@ -193,7 +198,7 @@ const EDGE_DEFINITION: BrowserDefinition = {
193198
const FIREFOX_DEFINITION: BrowserDefinition = {
194199
name: 'Firefox',
195200
logo: 'https://unpkg.com/@browser-logos/firefox@3.0.9/firefox.svg',
196-
versions: Array.from({length: 103 - 69})
201+
versions: Array.from({length: 103 - 103/*69*/})
197202
.map((_, i) => 69 + i)
198203
.map(version => `${version}.0`)
199204
.map(browserVersion => ({
@@ -212,52 +217,12 @@ const FIREFOX_DEFINITION: BrowserDefinition = {
212217
})),
213218
};
214219

215-
const SAMSUNG_INTERNET_DEFINITION: BrowserDefinition = {
216-
name: 'Samsung Internet',
217-
logo: 'https://unpkg.com/@browser-logos/samsung-internet@4.0.6/samsung-internet.svg',
218-
versions: [
219-
'9.2',
220-
'10.1',
221-
'11.2',
222-
'12.0',
223-
'13.0',
224-
'14.0',
225-
'15.0',
226-
'16.0',
227-
'17.0',
228-
].map(browserVersion => ({
229-
name: browserVersion,
230-
data: {
231-
type: DataType.FetchDescriptor,
232-
capabilities: {
233-
'bstack:options': {
234-
osVersion: '12.0',
235-
deviceName: 'Samsung Galaxy S22 Ultra',
236-
},
237-
browserName: 'samsung',
238-
browserVersion,
239-
},
240-
},
241-
})),
242-
};
243-
244-
const IE_DEFINITION: BrowserDefinition = {
245-
name: 'Internet Explorer',
246-
logo: 'https://unpkg.com/@browser-logos/internet-explorer_9-11@1.1.16/internet-explorer_9-11.svg',
247-
versions: ['9', '10', '11'].map(browserVersion => ({
248-
name: browserVersion,
249-
data: {type: DataType.Result, result: [0, 0]},
250-
})),
251-
};
252-
253220
const BROWSERS: BrowserDefinition[] = [
254221
CHROME_DEFINITION,
255222
SAFARI_IOS_DEFINITION,
256223
SAFARI_MACOS_DEFINITION,
257224
EDGE_DEFINITION,
258225
FIREFOX_DEFINITION,
259-
SAMSUNG_INTERNET_DEFINITION,
260-
IE_DEFINITION,
261226
];
262227

263228
interface Subtest {
@@ -419,8 +384,6 @@ async function main() {
419384
}
420385

421386
const testSuite = await getTests(manifestPath);
422-
console.info(`Using tests: ${JSON.stringify(testSuite, null, 4)}`);
423-
424387
const tests: Array<() => Promise<void>> = [];
425388
const results: BrowserDefinition[] = BROWSERS.map(browser => ({
426389
...browser,
@@ -445,20 +408,20 @@ async function main() {
445408
() => []
446409
);
447410

448-
let passed = 0;
449-
let failed = 0;
411+
const passed: TestDescriptor[] = [];
412+
const failed: TestDescriptor[] = [];
450413

451414
for (const test of results) {
452415
if (Array.isArray(test) && Array.isArray(test[1].tests)) {
453416
for (const subtest of test[1].tests) {
454417
if (SUBTEST_FILTERS.some(filter => filter.test(subtest.name))) {
455418
continue;
456419
}
457-
if (subtest.status === subtest.PASS) {
458-
passed++;
459-
} else if (subtest.status !== subtest.PRECONDITION_FAILED) {
460-
failed++;
461-
}
420+
const result = {test: test[0], subtest: subtest.name};
421+
const destination =
422+
subtest.status === subtest.PASS ? passed : failed;
423+
424+
destination.push(result);
462425
}
463426
}
464427
}
@@ -473,10 +436,54 @@ async function main() {
473436
const server = await createLocalServer();
474437
try {
475438
await eachLimit(tests, 5, async test => await test());
476-
console.log(JSON.stringify(results, null, 2));
477439
} finally {
478440
await stopLocalServer(server);
479441
}
442+
443+
interface TestToSubtestMap {
444+
[key: string]: SubtestMap;
445+
}
446+
447+
interface SubtestMap {
448+
[key: string]: string[];
449+
}
450+
451+
function getTargetResultBucket(
452+
testToSubtestMap: TestToSubtestMap,
453+
descriptor: TestDescriptor
454+
) {
455+
const testToSubtest = (testToSubtestMap[descriptor.test] =
456+
testToSubtestMap[descriptor.test] || {});
457+
const subtestToBucket = (testToSubtest[descriptor.subtest] =
458+
testToSubtest[descriptor.subtest] || []);
459+
460+
testToSubtestMap[descriptor.test] = testToSubtest;
461+
testToSubtest[descriptor.subtest] = subtestToBucket;
462+
463+
return subtestToBucket;
464+
}
465+
466+
const testToSubtests: TestToSubtestMap = {};
467+
for (const browser of results) {
468+
for (const version of browser.versions) {
469+
if (version.data.type === DataType.Result) {
470+
const [passed, failed] = version.data.result;
471+
const name = `${browser.name} ${version.name}`;
472+
473+
for (const result of passed) {
474+
const bucket = getTargetResultBucket(testToSubtests, result);
475+
bucket.push(name);
476+
}
477+
478+
for (const result of failed) {
479+
const bucket = getTargetResultBucket(testToSubtests, result);
480+
bucket.push(name);
481+
}
482+
}
483+
}
484+
}
485+
486+
console.info(JSON.stringify(testToSubtests), null, 2);
480487
}
481488

482489
try {

0 commit comments

Comments
 (0)