Repository navigation
ci(jtreg): run only the OpenJDK tests that cover java-web code no faster test covers #79
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
Open
Project516
wants to merge
6
commits into
master
Choose a base branch
from
p516/prune-tests
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
eeb4526
ci(jtreg): run only the OpenJDK tests that cover java-web code no fas…
Project516 6b6772a
ci(jtreg): run only the OpenJDK tests that cover java-web code no fas…
Project516 5797009
ci(jtreg): run only the OpenJDK tests that cover java-web code no fas…
Project516 643e3ad
ci(jtreg): run only the OpenJDK tests that cover java-web code no fas…
Project516 9b4cc86
ci(jtreg): run only the OpenJDK tests that cover java-web code no fas…
Project516 8a1fe2a
ci(jtreg): run only the OpenJDK tests that cover java-web code no fas…
Project516 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| // Splits the tests of passing.txt and redundant.txt between the two by what | ||
| // they cover. Coverage comes from a run with --coverage, which reruns both: | ||
| // | ||
| // node scripts/jtreg/run.ts <jdk> --only-passing --coverage build/coverage --vm dist/node.js | ||
| // node scripts/jtreg/prune.ts build/coverage | ||
| // | ||
| // java-web runs OpenJDK's class library unmodified, so a test only checks | ||
| // java-web where it runs java-web's own code. Fastest first (times.tsv), a | ||
| // test goes in passing.txt when it ran a block of the VM no test before it | ||
| // there ran, and in redundant.txt otherwise. Tests in locale-data.txt stay in | ||
| // passing.txt, and a test without a coverage file (it failed, timed out or did | ||
| // not run) stays in the list it was in. | ||
|
|
||
| import { existsSync, readFileSync, writeFileSync } from "node:fs"; | ||
| import { join } from "node:path"; | ||
|
|
||
| const root = join(import.meta.dirname, "..", ".."); | ||
| const dir = process.argv[2]; | ||
| if (!dir) { | ||
| console.error("usage: node scripts/jtreg/prune.ts <coverage dir>"); | ||
| process.exit(2); | ||
| } | ||
| const file = (name: string) => join(root, "test", "jtreg", name); | ||
| const list = (name: string) => existsSync(file(name)) | ||
| ? readFileSync(file(name), "utf8").split("\n").map((l) => l.trim()).filter((l) => l && !l.startsWith("#")) : []; | ||
|
|
||
| const passing = list("passing.txt"), wasRedundant = list("redundant.txt").filter((id) => !passing.includes(id)); | ||
| const read = (name: string) => { | ||
| try { | ||
| return readFileSync(file(name), "utf8"); | ||
| } catch { | ||
| return ""; | ||
| } | ||
| }; | ||
| const times = new Map(read("times.tsv").split("\n").filter(Boolean).map((l) => { | ||
| const [ms, id] = l.split("\t"); | ||
| return [id, Number(ms)]; | ||
| })); | ||
| const median = [...times.values()].sort((a, b) => a - b)[times.size >> 1] ?? 0; | ||
| const ms = (id: string) => times.get(id) ?? median; | ||
| const locale = new Set(list("locale-data.txt")); | ||
| const blocksOf = (id: string) => { | ||
| const f = join(dir, `${id.replace(/[#/]/g, "_")}.txt`); | ||
| return existsSync(f) ? readFileSync(f, "utf8").split("\n").filter(Boolean) : null; | ||
| }; | ||
|
|
||
| const covered = new Set<string>(); | ||
| const keep = new Set<string>(), drop = new Set<string>(); | ||
| const candidates: [string, string[]][] = []; | ||
| for (const id of [...passing, ...wasRedundant]) { | ||
| const blocks = blocksOf(id); | ||
| if (!blocks) (passing.includes(id) ? keep : drop).add(id); | ||
| else if (locale.has(id)) keep.add(id); | ||
| else { | ||
| candidates.push([id, blocks]); | ||
| continue; | ||
| } | ||
| for (const b of blocks ?? []) covered.add(b); | ||
| } | ||
| for (const [id, blocks] of candidates.sort((a, b) => ms(a[0]) - ms(b[0]))) { | ||
| if (blocks.some((b) => !covered.has(b))) { | ||
| keep.add(id); | ||
| for (const b of blocks) covered.add(b); | ||
| } else drop.add(id); | ||
| } | ||
|
|
||
| writeFileSync(file("passing.txt"), "# OpenJDK tests that pass on java-web; scripts/jtreg/run.ts --only-passing reruns them\n" | ||
| + [...keep].sort().join("\n") + "\n"); | ||
| writeFileSync(file("redundant.txt"), "# OpenJDK tests that pass on java-web but run no java-web code that a faster test in\n" | ||
| + "# passing.txt does not (scripts/jtreg/prune.ts). To run one again, move it to passing.txt.\n" + [...drop].sort().join("\n") + "\n"); | ||
| const min = (ids: Set<string>) => ([...ids].reduce((n, id) => n + ms(id), 0) / 60000).toFixed(0); | ||
| console.log(`passing.txt: ${keep.size} tests (${min(keep)} test-minutes); redundant.txt: ${drop.size} (${min(drop)} test-minutes)`); |
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
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.