Skip to content

test: skip chmod-dependent backup rotation tests on Windows#32286

Merged
steipete merged 2 commits intomainfrom
fix/windows-backup-rotation-skip
Mar 2, 2026
Merged

test: skip chmod-dependent backup rotation tests on Windows#32286
steipete merged 2 commits intomainfrom
fix/windows-backup-rotation-skip

Conversation

@jalehman
Copy link
Contributor

@jalehman jalehman commented Mar 2, 2026

chmod is a no-op on Windows — file permissions always report 0o666 regardless of what was set, so asserting 0o600 will never pass.

Adds IS_WINDOWS guard with it.skipIf on the two permission-asserting tests (hardenBackupPermissions and maintainConfigBackups), matching the pattern used for other platform-specific test skips.

All 4 tests still pass on macOS/Linux; the 2 chmod tests skip on Windows.

@openclaw-barnacle openclaw-barnacle bot added size: S maintainer Maintainer-authored PR labels Mar 2, 2026
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bb2ff87f66

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +121 to +122
it.skipIf(IS_WINDOWS)(
"maintainConfigBackups composes rotate/copy/harden/prune flow",

Choose a reason for hiding this comment

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

P2 Badge Keep Windows coverage for maintainConfigBackups flow

Skipping the entire maintainConfigBackups composes rotate/copy/harden/prune flow test on Windows removes validation of rotate/copy/orphan-prune behavior on that platform, even though only the mode check is chmod-dependent. This means a Windows-only regression in the backup maintenance sequence could now pass CI unnoticed; the skip should be narrowed to just the permission assertion instead of the whole test.

Useful? React with 👍 / 👎.

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 2, 2026

Greptile Summary

This PR correctly guards two file-permission-asserting tests with it.skipIf(IS_WINDOWS) to prevent false failures on Windows, where chmod is a no-op and file modes always report 0o666.

  • The hardenBackupPermissions skip is well-scoped: the test body exclusively checks 0o600 mode values, so the entire test is legitimately Windows-incompatible.
  • The maintainConfigBackups skip is slightly over-broad. Three of its four assertions (file content, backup rotation into ring slot .bak.1, and orphan pruning) are purely filesystem-content checks that work on Windows. Only the mode & 0o777 === 0o600 assertion is Windows-incompatible. As written, the entire compose flow is untested on Windows.
  • Note: the PR description states this matches "the pattern used for other platform-specific test skips," but the existing tests in the repo (src/secrets/resolve.test.ts, etc.) use inline if (process.platform === "win32") guards rather than it.skipIf. The it.skipIf approach is valid Vitest API and arguably cleaner, but it is a new pattern in the codebase.

Confidence Score: 5/5

  • This PR is safe to merge — it only adjusts test skip conditions with no changes to production code.
  • The change is isolated to a test file, is logically correct (chmod truly is a no-op on Windows), and does not affect any production behaviour. The only concern is that the maintainConfigBackups test skips more than strictly necessary on Windows, reducing Windows test coverage for the compose flow — but this is a minor stylistic issue, not a correctness problem.
  • No files require special attention.

Last reviewed commit: bb2ff87

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

1 file reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Comment on lines +121 to +149
it.skipIf(IS_WINDOWS)(
"maintainConfigBackups composes rotate/copy/harden/prune flow",
async () => {
await withTempHome(async () => {
const stateDir = process.env.OPENCLAW_STATE_DIR?.trim();
if (!stateDir) {
throw new Error("Expected OPENCLAW_STATE_DIR to be set by withTempHome");
}
const configPath = path.join(stateDir, "openclaw.json");
await fs.writeFile(configPath, JSON.stringify({ token: "secret" }), { mode: 0o600 });
await fs.writeFile(`${configPath}.bak`, "previous", { mode: 0o644 });
await fs.writeFile(`${configPath}.bak.orphan`, "old");

await maintainConfigBackups(configPath, fs);

// A new primary backup is created from the current config.
await expect(fs.readFile(`${configPath}.bak`, "utf-8")).resolves.toBe(
JSON.stringify({ token: "secret" }),
);
// Prior primary backup gets rotated into ring slot 1.
await expect(fs.readFile(`${configPath}.bak.1`, "utf-8")).resolves.toBe("previous");
// Mode hardening still applies.
const primaryBackupStat = await fs.stat(`${configPath}.bak`);
expect(primaryBackupStat.mode & 0o777).toBe(0o600);
// Out-of-ring orphan gets pruned.
await expect(fs.stat(`${configPath}.bak.orphan`)).rejects.toThrow();
});
},
);
Copy link
Contributor

Choose a reason for hiding this comment

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

Entire test skipped on Windows, including non-permission assertions

The maintainConfigBackups test is skipped wholesale on Windows, but only the final permission assertion (mode & 0o777 === 0o600) is Windows-incompatible. The other three assertions — file content, rotation into ring slot 1, and orphan pruning — are all filesystem-content checks that work fine on Windows.

Skipping the full test means the compose flow (rotate → copy → harden → prune) gets zero coverage on Windows. Consider splitting the test into a platform-agnostic block for the content/rotation/pruning checks and a platform-guarded block for the permission check, or pulling the permission assertion into its own it.skipIf(IS_WINDOWS) test alongside the existing hardenBackupPermissions test.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/config/config.backup-rotation.test.ts
Line: 121-149

Comment:
**Entire test skipped on Windows, including non-permission assertions**

The `maintainConfigBackups` test is skipped wholesale on Windows, but only the final permission assertion (`mode & 0o777 === 0o600`) is Windows-incompatible. The other three assertions — file content, rotation into ring slot 1, and orphan pruning — are all filesystem-content checks that work fine on Windows.

Skipping the full test means the compose flow (`rotate → copy → harden → prune`) gets zero coverage on Windows. Consider splitting the test into a platform-agnostic block for the content/rotation/pruning checks and a platform-guarded block for the permission check, or pulling the permission assertion into its own `it.skipIf(IS_WINDOWS)` test alongside the existing `hardenBackupPermissions` test.

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

@jalehman jalehman force-pushed the fix/windows-backup-rotation-skip branch from bb2ff87 to d1aafcb Compare March 2, 2026 23:32
jalehman and others added 2 commits March 2, 2026 23:37
chmod is a no-op on Windows — file permissions always report 0o666
regardless of what was set, so asserting 0o600 will never pass.
@steipete steipete force-pushed the fix/windows-backup-rotation-skip branch from d1aafcb to 54810b2 Compare March 2, 2026 23:38
@steipete steipete merged commit abec8a4 into main Mar 2, 2026
1 check passed
@steipete steipete deleted the fix/windows-backup-rotation-skip branch March 2, 2026 23:38
@steipete
Copy link
Contributor

steipete commented Mar 2, 2026

Landed via temp rebase onto main.

  • Gate: pnpm -s vitest run src/config/config.backup-rotation.test.ts && pnpm -s tsgo
  • Land commit: 54810b2
  • Merge commit: abec8a4

Thanks @jalehman!

Copy link

@mizoz mizoz left a comment

Choose a reason for hiding this comment

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

LGTM ✅ - This is the correct fix. chmod is a no-op on Windows, so skipping these permission-asserting tests is the right approach. The IS_WINDOWS guard matches the pattern used elsewhere in the codebase.

dawi369 pushed a commit to dawi369/davis that referenced this pull request Mar 3, 2026
OWALabuy pushed a commit to kcinzgg/openclaw that referenced this pull request Mar 4, 2026
zooqueen pushed a commit to hanzoai/bot that referenced this pull request Mar 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants