Skip to content

test: skip chmod-based permission tests when running as root#2171

Merged
affaan-m merged 1 commit into
affaan-m:mainfrom
Spartallan:test/skip-chmod-tests-as-root
Jun 7, 2026
Merged

test: skip chmod-based permission tests when running as root#2171
affaan-m merged 1 commit into
affaan-m:mainfrom
Spartallan:test/skip-chmod-tests-as-root

Conversation

@konstapukarifastnetfi

@konstapukarifastnetfi konstapukarifastnetfi commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

What Changed

Two tests provoke EACCES via chmod and already skip on win32, but root ignores file modes, so both fail when the suite runs as root (e.g. in a default Docker container):

  • tests/lib/session-aliases.test.js: "saveAliases triggers inner restoreErr catch when both save and restore fail"
  • tests/lib/session-manager.test.js: "appendSessionContent returns false when file is read-only (EACCES)"

Every other chmod-based test in the repo already guards with process.getuid?.() === 0; these two were the only ones missing the guard. This applies the same skip condition and message.

Why This Change

node tests/run-all.js should be green in any environment. As root the chmod calls succeed but do not restrict anything, so the code under test never sees EACCES and the assertions fail - an environment artifact, not a product bug.

Testing Done

  • Manual testing completed
  • Automated tests pass locally (node tests/run-all.js) - 2619/2619 verified BOTH as a non-root user (tests execute, pass) and as root (tests skip, suite green) in clean node:22-bookworm containers
  • Edge cases considered and tested - process.getuid?.() is undefined-safe on Windows where the API does not exist

Type of Change

  • test: Tests

Security & Quality Checklist

  • No secrets or API keys committed (ghp_, sk-, AKIA, xoxb, xoxp patterns checked)
  • JSON files validate cleanly
  • Shell scripts pass shellcheck (if applicable)
  • Pre-commit hooks pass locally (if configured)
  • No sensitive data exposed in logs or output
  • Follows conventional commits format

Documentation

  • Updated relevant documentation - n/a
  • Added comments for complex logic - skip reason stated in the skip message
  • README updated (if needed) - n/a

Summary by cubic

Skip two chmod-based permission tests when running as root (in addition to Windows) to avoid false failures. Aligns with existing process.getuid?.() === 0 guards and keeps node tests/run-all.js green in Docker/root environments.

  • Bug Fixes
    • tests/lib/session-aliases.test.js: Skip on Windows/root; chmod cannot trigger EACCES in the save/restore double-fault case.
    • tests/lib/session-manager.test.js: Skip on Windows/root for the read-only file (EACCES) check.

Written for commit ffc2920. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • Tests
    • Updated test skip conditions across multiple test files to account for root user execution contexts in addition to Windows platform checks. These changes ensure tests reliably bypass execution in environments where system permissions and filesystem behaviors may vary, improving overall test consistency and preventing unexpected failures.

Two tests provoke EACCES via chmod (saveAliases backup double failure,
appendSessionContent on a read-only file) and already skip on win32, but
root ignores file modes so both fail when the suite runs as root (for
example in a default Docker container). Every other chmod-based test in
the repo already guards with process.getuid?.() === 0; these two were the
only ones missing the guard. Apply the same skip condition and message.
@coderabbitai

coderabbitai Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Ready to act? Review this PR in Change Stack to turn feedback into patch suggestions you can inspect and refine.

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: fd2264b0-f223-4fad-9250-fa7be9309508

📥 Commits

Reviewing files that changed from the base of the PR and between 7113b5b and ffc2920.

📒 Files selected for processing (2)
  • tests/lib/session-aliases.test.js
  • tests/lib/session-manager.test.js

📝 Walkthrough

Walkthrough

Two permission-sensitive test cases in the session management test suite now skip execution when running as root, in addition to the existing Windows platform skip. The skip conditions and associated messages are updated to reflect the broader guard for filesystem permission behaviors that do not behave consistently under root privilege.

Changes

Root User Test Skip Conditions

Layer / File(s) Summary
Permission-sensitive test skip conditions
tests/lib/session-aliases.test.js, tests/lib/session-manager.test.js
The Round 90 saveAliases backup/restore test and Round 112 appendSessionContent read-only file test both expand their skip conditions from Windows-only to Windows-or-root, and update their skip messages accordingly.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

A rabbit hopped through test suites bright,
Adding root checks to set things right,
No Windows walls nor root-user gates,
Can hide from skips that come of late! 🐰✨

🚥 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 directly and accurately summarizes the main change: adding skip guards to chmod-based permission tests when running as root.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration.


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 and usage tips.

@cubic-dev-ai cubic-dev-ai Bot left a comment

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.

No issues found across 2 files

Re-trigger cubic

@affaan-m affaan-m merged commit 6614f79 into affaan-m:main Jun 7, 2026
3 checks passed
syarfandi pushed a commit to syarfandi/ECC that referenced this pull request Jun 9, 2026
…m#2171)

Two tests provoke EACCES via chmod (saveAliases backup double failure,
appendSessionContent on a read-only file) and already skip on win32, but
root ignores file modes so both fail when the suite runs as root (for
example in a default Docker container). Every other chmod-based test in
the repo already guards with process.getuid?.() === 0; these two were the
only ones missing the guard. Apply the same skip condition and message.
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