Skip to content

Commit 23039db

Browse files
committed
Document WPT capability runner functions
1 parent 7dadbe6 commit 23039db

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

packages/wpt-runner/scripts/capabilities.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export interface CapabilityRow {
1313

1414
const VALID_STATUSES: ReadonlySet<string> = new Set(['supported', 'deferred']);
1515

16+
/** Reads a capability table and rejects content that is not canonical. */
1617
export async function readCapabilities(file: string): Promise<CapabilityRow[]> {
1718
const source = await fs.readFile(file, 'utf8');
1819
const rows = parseCapabilities(source, file);
@@ -27,6 +28,7 @@ export async function readCapabilities(file: string): Promise<CapabilityRow[]> {
2728
return rows;
2829
}
2930

31+
/** Parses and validates capability rows from escaped TSV source. */
3032
export function parseCapabilities(
3133
source: string,
3234
label = 'capabilities.tsv',
@@ -89,6 +91,7 @@ export function parseCapabilities(
8991
return rows;
9092
}
9193

94+
/** Sorts and serializes capability rows as canonical escaped TSV. */
9295
export function serializeCapabilities(rows: readonly CapabilityRow[]): string {
9396
const sorted = [...rows].sort(compareCapabilityRows);
9497
const lines = [
@@ -119,6 +122,7 @@ export function compareCodeUnits(left: string, right: string): number {
119122
return left < right ? -1 : 1;
120123
}
121124

125+
/** Groups capability rows by their WPT file while preserving row order. */
122126
export function rowsByPath(
123127
rows: readonly CapabilityRow[],
124128
): Map<string, CapabilityRow[]> {
@@ -143,6 +147,7 @@ function escapeField(value: string): string {
143147
.replaceAll('\r', '\\r');
144148
}
145149

150+
/** Decodes supported TSV escapes and rejects malformed sequences. */
146151
function unescapeField(
147152
value: string,
148153
label: string,

packages/wpt-runner/scripts/run-wpt.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ try {
113113
await server?.close().catch(() => {});
114114
}
115115

116+
/** Parses CLI flags and chooses the default capability enforcement mode. */
116117
function parseArguments(arguments_: string[]): RunnerOptions {
117118
const normalizedArguments =
118119
arguments_[0] === '--' ? arguments_.slice(1) : arguments_;
@@ -147,6 +148,7 @@ function parseArguments(arguments_: string[]): RunnerOptions {
147148
};
148149
}
149150

151+
/** Resolves deduplicated WPT paths and verifies enforced paths are classified. */
150152
function selectPaths(
151153
options: RunnerOptions,
152154
groupedCapabilities: ReadonlyMap<string, readonly CapabilityRow[]>,
@@ -167,6 +169,7 @@ function selectPaths(
167169
return paths;
168170
}
169171

172+
/** Runs one WPT file and converts page evaluation errors into a run record. */
170173
async function runWpt(
171174
browserPage: Page,
172175
testPath: string,
@@ -189,6 +192,7 @@ async function runWpt(
189192
}
190193
}
191194

195+
/** Reports an unclassified run and returns whether any result failed. */
192196
function printExploratoryResult(run: WptRunRecord): boolean {
193197
const tests = run.result?.tests ?? [];
194198
const failedTests = tests.filter((test) => test.status !== 0);
@@ -206,6 +210,7 @@ function printExploratoryResult(run: WptRunRecord): boolean {
206210
return failed;
207211
}
208212

213+
/** Evaluates and reports classified results, drift, and promotion candidates. */
209214
function printCapabilityResult(
210215
run: WptRunRecord,
211216
rows: readonly CapabilityRow[],
@@ -263,6 +268,7 @@ function printTestFailure(test: WptHarnessTestResult, prefix: string): void {
263268
if (test.stack) console.log(indent(test.stack, ' '));
264269
}
265270

271+
/** Prints a run error and its most recent captured browser logs. */
266272
function printRunError(run: WptRunRecord): void {
267273
if (run.error) console.log(indent(run.error, ' '));
268274
if (run.state === 'error' && run.logs?.length > 0) {

0 commit comments

Comments
 (0)