test: normalize Windows plugin path assertions#48557
test: normalize Windows plugin path assertions#48557danielwanwx wants to merge 1 commit intoopenclaw:mainfrom
Conversation
Greptile SummaryThis 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 Key changes:
Minor note: Confidence Score: 5/5
Prompt To Fix All With AIThis 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 |
| function normalizeAssertionPath(value: string | undefined): string | undefined { | ||
| if (!value) { | ||
| return value; | ||
| } | ||
| return value.replace(/\\/g, "/").toLowerCase(); | ||
| } |
There was a problem hiding this 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:
// 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.|
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. |
Summary
Normalize Windows-sensitive path assertions in plugin-related tests.
Problem
Several Windows CI failures are caused by exact path string assertions that compare:
runneradminRUNNER~1Those 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.tssrc/hooks/plugin-hooks.test.tssrc/plugins/marketplace.test.tsInstead of asserting exact full path strings, the tests now assert:
Why this is low risk
Verification