Skip to content

test: normalize Windows plugin path assertions#48557

Closed
danielwanwx wants to merge 1 commit intoopenclaw:mainfrom
danielwanwx:fix/windows-path-assertions
Closed

test: normalize Windows plugin path assertions#48557
danielwanwx wants to merge 1 commit intoopenclaw:mainfrom
danielwanwx:fix/windows-path-assertions

Conversation

@danielwanwx
Copy link
Copy Markdown
Contributor

Summary

Normalize Windows-sensitive path assertions in plugin-related tests.

Problem

Several Windows CI failures are caused by exact path string assertions that compare:

  • runneradmin
  • RUNNER~1

Those are equivalent filesystem locations on the runner, but the tests currently treat them as different strings.

Change

This patch narrows the fix to tests only:

  • src/plugins/bundle-mcp.test.ts
  • src/hooks/plugin-hooks.test.ts
  • src/plugins/marketplace.test.ts

Instead of asserting exact full path strings, the tests now assert:

  • the path is absolute when needed
  • the normalized path contains the expected stable suffix
  • comparisons use slash-normalized lowercase forms where appropriate

Why this is low risk

  • test-only change
  • no production behavior changes
  • only relaxes brittle runner-path assumptions

Verification

npx [email protected] exec vitest run src/plugins/bundle-mcp.test.ts
npx [email protected] exec vitest run src/hooks/plugin-hooks.test.ts
npx [email protected] exec vitest run src/plugins/marketplace.test.ts

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 16, 2026

Greptile Summary

This PR narrows three test files to use platform-independent path assertions, fixing Windows CI failures caused by exact path string comparisons that broke when the Windows runner resolved the same filesystem location via different representations (8.3 short names like RUNNER~1 vs long names like runneradmin, or backslash vs forward-slash separators).

Key changes:

  • src/plugins/bundle-mcp.test.ts: Removes the fs.realpath() round-trip that compared the fully-resolved server path, replacing it with isAbsolute + normalised-suffix toContain checks. This is the most impactful fix because realpath was the specific call that could return a different name form than the production path.
  • src/hooks/plugin-hooks.test.ts: Drops fs.realpathSync.native comparison in favour of isDefined + isAbsolute + normalised-suffix containment. Also removes the now-unused synchronous fs import.
  • src/plugins/marketplace.test.ts: Splits the monolithic toEqual into individual property assertions; uses toContain on a normalised sourceLabel, and moves marketplaceSource out of toMatchObject so slash-normalization can be applied before comparison.

Minor note: normalizeAssertionPath is now defined identically in all three files. Extracting it into src/test-utils/ would reduce duplication.

Confidence Score: 5/5

  • Test-only change with no production behavior modifications; safe to merge.
  • All three modified files are test files. The changes relax brittle exact-path assertions into layered checks (defined, absolute, normalised-suffix containment) that are both correct and cross-platform. The normalizeAssertionPath helper has been reviewed and is logically sound. Production code is untouched. The only observation is cosmetic duplication of the helper across files.
  • No files require special attention.
Prompt To Fix All With AI
This is a comment left during a code review.
Path: src/hooks/plugin-hooks.test.ts
Line: 97-102

Comment:
**Duplicated helper across three test files**

`normalizeAssertionPath` is now defined independently in `src/hooks/plugin-hooks.test.ts`, `src/plugins/bundle-mcp.test.ts`, and `src/plugins/marketplace.test.ts` (and a previous version of the same pattern already existed in `src/plugins/discovery.test.ts` according to the search results). The project already has a `src/test-utils/` directory with shared helpers (e.g. `env.ts`, `temp-dir.ts`). Extracting this function into a shared module would prevent future divergence if the normalisation logic needs to change:

```ts
// src/test-utils/path-assertions.ts
export function normalizeAssertionPath(value: string | undefined): string | undefined {
  if (!value) return value;
  return value.replace(/\\/g, "/").toLowerCase();
}
```

Then each test file imports it instead of re-declaring it.

How can I resolve this? If you propose a fix, please make it concise.

Last reviewed commit: e5dbba1

Comment on lines +97 to +102
function normalizeAssertionPath(value: string | undefined): string | undefined {
if (!value) {
return value;
}
return value.replace(/\\/g, "/").toLowerCase();
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Duplicated helper across three test files

normalizeAssertionPath is now defined independently in src/hooks/plugin-hooks.test.ts, src/plugins/bundle-mcp.test.ts, and src/plugins/marketplace.test.ts (and a previous version of the same pattern already existed in src/plugins/discovery.test.ts according to the search results). The project already has a src/test-utils/ directory with shared helpers (e.g. env.ts, temp-dir.ts). Extracting this function into a shared module would prevent future divergence if the normalisation logic needs to change:

// src/test-utils/path-assertions.ts
export function normalizeAssertionPath(value: string | undefined): string | undefined {
  if (!value) return value;
  return value.replace(/\\/g, "/").toLowerCase();
}

Then each test file imports it instead of re-declaring it.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/hooks/plugin-hooks.test.ts
Line: 97-102

Comment:
**Duplicated helper across three test files**

`normalizeAssertionPath` is now defined independently in `src/hooks/plugin-hooks.test.ts`, `src/plugins/bundle-mcp.test.ts`, and `src/plugins/marketplace.test.ts` (and a previous version of the same pattern already existed in `src/plugins/discovery.test.ts` according to the search results). The project already has a `src/test-utils/` directory with shared helpers (e.g. `env.ts`, `temp-dir.ts`). Extracting this function into a shared module would prevent future divergence if the normalisation logic needs to change:

```ts
// src/test-utils/path-assertions.ts
export function normalizeAssertionPath(value: string | undefined): string | undefined {
  if (!value) return value;
  return value.replace(/\\/g, "/").toLowerCase();
}
```

Then each test file imports it instead of re-declaring it.

How can I resolve this? If you propose a fix, please make it concise.

@vincentkoc vincentkoc added the r: no-ci-pr Auto-response for CI/test-failure PRs label Mar 20, 2026
@openclaw-barnacle
Copy link
Copy Markdown

Please don't make PRs for test failures on main.

The team is aware of those and will handle them directly on the codebase, not only fixing the tests but also investigating what the root cause is. Having to sift through test-fix-PRs (including some that have been out of date for weeks...) on top of that doesn't help. There are already way too many PRs for humans to manage; please don't make the flood worse.

Thank you.

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

Labels

r: no-ci-pr Auto-response for CI/test-failure PRs size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants