Skip to content

Comments

chore(test-dev-server): add retry mechanism to hmr-full-bundle-mode tests#7588

Merged
graphite-app[bot] merged 1 commit intomainfrom
copilot/add-retry-mechanism-to-tests
Dec 19, 2025
Merged

chore(test-dev-server): add retry mechanism to hmr-full-bundle-mode tests#7588
graphite-app[bot] merged 1 commit intomainfrom
copilot/add-retry-mechanism-to-tests

Conversation

Copy link
Contributor

Copilot AI commented Dec 19, 2025

  • Understand the test mechanism and retry requirements
  • Modify vitest-setup-playwright.ts to add a beforeEach hook that resets files from original playground directory
  • Modify vitest.config.browser.mts to add retry support (retry: process.env.CI ? 3 : 0)
  • Run lint and type checks
  • Address code review feedback:
    • Use nodePath.join() instead of template literals for path construction
    • Rethrow errors when file reset fails instead of just logging
    • Better document the 500ms delay value
  • Run code review and security checks

Summary of Changes

Problem

The hmr-full-bundle-mode.spec.ts tests were flaky and couldn't properly retry when a test failed mid-way. This is because:

  1. Tests modify files (hmr.js, main.js) during execution
  2. If a test fails mid-way, files remain in an inconsistent state
  3. On retry, the test tries to find and replace wrong content, causing the retry to fail

Solution

  1. Added retry support in vitest.config.browser.mts:

    • retry: process.env.CI ? 3 : 0 (3 retries in CI, 0 locally)
  2. Added file reset mechanism in vitest-setup-playwright.ts:

    • Added beforeEach hook that runs before each test (including retries)
    • resetTestFiles() function copies original files from playground/hmr-full-bundle-mode back to tmp-playground/hmr-full-bundle-mode
    • After reset, the page is reloaded to reflect the clean file state
    • Uses nodePath.join() for cross-platform path construction
    • Properly throws errors when file reset fails to prevent confusing test failures
Original prompt

Solve #7584

The task is not that easy. You need to make sure the test logic itself supports retry mechanism. Please go through how the test mechanism is implemented first.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@netlify
Copy link

netlify bot commented Dec 19, 2025

Deploy Preview for rolldown-rs canceled.

Name Link
🔨 Latest commit 84f3a52
🔍 Latest deploy log https://app.netlify.com/projects/rolldown-rs/deploys/69452f92349e2600089ed4af

Copilot AI changed the title [WIP] Add retry mechanism to test logic Add retry mechanism to hmr-full-bundle-mode tests Dec 19, 2025
Copilot AI requested a review from hyf0 December 19, 2025 04:42
@hyf0 hyf0 marked this pull request as ready for review December 19, 2025 05:10
Copilot AI review requested due to automatic review settings December 19, 2025 05:10
@hyf0 hyf0 changed the title Add retry mechanism to hmr-full-bundle-mode tests chore(test-dev-server): add retry mechanism to hmr-full-bundle-mode tests Dec 19, 2025
@hyf0 hyf0 unassigned hyf0 and Copilot Dec 19, 2025
@hyf0 hyf0 requested a review from sapphi-red December 19, 2025 05:10
Copy link
Member

hyf0 commented Dec 19, 2025

Merge activity

Copy link
Contributor

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 adds a retry mechanism to the hmr-full-bundle-mode browser tests to handle flakiness in CI. The main challenge is that tests modify source files (hmr.js, main.js) during execution, so failed tests leave files in an inconsistent state that breaks retries.

  • Added retry configuration (3 retries in CI) to vitest.config.browser.mts
  • Implemented beforeEach hook that resets test files to original state before each test run
  • Added page reload after file reset to ensure browser reflects the clean state

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
packages/test-dev-server/tests/vitest.config.browser.mts Added retry: process.env.CI ? 3 : 0 configuration to enable retries in CI environments
packages/test-dev-server/tests/vitest-setup-playwright.ts Added resetTestFiles() function and beforeEach hook to reset modified test files before each test, ensuring clean state for retries

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@hyf0
Copy link
Member

hyf0 commented Dec 19, 2025

@copilot Take PR's comments into account and fix/resolve them.

