Skip to content

fix: can not rerun all tests when has command filter #502

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

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

9aoy
Copy link
Contributor

@9aoy 9aoy commented Aug 22, 2025

Summary

use virtual entry + virtualModulesPlugin.writeModule to trigger recompile.

Related Links

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

@Copilot Copilot AI review requested due to automatic review settings August 22, 2025 08:57
Copy link

netlify bot commented Aug 22, 2025

Deploy Preview for rstest-dev ready!

Name Link
🔨 Latest commit 630b788
🔍 Latest deploy log https://app.netlify.com/projects/rstest-dev/deploys/68a8323215c1610008a5badf
😎 Deploy Preview https://deploy-preview-502--rstest-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@9aoy 9aoy marked this pull request as draft August 22, 2025 08:57
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes an issue where rerunning all tests doesn't work properly when command filters are applied in watch mode. The solution introduces a virtual entry mechanism to trigger recompilation and removes the isFirstRun logic that was preventing proper test reruns.

  • Removes isFirstRun tracking and related conditional logic
  • Implements a virtual entry system using VirtualModulesPlugin to trigger recompilation
  • Updates test mode determination to use isFirstCompile and a forceRerunOnce flag

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/core/src/core/runTests.ts Removes isFirstRun logic and implements forceRerunOnce flag for triggering test reruns
packages/core/src/core/rsbuild.ts Removes isFirstRun tracking from Rsbuild stats
packages/core/src/core/plugins/entry.ts Adds virtual entry plugin with triggerRerun functionality using VirtualModulesPlugin
examples/node/test/index1.test.ts Adds new test file for testing the fix
e2e/watch/shortcuts.test.ts Updates test expectations and adds new test case for command filter scenario
e2e/watch/index.test.ts Updates test expectation from "Fully run test files for first run" to "Run all tests"

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

if (isWatch) {
// FIXME: inspect config will retrigger initConfig
Copy link
Preview

Copilot AI Aug 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The FIXME comment indicates a known issue but lacks detail about the problem and potential solutions. Consider expanding this comment to explain what 'inspect config will retrigger initConfig' means and its implications.

Suggested change
// FIXME: inspect config will retrigger initConfig
// FIXME: When the configuration is inspected (e.g., by tools or plugins that read or modify the config),
// it will cause initConfig to be retriggered. This can lead to multiple initializations,
// which may result in redundant plugin setup, unexpected side effects, or performance issues.
// Ideally, we should detect and prevent repeated initialization, or refactor the config
// inspection logic to avoid retriggering initConfig. See related discussion in issue tracker
// or consider implementing a guard to ensure initConfig runs only once per session.

Copilot uses AI. Check for mistakes.

virtualEntryPath,
`export const virtualEntry = ${Date.now()}`,
),
);
Copy link
Preview

Copilot AI Aug 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using Date.now() as a timestamp in code generation could be problematic for deterministic builds or testing. Consider using a counter or hash-based approach instead.

Suggested change
);
[virtualEntryPath]: `export const virtualEntry = ${virtualEntryVersion}`,
});
registerRerunTrigger(() => {
virtualEntryVersion += 1;
virtualModulesPlugin.writeModule(
virtualEntryPath,
`export const virtualEntry = ${virtualEntryVersion}`,
);
});

Copilot uses AI. Check for mistakes.

virtualEntryPath,
`export const virtualEntry = ${Date.now()}`,
),
);
Copy link
Preview

Copilot AI Aug 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue as above - using Date.now() for virtual module content could cause non-deterministic behavior. Consider using a counter or hash-based approach.

Suggested change
);
[virtualEntryPath]: `export const virtualEntry = ${virtualEntryVersion}`,
});
registerRerunTrigger(() => {
virtualEntryVersion += 1;
virtualModulesPlugin.writeModule(
virtualEntryPath,
`export const virtualEntry = ${virtualEntryVersion}`,
);
});

Copilot uses AI. Check for mistakes.

@9aoy
Copy link
Contributor Author

9aoy commented Aug 22, 2025

CI problem should be fixed by web-infra-dev/rspack#11460

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant