-
Notifications
You must be signed in to change notification settings - Fork 482
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
Changes from 2 commits
ca6efc5
58230ba
ae3ff11
cc010e0
5b82730
68afcc0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,43 +1,24 @@ | ||
| // @ts-check | ||
|
|
||
| import * as fs from "node:fs/promises"; | ||
| import * as assert from "node:assert"; | ||
| import { setup } from "#dev/process"; | ||
|
|
||
| const { execBuildLegacy, execCleanLegacy } = setup(import.meta.dirname); | ||
|
|
||
| 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 { stdout, stderr } = await execBuild(); | ||
|
|
||
| const expectedWarning = | ||
| "Duplicated package: z ./node_modules/z (chosen) vs ./a/node_modules/z in ./a"; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I believe so, as we use |
||
|
|
||
| const actualErrorOutput = postProcessErrorOutput(stderr.toString()); | ||
| if (updateTests) { | ||
| await fs.writeFile(expectedFilePath, actualErrorOutput); | ||
| } else { | ||
| const expectedErrorOutput = postProcessErrorOutput( | ||
| await fs.readFile(expectedFilePath, { encoding: "utf-8" }), | ||
| const output = stdout + stderr; | ||
| if (!output.includes(expectedWarning)) { | ||
| assert.fail( | ||
| `Expected duplicate package warning not found in output.\nExpected: ${expectedWarning}\nActual output:\n${output}`, | ||
| ); | ||
| 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.
Uh oh!
There was an error while loading. Please reload this page.