Debian Codegraph @

testing/web-platform/mozilla/tests/webgpu/common/internal/file_loader.js

raw
1 /**
2 * AUTO-GENERATED - DO NOT EDIT. Source: https://github.com/gpuweb/cts
3 **/import { assert } from '../util/util.js';
4 import { parseQuery } from './query/parseQuery.js';
5
6
7 import { loadTreeForQuery } from './tree.js';
8
9 // A listing file, e.g. either of:
10 // - `src/webgpu/listing.ts` (which is dynamically computed, has a Promise<TestSuiteListing>)
11 // - `out/webgpu/listing.js` (which is pre-baked, has a TestSuiteListing)
12
13
14
15
16 // A .spec.ts file, as imported.
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32 // Override the types for addEventListener/removeEventListener so the callbacks can be used as
33 // strongly-typed.
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 // Base class for DefaultTestFileLoader and FakeTestFileLoader.
59
60 export class TestFileLoader extends EventTarget {
61
62
63
64 async importSpecFile(suite, path) {
65 const url = `${suite}/${path.join('/')}.spec.js`;
66 this.dispatchEvent(new MessageEvent('import', { data: { url } }));
67 const ret = await this.import(url);
68 this.dispatchEvent(new MessageEvent('imported', { data: { url } }));
69 return ret;
70 }
71
72 async loadTree(
73 query,
74 {
75 subqueriesToExpand = [],
76 fullyExpandSubtrees = [],
77 maxChunkTime = Infinity
78 } = {})
79 {
80 const tree = await loadTreeForQuery(this, query, {
81 subqueriesToExpand: subqueriesToExpand.map((s) => {
82 const q = parseQuery(s);
83 assert(q.level >= 2, () => `subqueriesToExpand entries should not be multi-file:\n ${q}`);
84 return q;
85 }),
86 fullyExpandSubtrees: fullyExpandSubtrees.map((s) => parseQuery(s)),
87 maxChunkTime
88 });
89 this.dispatchEvent(new MessageEvent('finish'));
90 return tree;
91 }
92
93 async loadCases(query) {
94 const tree = await this.loadTree(query);
95 return tree.iterateLeaves();
96 }
97 }
98
99 export class DefaultTestFileLoader extends TestFileLoader {
100 async listing(suite) {
101 return (await import(`../../${suite}/listing.js`)).listing;
102 }
103
104 import(path) {
105 return import(`../../${path}`);
106 }
107 }