Skip to content

Commit

Permalink
Improve WPT-Diff scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
MovByte committed Dec 15, 2024
1 parent 5c6f22c commit 567dc33
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 9 deletions.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { envsafe, string } from "envsafe";
*
* @param browser The browser that the WPT-diff tests were run on
*/
async function getRunsInfoRes(browser: string, outfile: string): Promise<ResultAsync<any, Error>> {
export default async function getRunsInfoRes(browser: string, outfile: string): Promise<ResultAsync<any, Error>> {
let runsResp: Response;
try {
runsResp = await fetch("https://wpt.fyi/api/runs?label=experimental&label=master&aligned");
Expand All @@ -51,6 +51,10 @@ async function getRunsInfoRes(browser: string, outfile: string): Promise<ResultA
return fmtNeverthrowErr("Failed to parse the WPT Runs JSON, which was expected to contain the WPT runs info we need", err.message);
}

const runsInfoBrowser = runsInfoJSON.runs.find((run: any) => run.browser_name === browser);
if (!runsInfoBrowser)
return nErrAsync(`The browser you chose, ${browser}, was not found in the default WPT runs info`);

/** Meant to be an object in the array of the runs in the `runs.json` file. See @https://wpt.fyi/api/runs?label=experimental&label=master&aligned. */
return getRunsInfoObjJSON(runsInfoJSON);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import type { ResultAsync } from "neverthrow";
import { okAsync, errAsync as nErrAsync } from "neverthrow";
import errLogAfterColon, { fmtNeverthrowErr } from "../util/fmtErrTest.ts";

import type { ResultsSummary } from "../../../WPTUtils/types/diff.d.ts";
import type { ResultsSummary } from "../../../WPTUtils/types/diff";

// Utility
import { safeExec } from "../util/safeExec.ts";
import { setupPatchedCLI } from "./setupCLI.ts";
import setupPatchedCLI from "./util/patchCLI.ts";
import writeNPMVersions from "../util/getNPMVersions.ts";
//import convertWptreportToExpectations from "../../../WPTUtils/src/convertWptreportToExpectations.ts";
/// For CLI
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Neverthrow
import type { Result, ResultAsync } from "neverthrow";
import { ok as nOk, okAsync as nOkAsync, errAsync as nErrAsync } from "neverthrow";
import { fmtNeverthrowErr } from "../util/fmtErrTest.ts";
import { fmtNeverthrowErr } from "../../util/fmtErrTest.ts";

import type { Maybe } from "option-t/maybe";
import { unwrapMaybe } from "option-t/maybe/maybe";
Expand All @@ -19,13 +19,13 @@ import Parser from "tree-sitter";
import Python from "tree-sitter-python";

// Utility
import checkoutRepo from "../util/checkoutRepo.ts";
import checkoutRepo from "../../util/checkoutRepo.ts";

/**
* Gets the WPT CLI and patches it for the *WPT-Diff* tests (to work under proxies)
* This is a helper function meant to be for internal-use only, but it is exposed just in case you want to use it for whatever reason.
*/
export async function setupCLI({ dirs, proxyURL, wptRepo, browser, proxyName }: {
export default async function setupPatchedCLI({ dirs, proxyURL, wptRepo, browser, proxyName }: {
dirs: {
checkout: string
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// Neverthrow
import type { ResultAsync } from "neverthrow";
import { okAsync } from "neverthrow";
import { fmtNeverthrowErr } from "../util/fmtErrTest.ts";
import { fmtNeverthrowErr } from "../../util/fmtErrTest.ts";

import { resolve } from "node:path";

// Utility
import getNPMVersions from "../util/getNPMVersions.ts";
import getNPMVersions from "../../util/getNPMVersions.ts";
import safeWriteFileToDir from "../../../WPTUtils/src/safeWriteFileToDir.ts";

/**
Expand Down
3 changes: 3 additions & 0 deletions aeroSW/tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
"dependencies": {
"envsafe": "^2.0.3",
"flags": "^0.2.2",
"option-t": "^51.0.0",
"tree-sitter": "^0.22.1",
"tree-sitter-python": "^0.23.5",
"yaml": "^2.6.1"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion aeroSW/tests/util/getNPMVersions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import type { ResultAsync } from "neverthrow";
import { okAsync, errAsync as nErrAsync } from "neverthrow";
import { fmtNeverthrowErr } from "./fmtErrTest";

import packageJSON from "../../aeroSW/package.json" with { type: "json" };
import packageJSON from "../../package.json" with { type: "json" };

type packageVersions = string[];

Expand Down

0 comments on commit 567dc33

Please sign in to comment.