Repository navigation
Fix errors from test wild #294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
aspeddro
merged 6 commits into
rescript-lang:main
from
aspeddro:fix-errors-from-test-wild
Jul 11, 2026
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
5649b3d
Implemented all three parser fixes:
aspeddro 903de35
Fixed glennsl/rescript-jest `jest.res`.
aspeddro 5fc8ac9
Fixed `Sury.res`
aspeddro 8433765
Add script test wild
aspeddro 01dac02
Skip test on Windows
aspeddro 3806920
ci: continue-on-error
aspeddro File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,170 @@ | ||
| import child_process from "node:child_process"; | ||
| import fs from "node:fs"; | ||
| import path from "node:path"; | ||
|
|
||
| const repositories = [ | ||
| { | ||
| url: "https://github.com/rescript-lang/experimental-rescript-webapi", | ||
| commit: null, | ||
| }, | ||
| { url: "https://github.com/rescript-lang/rescript-lang.org", commit: null }, | ||
| { url: "https://github.com/rescript-lang/rescript-react", commit: null }, | ||
| { url: "https://github.com/enviodev/hyperindex", commit: null }, | ||
| { url: "https://github.com/frontman-ai/frontman", commit: null }, | ||
| { url: "https://github.com/zth/rescript-relay", commit: null }, | ||
| { url: "https://github.com/glennsl/rescript-jest", commit: null }, | ||
| { url: "https://github.com/cca-io/rescript-mui", commit: null }, | ||
| { url: "https://github.com/DZakh/sury", commit: null }, | ||
| { url: "https://github.com/DZakh/rescript-envsafe", commit: null }, | ||
| { url: "https://github.com/DZakh/rescript-rest", commit: null } | ||
| ]; | ||
|
|
||
| const TEST_WILD_DIR = path.join(process.cwd(), "test_wild"); | ||
|
|
||
| if (!fs.existsSync(TEST_WILD_DIR)) { | ||
| fs.mkdirSync(TEST_WILD_DIR); | ||
| } | ||
|
|
||
| const signals = { | ||
| SIGINT: 2, | ||
| SIGQUIT: 3, | ||
| SIGKILL: 9, | ||
| SIGTERM: 15, | ||
| }; | ||
| async function exec(command, args = [], cwd = process.cwd(), options = {}) { | ||
| const { throwOnFail = options.stdio === "inherit" } = options; | ||
|
|
||
| const stdoutChunks = []; | ||
| const stderrChunks = []; | ||
|
|
||
| const subprocess = child_process.spawn(command, args, { | ||
| cwd, | ||
| shell: process.platform === "win32", | ||
| stdio: ["ignore", "pipe", "pipe"], | ||
| ...options, | ||
| }); | ||
|
|
||
| subprocess.stdout?.on("data", (chunk) => { | ||
| stdoutChunks.push(chunk); | ||
| }); | ||
|
|
||
| subprocess.stderr?.on("data", (chunk) => { | ||
| stderrChunks.push(chunk); | ||
| }); | ||
|
|
||
| return await new Promise((resolve, reject) => { | ||
| subprocess.once("error", (err) => { | ||
| reject(err); | ||
| }); | ||
|
|
||
| subprocess.once("close", (exitCode, signal) => { | ||
| const stdout = Buffer.concat(stdoutChunks).toString("utf8"); | ||
| const stderr = Buffer.concat(stderrChunks).toString("utf8"); | ||
|
|
||
| let code = exitCode ?? 1; | ||
| if (signals[signal]) { | ||
| // + 128 is standard POSIX practice, see also https://nodejs.org/api/process.html#exit-codes | ||
| code = signals[signal] + 128; | ||
| } | ||
|
|
||
| if (throwOnFail && code !== 0) { | ||
| reject( | ||
| new Error(`Command ${command} exited with non-zero status: ${code}`), | ||
| ); | ||
| } else { | ||
| resolve({ status: code, stdout, stderr }); | ||
| } | ||
| }); | ||
| }); | ||
| } | ||
|
|
||
| async function cloneRepo({ url, commit }) { | ||
| const baseName = url.split("/").pop(); | ||
| const dirName = commit ? `${baseName}-${commit}` : baseName; | ||
| const repoDir = path.join(TEST_WILD_DIR, dirName); | ||
| const label = commit ? `${baseName}@${commit}` : baseName; | ||
|
|
||
| if (fs.existsSync(repoDir)) { | ||
| console.log(`[${label}] already cloned, skipping`); | ||
| return { repoDir, dirName, label }; | ||
| } | ||
|
|
||
| if (commit) { | ||
| console.log(`[${label}] cloning at commit ${commit}...`); | ||
| await exec("git", ["clone", url, repoDir]); | ||
| await exec("git", ["checkout", commit], repoDir); | ||
| } else { | ||
| console.log(`[${label}] cloning...`); | ||
| await exec("git", ["clone", "--depth=1", url, repoDir]); | ||
| } | ||
| console.log(`[${label}] cloned`); | ||
| return { repoDir, dirName, label }; | ||
| } | ||
|
|
||
| async function parseRepo(dirName, label) { | ||
| const globPatternRes = `test_wild/${dirName}/**/*.res`; | ||
| console.log(`[${label}] running tree-sitter parse...`); | ||
|
|
||
| const { stdout, stderr } = await exec("npx", [ | ||
| "tree-sitter", | ||
| "parse", | ||
| "--json-summary", | ||
| globPatternRes, | ||
| ]); | ||
|
|
||
| const validJson = stdout | ||
| .split("\n") | ||
| .filter((line) => !line.trim().startsWith("test_wild")) | ||
| .join("\n"); | ||
|
|
||
| try { | ||
| const result = JSON.parse(validJson); | ||
| return result.parse_summaries ?? []; | ||
| } catch { | ||
| console.error({ | ||
| stdout: stdout, | ||
| stderr: stderr, | ||
| }); | ||
| throw new Error(`Failed to parse json`); | ||
| } | ||
| } | ||
|
|
||
| async function processRepo(repo) { | ||
| const { dirName, label } = await cloneRepo(repo); | ||
|
|
||
| const summaries = await parseRepo(dirName, label); | ||
| const errors = summaries.filter((s) => !s.successful); | ||
|
|
||
| console.log( | ||
| `[${label}] ${summaries.length} files parsed, ${errors.length} errors`, | ||
| ); | ||
| return { label, summaries, errors }; | ||
| } | ||
|
|
||
| async function main() { | ||
| const results = await Promise.all(repositories.map(processRepo)); | ||
|
|
||
| console.log("\n=== Parse Error Summary ===\n"); | ||
| let totalErrors = 0; | ||
|
|
||
| for (const { label, summaries, errors } of results) { | ||
| console.log( | ||
| `${label}: ${errors.length} / ${summaries.length} files with errors`, | ||
| ); | ||
| for (const entry of errors) { | ||
| console.log(` ${entry.file}`); | ||
| } | ||
| totalErrors += errors.length; | ||
| } | ||
|
|
||
| console.log(`\nTotal files with errors: ${totalErrors}`); | ||
|
|
||
| if (totalErrors > 0) { | ||
| throw new Error("Test wild failed"); | ||
| } | ||
| } | ||
|
|
||
| main().catch((err) => { | ||
| console.error(err); | ||
| process.exit(1); | ||
| }); | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.