-
Notifications
You must be signed in to change notification settings - Fork 25
Improve backwards compat test #3039
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
base: main
Are you sure you want to change the base?
Conversation
Created using jj-spr 0.1.0
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Created using jj-spr 0.1.0
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.
Bug: Temporary CLI install directory never cleaned up
The checkLatestPublishedCLI() function creates a temporary directory via fs.mkdtempSync() and stores it in the global CLI_INSTALL_DIR variable. However, there's no corresponding cleanup in an after() hook at the outer describe level to remove this directory after all tests complete. This causes a resource leak where temporary directories accumulate in the system's temp folder. An after() hook should be added to clean up CLI_INSTALL_DIR when the test suite finishes.
apps/framework-cli-e2e/test/backward-compatibility.test.ts#L246-L263
moosestack/apps/framework-cli-e2e/test/backward-compatibility.test.ts
Lines 246 to 263 in 73ccd44
| describe("Backward Compatibility Tests", function () { | |
| before(async function () { | |
| this.timeout(TIMEOUTS.TEST_SETUP_MS); | |
| // Check latest published CLI is available | |
| await checkLatestPublishedCLI(); | |
| // Verify new CLI is built | |
| try { | |
| await fs.promises.access(CLI_PATH, fs.constants.F_OK); | |
| } catch (err) { | |
| console.error( | |
| `CLI not found at ${CLI_PATH}. It should be built in the pretest step.`, | |
| ); | |
| throw err; | |
| } | |
| }); |
apps/framework-cli-e2e/test/backward-compatibility.test.ts#L64-L106
moosestack/apps/framework-cli-e2e/test/backward-compatibility.test.ts
Lines 64 to 106 in 73ccd44
| */ | |
| async function checkLatestPublishedCLI(): Promise<void> { | |
| console.log("Installing latest published moose-cli from npm..."); | |
| try { | |
| // Create a temp directory for CLI install | |
| const os = require("os"); | |
| CLI_INSTALL_DIR = fs.mkdtempSync(path.join(os.tmpdir(), "moose-cli-")); | |
| console.log(`Installing CLI to temp directory: ${CLI_INSTALL_DIR}`); | |
| // Install CLI using pnpm (consistent with monorepo) | |
| const installResult = await execAsync( | |
| "pnpm add @514labs/moose-cli@latest", | |
| { cwd: CLI_INSTALL_DIR }, | |
| ); | |
| console.log("pnpm install output:", installResult.stdout); | |
| // Find the installed CLI binary in pnpm's structure | |
| LATEST_CLI_PATH = path.join( | |
| CLI_INSTALL_DIR, | |
| "node_modules", | |
| ".bin", | |
| "moose-cli", | |
| ); | |
| // Verify it exists and works | |
| if (!fs.existsSync(LATEST_CLI_PATH)) { | |
| throw new Error(`CLI binary not found at ${LATEST_CLI_PATH}`); | |
| } | |
| const { stdout: version } = await execAsync( | |
| `"${LATEST_CLI_PATH}" --version`, | |
| ); | |
| console.log("Latest published CLI version:", version.trim()); | |
| } catch (error: any) { | |
| console.error("Failed to install latest CLI:", error.message); | |
| if (error.stdout) console.error("stdout:", error.stdout); | |
| if (error.stderr) console.error("stderr:", error.stderr); | |
| throw new Error( | |
| "Cannot install latest published CLI for backward compatibility test", | |
| ); | |
| } | |
| } |
Created using jj-spr 0.1.0
Created using jj-spr 0.1.0
Created using jj-spr 0.1.0
Note
Use a temp pnpm-installed moose-cli instead of npx, switch installs to pnpm, explicitly use Python 3.13, and update flake to python313 with cleanup handling.
apps/framework-cli-e2e/test/backward-compatibility.test.ts):@514labs/moose-cliviapnpminto a temp dir and use its binary (LATEST_CLI_PATH) forinitanddev.npm installwithpnpm installfor TypeScript template setup.python3.13and install fromrequirements.txt.afterhook to clean up the temporary CLI install directory.flake.nix):python312topython313and propagate throughpythonEnv.Written by Cursor Bugbot for commit 6663a7e. This will update automatically on new commits. Configure here.