Skip to content

Commit

Permalink
Add expandAll for expectations
Browse files Browse the repository at this point in the history
  • Loading branch information
sagudev committed Jan 8, 2024
1 parent 3ce8d0e commit dd3fb51
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/common/internal/file_loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,17 @@ export abstract class TestFileLoader extends EventTarget {
query: TestQuery,
{
subqueriesToExpand = [],
expandAll = false,
maxChunkTime = Infinity,
}: { subqueriesToExpand?: string[]; maxChunkTime?: number } = {}
}: { subqueriesToExpand?: string[]; expandAll?: boolean; maxChunkTime?: number } = {}
): Promise<TestTree> {
const tree = await loadTreeForQuery(this, query, {
subqueriesToExpand: subqueriesToExpand.map(s => {
const q = parseQuery(s);
assert(q.level >= 2, () => `subqueriesToExpand entries should not be multi-file:\n ${q}`);
return q;
}),
expandAll,
maxChunkTime,
});
this.dispatchEvent(new MessageEvent<void>('finish'));
Expand Down
4 changes: 3 additions & 1 deletion src/common/internal/tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,9 @@ export async function loadTreeForQuery(
queryToLoad: TestQuery,
{
subqueriesToExpand,
expandAll = false,
maxChunkTime = Infinity,
}: { subqueriesToExpand: TestQuery[]; maxChunkTime?: number }
}: { subqueriesToExpand: TestQuery[]; expandAll?: boolean; maxChunkTime?: number }
): Promise<TestTree> {
const suite = queryToLoad.suite;
const specs = await loader.listing(suite);
Expand All @@ -302,6 +303,7 @@ export async function loadTreeForQuery(

// If toExpand == subquery, no expansion is needed (but it's still "seen").
if (ordering === Ordering.Equal) seenSubqueriesToExpand[i] = true;
if (expandAll) return ordering === Ordering.Unordered;
return ordering !== Ordering.StrictSubset;
});

Expand Down
6 changes: 6 additions & 0 deletions src/common/tools/gen_wpt_cts_html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ interface ConfigJSON {
file: string;
/** The prefix to trim from every line of the expectations_file. */
prefix: string;
/** Expend all subtrees for provided expectations */
expandAll?: boolean;
};
/*No long path assert */
noLongPathAssert?: boolean;
Expand All @@ -85,6 +87,7 @@ interface Config {
expectations?: {
file: string;
prefix: string;
expandAll: boolean;
};
}

Expand All @@ -110,6 +113,7 @@ let config: Config;
config.expectations = {
file: path.resolve(jsonFileDir, configJSON.expectations.file),
prefix: configJSON.expectations.prefix,
expandAll: configJSON.expectations.expandAll ?? false,
};
}
break;
Expand Down Expand Up @@ -143,6 +147,7 @@ let config: Config;
config.expectations = {
file: expectationsFile,
prefix: expectationsPrefix,
expandAll: false,
};
}
break;
Expand Down Expand Up @@ -188,6 +193,7 @@ let config: Config;
const rootQuery = new TestQueryMultiFile(config.suite, []);
const tree = await loader.loadTree(rootQuery, {
subqueriesToExpand: expectations.get(prefix),
expandAll: config.expectations?.expandAll,
maxChunkTime: config.maxChunkTimeMS,
});

Expand Down

0 comments on commit dd3fb51

Please sign in to comment.