diff options
author | Andreu Botella <abb@randomunok.com> | 2021-07-07 19:56:47 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-07 19:56:47 +0200 |
commit | c972fe6cec8f643fbafd0fe33b461798faedaf80 (patch) | |
tree | 394808f66b3b31e9956e0431121f0470c4966c7c | |
parent | 29b9c89312547661fa8e32efd2f29a653b83d730 (diff) |
tests: escape lone surrogates in wptreport (#11310)
-rwxr-xr-x | tools/wpt.ts | 10 | ||||
-rw-r--r-- | tools/wpt/utils.ts | 10 |
2 files changed, 16 insertions, 4 deletions
diff --git a/tools/wpt.ts b/tools/wpt.ts index 46829c036..9d1e689ac 100755 --- a/tools/wpt.ts +++ b/tools/wpt.ts @@ -14,6 +14,7 @@ import { autoConfig, cargoBuild, checkPy3Available, + escapeLoneSurrogates, Expectation, generateRunInfo, getExpectation, @@ -235,16 +236,17 @@ async function generateWptReport( } return { - name: case_.name, + name: escapeLoneSurrogates(case_.name), status: case_.passed ? "PASS" : "FAIL", - message: case_.message, + message: escapeLoneSurrogates(case_.message), expected, known_intermittent: [], }; }), status, - message: result.harnessStatus?.message ?? - (result.stderr.trim() || null), + message: escapeLoneSurrogates( + result.harnessStatus?.message ?? (result.stderr.trim() || null), + ), duration: result.duration, expected: status === "OK" ? undefined : "OK", "known_intermittent": [], diff --git a/tools/wpt/utils.ts b/tools/wpt/utils.ts index 13c68ec90..1f76ff128 100644 --- a/tools/wpt/utils.ts +++ b/tools/wpt/utils.ts @@ -154,6 +154,16 @@ export async function cargoBuild() { assert(status.success, "cargo build failed"); } +export function escapeLoneSurrogates(input: string): string; +export function escapeLoneSurrogates(input: string | null): string | null; +export function escapeLoneSurrogates(input: string | null): string | null { + if (input === null) return null; + return input.replace( + /[\uD800-\uDFFF]/gu, + (match) => `U+${match.charCodeAt(0).toString(16)}`, + ); +} + /// WPTREPORT export async function generateRunInfo(): Promise<unknown> { |