-
Notifications
You must be signed in to change notification settings - Fork 477
Add duplicate package detection to rewatch #8180
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
+48
−31
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ca6efc5
Add duplicate package detection to rewatch
nojaf 58230ba
Add changelog
nojaf ae3ff11
Warn to stderr
nojaf cc010e0
Merge branch 'master' into rewatch-dup-pack
nojaf 5b82730
Set runtime env var
nojaf 68afcc0
fmt
nojaf 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 |
|---|---|---|
| @@ -1,43 +1,27 @@ | ||
| // @ts-check | ||
|
|
||
| import * as fs from "node:fs/promises"; | ||
| import * as assert from "node:assert"; | ||
| import { runtimePath } from "#cli/runtime"; | ||
| import { setup } from "#dev/process"; | ||
|
|
||
| const { execBuildLegacy, execCleanLegacy } = setup(import.meta.dirname); | ||
| // Set runtime path for rewatch to find | ||
| process.env.RESCRIPT_RUNTIME = runtimePath; | ||
|
|
||
| const expectedFilePath = "./out.expected"; | ||
|
|
||
| const updateTests = process.argv[2] === "update"; | ||
|
|
||
| /** | ||
| * @param {string} output | ||
| * @return {string} | ||
| */ | ||
| function postProcessErrorOutput(output) { | ||
| return output.trimEnd().replace(new RegExp(import.meta.dirname, "gi"), "."); | ||
| } | ||
| const { execBuild, execClean } = setup(import.meta.dirname); | ||
|
|
||
| if (process.platform === "win32") { | ||
| console.log("Skipping test on Windows"); | ||
| process.exit(0); | ||
| } | ||
|
|
||
| await execCleanLegacy(); | ||
| const { stderr } = await execBuildLegacy(); | ||
| await execClean(); | ||
| const { stderr } = await execBuild(); | ||
|
|
||
| const expectedWarning = | ||
| "Duplicated package: z ./node_modules/z (chosen) vs ./a/node_modules/z in ./a"; | ||
|
|
||
| const actualErrorOutput = postProcessErrorOutput(stderr.toString()); | ||
| if (updateTests) { | ||
| await fs.writeFile(expectedFilePath, actualErrorOutput); | ||
| } else { | ||
| const expectedErrorOutput = postProcessErrorOutput( | ||
| await fs.readFile(expectedFilePath, { encoding: "utf-8" }), | ||
| if (!stderr.includes(expectedWarning)) { | ||
| assert.fail( | ||
| `Expected duplicate package warning not found in stderr.\nExpected: ${expectedWarning}\nActual stderr:\n${stderr}`, | ||
| ); | ||
| if (expectedErrorOutput !== actualErrorOutput) { | ||
| console.error(`The old and new error output aren't the same`); | ||
| console.error("\n=== Old:"); | ||
| console.error(expectedErrorOutput); | ||
| console.error("\n=== New:"); | ||
| console.error(actualErrorOutput); | ||
| process.exit(1); | ||
| } | ||
| } | ||
This file was deleted.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The check in bsb was taking symlinks into account according to https://github.com/rescript-lang/rescript/blob/86814cea6e8dfd9dbf756a70a2e6c4964a7c5a60/tests/build_tests/duplicated_symlinked_packages/README.md.
Is the check here also doing that? I.e., is it only warning about
zor about other packages, too?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I believe so, as we use
canonicalize()