Skip to content

Recovered: fix(test): restore full test suite on Windows (#4 by @SahilRakhaiya05)#243

Open
jangjos-128 wants to merge 3 commits into
TestSprite:mainfrom
SahilRakhaiya05:fix/windows-cross-platform-tests
Open

Recovered: fix(test): restore full test suite on Windows (#4 by @SahilRakhaiya05)#243
jangjos-128 wants to merge 3 commits into
TestSprite:mainfrom
SahilRakhaiya05:fix/windows-cross-platform-tests

Conversation

@jangjos-128

@jangjos-128 jangjos-128 commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Fixes 10 Windows-only test failures so the Vitest suite runs cleanly on Windows dev machines. Linux/macOS CI behavior is unchanged.

Windows result:

  • 1416 passing
  • 3 skipped intentionally on Windows only

What changed

  • Fixed resolveBundleDir to strip both / and \ trailing separators while preserving roots like C:\ and /.
  • Updated subprocess tests to set both HOME and USERPROFILE so credentials stay inside the test temp directory on Windows.
  • Replaced Unix-only rm usage with unlinkSync().
  • Added test/helpers/execNpm.ts so npm subprocess calls work on Windows .cmd shims.
  • Fixed CRLF handling in frontmatter parsing by stripping trailing \r.
  • Added .gitattributes to normalize line endings to LF.
  • Skipped symlink tests only when the OS cannot create symlinks.
  • Skipped Unix 0600 chmod assertions on Windows because NTFS does not enforce POSIX file modes.
  • Replaced Unix-only path assertions with path.resolve(), path.join(), and homedir() based checks.

Test Plan

  • npm test — 1416 passed, 3 skipped on Windows only
  • npm run typecheck
  • npm run lint
  • Subprocess suite — 49/49 passed
  • Help snapshot suite — passed

Skipped on Windows by design:

  • 2 symlink tests requiring Developer Mode/elevation
  • 1 chmod 0600 test due to NTFS behavior

Summary by CodeRabbit

  • Bug Fixes

    • Improved output directory handling for paths with trailing slashes or backslashes, including Windows drive roots.
    • Improved cross-platform CLI behavior for home directories, credential files, and npm commands.
    • Credential and file-permission checks now account for platform-specific behavior.
  • Tests

    • Expanded platform-aware coverage for symlinks, paths, permissions, frontmatter, and CLI workflows.
    • Standardized text files to use automatic line-ending handling with LF output.

Solving Issue #108

- Strip both slash and backslash trailing separators in resolveBundleDir

- Add cross-platform npm helper for subprocess/snapshot builds

- Set USERPROFILE alongside HOME in subprocess tests

- Replace Unix-only rm with unlinkSync for credential cleanup

- Skip symlink and chmod assertions when platform cannot honor them

- Normalize CRLF in frontmatter description parsing

- Enforce LF line endings via .gitattributes
Rebased onto v0.2.0 main introduced skill-nudge tests that assumed
Unix-style path prefixes. Use path.join/resolve and TARGETS landing
paths so probes match on Windows.
@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

Changes

Cross-platform compatibility

Layer / File(s) Summary
Path and line-ending handling
.gitattributes, src/lib/bundle.*, src/lib/agent-targets.test.ts, src/lib/skill-nudge.test.ts
Normalizes line endings, handles trailing path separators, and updates path assertions for platform-specific resolution.
Cross-platform npm test execution
test/helpers/execNpm.ts, test/cli.subprocess.test.ts, test/help.snapshot.test.ts
Adds Windows-compatible npm execution and updates test environment isolation and cleanup.
Platform-specific test gates
src/commands/agent.test.ts, src/lib/credentials.test.ts, test/cli.subprocess.test.ts
Skips unsupported symlink and permission assertions and uses platform-correct credential paths.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related issues

  • TestSprite/testsprite-cli issue 108: Covers the Windows compatibility fixes addressed by this PR, including paths, symlinks, permissions, line endings, and npm subprocess execution.

Possibly related PRs

Suggested reviewers: ruili-testsprite, zeshi-du

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title matches the main change: restoring the test suite on Windows.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/lib/skill-nudge.test.ts`:
- Line 89: Replace the prefix-only containment checks in both assertions of the
skill-nudge tests with boundary-safe path.relative checks: resolve each observed
path against the resolved root, and accept it only when the relative result is
neither absolute nor equal to or nested under .. . Preserve the existing
every-based assertions and test intent.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 3d31c606-a737-4562-b2bf-d8bec80a7295

📥 Commits

Reviewing files that changed from the base of the PR and between 60d55e4 and ef279db.

📒 Files selected for processing (10)
  • .gitattributes
  • src/commands/agent.test.ts
  • src/lib/agent-targets.test.ts
  • src/lib/bundle.test.ts
  • src/lib/bundle.ts
  • src/lib/credentials.test.ts
  • src/lib/skill-nudge.test.ts
  • test/cli.subprocess.test.ts
  • test/help.snapshot.test.ts
  • test/helpers/execNpm.ts

});
expect(seen.every(p => p.startsWith('/some/proj'))).toBe(true);
const resolvedRoot = path.resolve(root);
expect(seen.every(p => path.resolve(p).startsWith(resolvedRoot))).toBe(true);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Use a boundary-safe path containment check.

startsWith(resolvedRoot) also accepts sibling paths such as /work/proj2 for /work/proj, so these tests may miss an escaped probe. Use path.relative and reject .. and absolute results in both assertions.

As per path instructions, the src/** review must focus on correctness; these prefix-only path assertions are not containment-safe.

Suggested fix
+const isWithin = (root: string, candidate: string): boolean => {
+  const relative = path.relative(root, path.resolve(candidate));
+  return (
+    relative === '' ||
+    (!path.isAbsolute(relative) &&
+      relative !== '..' &&
+      !relative.startsWith(`..${path.sep}`))
+  );
+};
+
-expect(seen.every(p => path.resolve(p).startsWith(resolvedRoot))).toBe(true);
+expect(seen.every(p => isWithin(resolvedRoot, p))).toBe(true);
 
-expect(probed.every(p => path.resolve(p).startsWith(resolvedCwd))).toBe(true);
+expect(probed.every(p => isWithin(resolvedCwd, p))).toBe(true);

Also applies to: 216-216

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/lib/skill-nudge.test.ts` at line 89, Replace the prefix-only containment
checks in both assertions of the skill-nudge tests with boundary-safe
path.relative checks: resolve each observed path against the resolved root, and
accept it only when the relative result is neither absolute nor equal to or
nested under .. . Preserve the existing every-based assertions and test intent.

Source: Path instructions

@jangjos-128

Copy link
Copy Markdown
Contributor Author

Hi @SahilRakhaiya05 👋 — this is the recovery of your PR #4, which was auto-closed by an error in our 2026-07-09 release process. Your commits are intact — thank you for the contribution!

It currently shows merge conflicts because main has moved on since your branch was cut. To clear them, update your PR branch (BRANCH) against the latest main — either option works and both update this PR in place:

Option A — merge (no force-push):

git checkout BRANCH
git fetch upstream          # your remote for TestSprite/testsprite-cli (may be "origin")
git merge upstream/main     # resolve conflicts, commit
git push

Option B — rebase (cleaner history, needs force):

git checkout BRANCH
git fetch upstream
git rebase upstream/main    # resolve conflicts
git push --force-with-lease

Once you push, the conflicts here resolve automatically and we'll take it into review.

Sorry again for the extra step!

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.

2 participants