Copy link
Contributor Author

Copilot AI commented Dec 19, 2025

@copilot Take PR's comments into account and fix/resolve them.

Addressed all feedback in 86326e0:

  • Using nodePath.join() for cross-platform path construction
  • Collecting and rethrowing errors when file reset fails
  • Added detailed documentation for the 500ms delay constant

@hyf0 hyf0 force-pushed the copilot/add-retry-mechanism-to-tests branch from 86326e0 to 4bd8077 Compare December 19, 2025 09:05
Copy link
Member

hyf0 commented Dec 19, 2025


How to use the Graphite Merge Queue

Add the label graphite: merge to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@hyf0 hyf0 force-pushed the copilot/add-retry-mechanism-to-tests branch from 4bd8077 to f7d2c8a Compare December 19, 2025 09:29
@hyf0 hyf0 requested a review from IWANABETHATGUY December 19, 2025 09:53
…ests (#7588)

- [x] Understand the test mechanism and retry requirements
- [x] Modify `vitest-setup-playwright.ts` to add a `beforeEach` hook that resets files from original playground directory
- [x] Modify `vitest.config.browser.mts` to add retry support (`retry: process.env.CI ? 3 : 0`)
- [x] Run lint and type checks
- [x] Address code review feedback:
  - [x] Use `nodePath.join()` instead of template literals for path construction
  - [x] Rethrow errors when file reset fails instead of just logging
  - [x] Better document the 500ms delay value
- [x] Run code review and security checks

## Summary of Changes

### Problem
The `hmr-full-bundle-mode.spec.ts` tests were flaky and couldn't properly retry when a test failed mid-way. This is because:
1. Tests modify files (`hmr.js`, `main.js`) during execution
2. If a test fails mid-way, files remain in an inconsistent state
3. On retry, the test tries to find and replace wrong content, causing the retry to fail

### Solution
1. **Added retry support** in `vitest.config.browser.mts`:
   - `retry: process.env.CI ? 3 : 0` (3 retries in CI, 0 locally)

2. **Added file reset mechanism** in `vitest-setup-playwright.ts`:
   - Added `beforeEach` hook that runs before each test (including retries)
   - `resetTestFiles()` function copies original files from `playground/hmr-full-bundle-mode` back to `tmp-playground/hmr-full-bundle-mode`
   - After reset, the page is reloaded to reflect the clean file state
   - Uses `nodePath.join()` for cross-platform path construction
   - Properly throws errors when file reset fails to prevent confusing test failures

<!-- START COPILOT CODING AGENT SUFFIX -->

<!-- START COPILOT ORIGINAL PROMPT -->

<details>

<summary>Original prompt</summary>

> Solve #7584
>
> The task is not that easy. You need to make sure the test logic itself supports retry mechanism. Please go through how the test mechanism is implemented first.

</details>

<!-- START COPILOT CODING AGENT TIPS -->
---

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more [Copilot coding agent tips](https://gh.io/copilot-coding-agent-tips) in the docs.
@graphite-app graphite-app bot force-pushed the copilot/add-retry-mechanism-to-tests branch from f7d2c8a to 84f3a52 Compare December 19, 2025 10:57
@graphite-app graphite-app bot merged commit 84f3a52 into main Dec 19, 2025
31 checks passed
@graphite-app graphite-app bot deleted the copilot/add-retry-mechanism-to-tests branch December 19, 2025 11:11
shulaoda added a commit that referenced this pull request Dec 22, 2025
## [1.0.0-beta.56] - 2025-12-22

### 💥 BREAKING CHANGES

- rename `MIXED_EXPORT` error to `MIXED_EXPORTS` (#7565) by @sapphi-red

### 🚀 Features

- rename `id` property to `exporter` in CIRCULAR_REEXPORT error (#7592) by @sapphi-red
- add `ids` property to `CIRCULAR_DEPENDENCY` error (#7591) by @sapphi-red
- node/dev: expose `devMode.lazy` (#7549) by @hyf0
- set log and pos properties for `parseAst` function errors (#7568) by @sapphi-red
- set log and pos properties for logs (#7567) by @sapphi-red
- test-dev-sever: support to manually configure port, run tests in concurrent (#7576) by @hyf0
- add `exporter` property to `MISSING_EXPORT` error (#7564) by @sapphi-red
- add `id` property to `PARSE_ERROR` error (#7563) by @sapphi-red
- support ImporterId hook filter (#7540) by @IWANABETHATGUY

### 🐛 Bug Fixes

- types: better "go to definition" experience for interface `OutputPlugin` (#7610) by @KazariEX
- `postBanner` content should be placed after shebang (#7583) by @btea
- use sanitized filename for preserve modules chunk name (#7603) by @IWANABETHATGUY
- correct filter out unused cjs namespace  (#7602) by @IWANABETHATGUY
- watch: property respect `notify.pollInternal` and `notify.compareContents` (#7595) by @sapphi-red
- make `cleanDir` work with default output directory (#7579) by @shulaoda
- merge `MISSING_NAME_OPTION_FOR_UMD_EXPORT` error to `MISSING_NAME_OPTION_FOR_IIFE_EXPORT` error (#7566) by @sapphi-red
- dev/hmr: ensure cjs modules with no exports reference correct `module` identifier (#7544) by @leegeunhyeok

### 🚜 Refactor

- remove `stable_id` field from `PARSE_ERROR` error (#7593) by @sapphi-red
- make include_runtime_symbol reuseable after linking stage (#7580) by @IWANABETHATGUY
- rust/dev: construct the bundler within itself (#7553) by @hyf0
- rust/watcher: polish API of `Watcher` struct (#7551) by @hyf0
- use `LinkingMetadata::stmt_info_included` to check if a stmt_info is included (#7572) by @IWANABETHATGUY
- use `LinkingMetadata::is_included` to check if a module is included (#7571) by @IWANABETHATGUY
- store module and stmt_info is included info to module meta (#7570) by @IWANABETHATGUY
- make include_* method reunsable after linking stage (#7552) by @IWANABETHATGUY
- rust/watcher: construct the bundler within watcher itself (#7550) by @hyf0
- extract make include_runtime_symbol reusable (#7546) by @IWANABETHATGUY

### ⚙️ Miscellaneous Tasks

- renovate: add `kill-port` in `ignoreDeps` in renovate.json (#7619) by @sapphi-red
- deps: update rust crates (#7617) by @renovate[bot]
- deps: update npm packages (#7616) by @renovate[bot]
- deps: update github-actions (#7615) by @renovate[bot]
- ci: skip benchmark workflows on draft PRs (#7611) by @Copilot
- deps: update dependency rolldown-plugin-dts to ^0.19.0 (#7607) by @renovate[bot]
- deps: update dependency oxlint-tsgolint to v0.10.0 (#7601) by @renovate[bot]
- deps: update dependency rolldown-plugin-dts to v0.18.4 (#7599) by @renovate[bot]
- deps: update notify (#7594) by @sapphi-red
- test-dev-server: add retry mechanism to hmr-full-bundle-mode tests (#7588) by @Copilot
- deps: update napi to v3.7.1 (#7590) by @renovate[bot]
- add JSDoc documentation for memfs type (#7587) by @Copilot
- deps: update dependency oxlint to v1.34.0 (#7589) by @renovate[bot]
- move some tests in ignored-by-unsupported-features that are passing (#7569) by @sapphi-red
- deps: update dependency oxlint-tsgolint to v0.9.2 (#7582) by @renovate[bot]
- deps: update oxc resolver to v11.16.0 (#7574) by @renovate[bot]
- test/dev-server: don't run `pnpm install` during tests (#7560) by @hyf0
- test/dev-server: use `kill-port@1` to improve performance (#7575) by @hyf0
- normalize error object to make some Rollup tests pass (#7562) by @sapphi-red
- ci: separate dev-server(hmr) tests and normal tests (#7558) by @hyf0
- ci: make native rolldown build reusable (#7557) by @hyf0
- resolve some TODOs (#7561) by @sapphi-red

### ❤️ New Contributors

* @KazariEX made their first contribution in [#7610](#7610)
* @leegeunhyeok made their first contribution in [#7544](#7544)

Co-authored-by: shulaoda <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants