1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-21 15:04:11 -05:00

chore: show expectation diff for wpt tests (#26014)

Closes https://github.com/denoland/deno/issues/26012

```
========================================

failures:

        "/WebCryptoAPI/wrapKey_unwrapKey/wrapKey_unwrapKey.https.any.html - Can wrap and unwrap X25519 private key keys as non-extractable using pkcs8 and AES-CTR"

final result: failed. 1 passed; 1 failed; 0 expected failure; total 2 (15646ms)

diff --git a/Users/divy/gh/deno/tests/wpt/runner/expectation.json b/var/folders/ll/ltqsx4nx72v5_r7rlsl36pgm0000gn/T/375d79f1257b05cd
index fb2063935..4449c5d15 100644
--- a/Users/divy/gh/deno/tests/wpt/runner/expectation.json
+++ b/var/folders/ll/ltqsx4nx72v5_r7rlsl36pgm0000gn/T/375d79f1257b05cd
@@ -1531,6 +1531,7 @@
     },
     "wrapKey_unwrapKey": {
       "wrapKey_unwrapKey.https.any.html": [
+        "Can wrap and unwrap X25519 private key keys as non-extractable using pkcs8 and AES-CTR",
         "Can wrap and unwrap X25519 private key keys as non-extractable using pkcs8 and AES-CBC",
         "Can wrap and unwrap X25519 private key keys as non-extractable using pkcs8 and AES-GCM",
         "Can wrap and unwrap X25519 private key keys as non-extractable using pkcs8 and AES-KW",
```
This commit is contained in:
Divy Srivastava 2024-10-03 18:31:36 +05:30 committed by GitHub
parent da7edf1c0c
commit 54467015e0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 43 additions and 10 deletions

View file

@ -76,7 +76,10 @@ export function getManifest(): Manifest {
/// WPT TEST EXPECTATIONS /// WPT TEST EXPECTATIONS
const EXPECTATION_PATH = join(ROOT_PATH, "./tests/wpt/runner/expectation.json"); export const EXPECTATION_PATH = join(
ROOT_PATH,
"./tests/wpt/runner/expectation.json",
);
export interface Expectation { export interface Expectation {
[key: string]: Expectation | boolean | string[] | { ignore: boolean }; [key: string]: Expectation | boolean | string[] | { ignore: boolean };
@ -87,9 +90,12 @@ export function getExpectation(): Expectation {
return JSON.parse(expectationText); return JSON.parse(expectationText);
} }
export function saveExpectation(expectation: Expectation) { export function saveExpectation(
expectation: Expectation,
path: string = EXPECTATION_PATH,
) {
Deno.writeTextFileSync( Deno.writeTextFileSync(
EXPECTATION_PATH, path,
JSON.stringify(expectation, undefined, " ") + "\n", JSON.stringify(expectation, undefined, " ") + "\n",
); );
} }
@ -134,6 +140,15 @@ export function runPy<T extends Omit<Deno.CommandOptions, "cwd">>(
}).spawn(); }).spawn();
} }
export async function runGitDiff(args: string[]): string {
await new Deno.Command("git", {
args: ["diff", ...args],
stdout: "inherit",
stderr: "inherit",
cwd: ROOT_PATH,
}).output();
}
export async function checkPy3Available() { export async function checkPy3Available() {
const { success, stdout } = await runPy(["--version"], { const { success, stdout } = await runPy(["--version"], {
stdout: "piped", stdout: "piped",

View file

@ -18,6 +18,7 @@ import {
checkPy3Available, checkPy3Available,
escapeLoneSurrogates, escapeLoneSurrogates,
Expectation, Expectation,
EXPECTATION_PATH,
generateRunInfo, generateRunInfo,
getExpectation, getExpectation,
getExpectFailForCase, getExpectFailForCase,
@ -30,6 +31,7 @@ import {
noIgnore, noIgnore,
quiet, quiet,
rest, rest,
runGitDiff,
runPy, runPy,
updateManifest, updateManifest,
wptreport, wptreport,
@ -256,7 +258,16 @@ async function run() {
await Deno.writeTextFile(wptreport, JSON.stringify(report) + "\n"); await Deno.writeTextFile(wptreport, JSON.stringify(report) + "\n");
} }
const newExpectations = newExpectation(results);
const tmp = Deno.makeTempFileSync();
saveExpectation(newExpectations, tmp);
const code = reportFinal(results, endTime - startTime); const code = reportFinal(results, endTime - startTime);
// Run git diff to see what changed
await runGitDiff([EXPECTATION_PATH, tmp]);
Deno.removeSync(tmp);
Deno.exit(code); Deno.exit(code);
} }
@ -390,6 +401,19 @@ async function update() {
await Deno.writeTextFile(json, JSON.stringify(results) + "\n"); await Deno.writeTextFile(json, JSON.stringify(results) + "\n");
} }
const newExpectations = newExpectation(results);
saveExpectation(newExpectations);
reportFinal(results, endTime - startTime);
console.log(blue("Updated expectation.json to match reality."));
Deno.exit(0);
}
function newExpectation(
results: { test: TestToRun; result: TestResult }[],
): Expectation {
const resultTests: Record< const resultTests: Record<
string, string,
{ passed: string[]; failed: string[]; testSucceeded: boolean } { passed: string[]; failed: string[]; testSucceeded: boolean }
@ -431,13 +455,7 @@ async function update() {
); );
} }
saveExpectation(currentExpectation); return currentExpectation;
reportFinal(results, endTime - startTime);
console.log(blue("Updated expectation.json to match reality."));
Deno.exit(0);
} }
function insertExpectation( function insertExpectation(