Skip to content

test: skip permission tests when running as root#1186

Merged
lazysegtree merged 1 commit into
mainfrom
root-test-fix
Dec 11, 2025
Merged

test: skip permission tests when running as root#1186
lazysegtree merged 1 commit into
mainfrom
root-test-fix

Conversation

@lazysegtree

@lazysegtree lazysegtree commented Dec 11, 2025

Copy link
Copy Markdown
Collaborator

Description

This PR fixes test failures that occur when running tests in containerized environments where tests run as root.

Problem

The permission-based tests in bool_file_store_test.go fail when running as root because:

  • Root bypasses Unix file permissions
  • Root can read files with 000 permissions
  • Root can write to read-only directories

Solution

Added checks to skip these specific permission tests when os.Geteuid() == 0 (running as root). This allows the test suite to pass in containerized environments while still maintaining test coverage in normal user environments.

Changes

  • Skip TestReadBoolFilePermissionDenied when running as root
  • Skip TestWriteBoolFilePermissionDenied when running as root

Testing

  • ✅ All tests pass when running as root
  • ✅ Tests still execute normally when not running as root
  • ✅ No linter issues

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature
  • Breaking change
  • Documentation update

Summary by CodeRabbit

  • Tests
    • Improved test reliability by adding runtime guards to skip permission-related tests in root execution environments. Tests will no longer fail unexpectedly when run with elevated privileges.

✏️ Tip: You can customize this high-level summary in your review settings.

These tests fail in containerized environments where tests run as root.
Root bypasses Unix file permissions, so we skip these tests when os.Geteuid() == 0.
@coderabbitai

coderabbitai Bot commented Dec 11, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

Two permission-related tests in the bool file store test suite now include runtime guards to skip execution when the process runs as root. The guards check the effective user ID and conditionally skip tests that would be unreliable under root privileges.

Changes

Cohort / File(s) Change Summary
Permission test guards
src/internal/utils/bool_file_store_test.go
Added os.Geteuid() == 0 checks to skip TestReadBoolFilePermissionDenied and TestWriteBoolFilePermissionDenied when running as root, preventing false test failures due to root bypassing permission restrictions

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

  • Straightforward test-only changes with a repetitive pattern (identical guard logic applied twice)
  • Low risk; guards are standard practice for permission tests in Unix-like environments
  • Single file affected with no logic changes to production code

Poem

🐰 Root cannot be bound by permission's chain,
So skip these tests, let fairness reign!
Two guards now shield the checks with care,
Where privilege floats through the air. 🔐

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title clearly and concisely summarizes the main change: adding runtime guards to skip permission tests when running as root.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch root-test-fix

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7906e5a and 6f555ab.

📒 Files selected for processing (1)
  • src/internal/utils/bool_file_store_test.go (2 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: lazysegtree
Repo: yorukot/superfile PR: 1021
File: .gitignore:37-37
Timestamp: 2025-08-27T11:32:17.326Z
Learning: In PR #1021 for yorukot/superfile, the tests were actually passing despite lazysegtree reporting crashes. The real issue was that production image preview crashes occurred during actual application usage due to duplicate ImagePreviewer instances (one in defaultModelConfig and one in preview.New()), while the test environment didn't stress the image preview system enough to expose the conflicts.
Learnt from: lazysegtree
Repo: yorukot/superfile PR: 924
File: src/internal/model_test.go:147-168
Timestamp: 2025-08-09T02:52:22.516Z
Learning: In superfile tests, lazysegtree prefers tests that accurately mimic the actual production behavior, including file operations like creating and deleting the LastDir file, rather than isolating such operations to temporary locations when the real behavior involves modifying/deleting those specific files.
Learnt from: lazysegtree
Repo: yorukot/superfile PR: 963
File: src/internal/default_config.go:16-16
Timestamp: 2025-07-27T07:40:51.938Z
Learning: lazysegtree prefers simpler implementation approaches when the alternatives are significantly more complex, even if the alternatives might be architecturally cleaner, prioritizing maintainability and avoiding over-engineering.
Learnt from: lazysegtree
Repo: yorukot/superfile PR: 963
File: src/internal/default_config.go:16-16
Timestamp: 2025-07-27T07:40:51.938Z
Learning: lazysegtree prefers simpler implementation approaches when the alternatives are significantly more complex, even if the alternatives might be architecturally cleaner, prioritizing maintainability and avoiding over-engineering.
Learnt from: lazysegtree
Repo: yorukot/superfile PR: 969
File: src/internal/key_function.go:40-40
Timestamp: 2025-08-03T09:34:55.721Z
Learning: lazysegtree emphasizes proper dependency direction in software architecture, preferring that low-level components (like modal handlers) should not depend on high-level components (like the main model object). He also prioritizes performance considerations, noting that creating objects on every keypress in hot code paths like key handling is inefficient and should be avoided.
Learnt from: lazysegtree
Repo: yorukot/superfile PR: 1013
File: src/internal/model_render.go:329-341
Timestamp: 2025-08-29T14:11:21.380Z
Learning: lazysegtree prefers to defer help menu rendering optimizations and other technical debt improvements to separate GitHub issues when the current PR scope has grown too large, maintaining focus on the primary refactoring objectives while tracking performance improvements for future work.
Learnt from: lazysegtree
Repo: yorukot/superfile PR: 985
File: src/internal/model.go:0-0
Timestamp: 2025-08-11T01:49:30.040Z
Learning: lazysegtree prefers maintaining code correctness through proper design and invariants rather than adding defensive bounds checks at every slice access point, viewing such defensive programming as "duct taping" that can mask actual bugs instead of fixing them at their source.
Learnt from: lazysegtree
Repo: yorukot/superfile PR: 973
File: src/internal/ui/processbar/model_update.go:7-27
Timestamp: 2025-08-03T14:49:31.221Z
Learning: lazysegtree prefers to keep test-only code simple without adding production-level concerns like goroutine synchronization, cancellation contexts, or complex lifecycle management, even when such patterns might prevent potential issues, since the complexity isn't justified for test utilities.
Learnt from: lazysegtree
Repo: yorukot/superfile PR: 1044
File: src/internal/utils/file_utils.go:149-149
Timestamp: 2025-09-09T13:29:11.771Z
Learning: lazysegtree prefers to keep PR scope focused on the primary objectives and considers pre-existing technical debt issues as out of scope for migration/refactoring PRs, preferring to defer such issues to separate GitHub issues rather than expanding the current PR scope.
Learnt from: lazysegtree
Repo: yorukot/superfile PR: 950
File: src/internal/ui/metadata/README.md:7-7
Timestamp: 2025-07-24T03:46:29.516Z
Learning: lazysegtree prefers to defer comprehensive unit testing to separate PRs when the current PR has grown too large, maintaining focus on the primary refactoring objectives while tracking testing requirements in dedicated GitHub issues.
Learnt from: lazysegtree
Repo: yorukot/superfile PR: 967
File: src/internal/key_function.go:45-47
Timestamp: 2025-08-02T11:47:07.713Z
Learning: lazysegtree prefers to track technical debt and architectural improvements in dedicated GitHub issues when they are identified during PR reviews but are beyond the scope of the current PR, particularly for complex refactoring needs like input handling architecture that would require significant changes.
Learnt from: lazysegtree
Repo: yorukot/superfile PR: 963
File: src/internal/handle_file_operations.go:567-570
Timestamp: 2025-07-27T08:49:09.687Z
Learning: lazysegtree prefers to defer technical debt issues like model mutation concerns to later PRs when the current PR has already grown too large, maintaining focus on the primary objectives while acknowledging the need to track such issues for future work.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Build and Test (windows-latest)
  • GitHub Check: Cloudflare Pages
🔇 Additional comments (2)
src/internal/utils/bool_file_store_test.go (2)

162-165: LGTM! Root check correctly placed.

The root user detection and skip logic is correct. Root bypasses Unix file permissions, making this test unreliable in containerized environments. The check is properly placed after the Windows skip and before the test logic.


193-196: LGTM! Consistent root check for write permissions.

The root user detection follows the same correct pattern as the read permission test. The implementation is consistent and properly prevents unreliable test execution when root can bypass directory write restrictions.


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.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying superfile with  Cloudflare Pages  Cloudflare Pages

Latest commit: 6f555ab
Status: ✅  Deploy successful!
Preview URL: https://f38b3915.superfile.pages.dev
Branch Preview URL: https://root-test-fix.superfile.pages.dev

View logs

@lazysegtree lazysegtree requested a review from yorukot December 11, 2025 13:31
@lazysegtree lazysegtree merged commit f83e2da into main Dec 11, 2025
16 checks passed
@lazysegtree lazysegtree deleted the root-test-fix branch January 1, 2026 18:22
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Jan 17, 2026
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [yorukot/superfile](https://github.com/yorukot/superfile) | minor | `v1.4.0` → `v1.5.0` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>yorukot/superfile (yorukot/superfile)</summary>

### [`v1.5.0`](https://github.com/yorukot/superfile/releases/tag/v1.5.0)

[Compare Source](yorukot/superfile@v1.4.0...v1.5.0)

This release brings major new features, including video and PDF preview support, multi-column file panels, and configurable navigation, alongside significant code refactoring and comprehensive bug fixes.

#### Install:

[**Click me to know how to install**](https://github.com/yorukot/superfile?tab=readme-ov-file#installation)

#### Highlights

- Added video and PDF preview support via loading the first frame/page as an image. Thanks [@&#8203;Yassen-Higazi](https://github.com/Yassen-Higazi) for the implementation

<details><summary>Screenshots</summary>
<p>

<img width="951" height="596" alt="image" src="https://github.com/user-attachments/assets/6edfa9c2-ebcd-4622-a115-f71fa533b3e1" />

<img width="949" height="594" alt="image" src="https://github.com/user-attachments/assets/8d15fa46-5178-422d-8eea-455cac31fdd0" />

</p>
</details>

- Multi-column file panel view with date/size/permission columns. Thanks [@&#8203;xelavopelk](https://github.com/xelavopelk) for the implementation

<details><summary>Screenshots</summary>
<p>

<img width="420" height="264" alt="image" src="https://github.com/user-attachments/assets/e172f1e8-c2a5-42d2-8eeb-62e721f61a4f" />

</p>
</details>

- Configurable fast navigation in the Filepanel. See this MR for more details: [#&#8203;1220](yorukot/superfile#1220)
- You can now configure `spf` to open files with specific extensions with your choice of editor application. Thanks  [@&#8203;litvinov-git](https://github.com/litvinov-git) for the implementation See this MR for more details: [#&#8203;1197](yorukot/superfile#1197)
- Terminal stdout support for shell commands
- Allow launching with the filename. `spf /a/b/c.txt` will launch in `/a/b` with `c.txt` as the selected file.
- Various bug fixes, including modal confirmations, layout issues, and race conditions. See 'Detailed Change Summary'

##### Internal Updates

- Separated FilePanel and FileModel into a dedicated package for better code organization
- Comprehensive end-to-end testing with layout fixes
- Enhanced dimension validation and sidebar fixes
- Updated multiple dependencies including Astro, Go toolchain, and linters
- Added gosec linter and MND linter with magic number cleanup

#### Detailed Change Summary

<details><summary>Details</summary>
<p>

##### Update
- allow hover to file [`#1177`](yorukot/superfile#1177) by @&#8203;lazysegtree
- show count selected items in select mode [`#1187`](yorukot/superfile#1187) by @&#8203;xelavopelk
- Add icon alias for kts to kt [`#1153`](yorukot/superfile#1153) by @&#8203;nicolaic
- link icon and metadata [`#1171`](yorukot/superfile#1171) by @&#8203;xelavopelk
- user configuration of editors by file extension [`#1197`](yorukot/superfile#1197) by @&#8203;litvinov-git
- add video preview support [`#1178`](yorukot/superfile#1178) by @&#8203;Yassen-Higazi
- Add pdf preview support [`#1198`](yorukot/superfile#1198) by @&#8203;Yassen-Higazi
- Add icons in pinned directories [`#1215`](yorukot/superfile#1215) by @&#8203;lazysegtree
- Enable fast configurable navigation [`#1220`](yorukot/superfile#1220) by @&#8203;lazysegtree
- add Trash bin to default directories for Linux [`#1236`](yorukot/superfile#1236) by @&#8203;lazysegtree
- add terminal stdout support for shell commands [`#1250`](yorukot/superfile#1250) by @&#8203;majiayu000
- More columns in file panel (MVP) [`#1268`](yorukot/superfile#1268) by @&#8203;xelavopelk

##### Bug Fix
- only calculate checksum on files [`#1119`](yorukot/superfile#1119) by @&#8203;nikero41
- Linter issue with PrintfAndExit [`#1133`](yorukot/superfile#1133) by @&#8203;xelavopelk
- Remove repeated os.ReadDir calls [`#1155`](yorukot/superfile#1155) by @&#8203;lazysegtree
- Disable COPYFILE in macOS [`#1194`](yorukot/superfile#1194) by @&#8203;lazysegtree
- add missing hotkeys to help menu [`#1192`](yorukot/superfile#1192) by @&#8203;lazysegtree
- Fetch latest version automatically [`#1127`](yorukot/superfile#1127) by @&#8203;lazysegtree
- Use async methods to prevent test race conditions [`#1201`](yorukot/superfile#1201) by @&#8203;lazysegtree
- update metadata and process bar sizes when toggling footer [`#1218`](yorukot/superfile#1218) by @&#8203;lazysegtree
- File panel dimension management [`#1222`](yorukot/superfile#1222) by @&#8203;lazysegtree
- Layout fixes with full end-to-end tests [`#1227`](yorukot/superfile#1227) by @&#8203;lazysegtree
- Fix flaky tests [`#1233`](yorukot/superfile#1233) by @&#8203;lazysegtree
- modal confirmation bug with arrow keys [`#1243`](yorukot/superfile#1243) by @&#8203;lazysegtree
- small file panel optimization [`#1241`](yorukot/superfile#1241) by @&#8203;xelavopelk
- use ExtractOperationMsg for extraction [`#1248`](yorukot/superfile#1248) by @&#8203;lazysegtree
- skip open_with from missing field validation [`#1251`](yorukot/superfile#1251) by @&#8203;lazysegtree
- border height validation fixes [`#1267`](yorukot/superfile#1267) by @&#8203;lazysegtree
- fix case with two active panes [`#1271`](yorukot/superfile#1271) by @&#8203;xelavopelk
- help model formatting [`#1277`](yorukot/superfile#1277) by @&#8203;booth-w

##### Optimization
- simplify renameIfDuplicate logic [`#1100`](yorukot/superfile#1100) by @&#8203;sarff
- separate FilePanel into dedicated package [`#1195`](yorukot/superfile#1195) by @&#8203;lazysegtree
- File model separation [`#1223`](yorukot/superfile#1223) by @&#8203;lazysegtree
- Dimension validations [`#1224`](yorukot/superfile#1224) by @&#8203;lazysegtree
- layout validation and sidebar dimension fixes [`#1228`](yorukot/superfile#1228) by @&#8203;lazysegtree
- user rendering package and removal of unused preview code [`#1245`](yorukot/superfile#1245) by @&#8203;lazysegtree
- user rendering package for file preview [`#1249`](yorukot/superfile#1249) by @&#8203;lazysegtree

##### Documentation
- update Fish shell setup docs [`#1142`](yorukot/superfile#1142) by @&#8203;wleoncio
- fix macOS typo [`#1212`](yorukot/superfile#1212) by @&#8203;wcbing
- stylistic and linguistic cleanup of config documentation [`#1184`](yorukot/superfile#1184) by @&#8203;ninetailedtori

##### Dependencies
- update astro monorepo [`#1010`](yorukot/superfile#1010) by @&#8203;renovate[bot]
- update starlight-giscus [`#1020`](yorukot/superfile#1020) by @&#8203;renovate[bot]
- bump astro versions [`#1138`](yorukot/superfile#1138), [`#1157`](yorukot/superfile#1157), [`#1158`](yorukot/superfile#1158) by @&#8203;dependabot[bot], @&#8203;renovate[bot]
- bump vite [`#1134`](yorukot/superfile#1134) by @&#8203;dependabot[bot]
- update setup-go action [`#1038`](yorukot/superfile#1038) by @&#8203;renovate[bot]
- update expressive-code plugins [`#1189`](yorukot/superfile#1189), [`#1246`](yorukot/superfile#1246) by @&#8203;renovate[bot]
- update sharp [`#1256`](yorukot/superfile#1256) by @&#8203;renovate[bot]
- update fontsource monorepo [`#1257`](yorukot/superfile#1257) by @&#8203;renovate[bot]
- update urfave/cli [`#1136`](yorukot/superfile#1136), [`#1190`](yorukot/superfile#1190) by @&#8203;renovate[bot]
- update astro / starlight / ansi / toolchain deps [`#1275`](yorukot/superfile#1275), [`#1278`](yorukot/superfile#1278), [`#1280`](yorukot/superfile#1280) by @&#8203;renovate[bot]
- update python and go versions [`#1276`](yorukot/superfile#1276), [`#1191`](yorukot/superfile#1191) by @&#8203;renovate[bot]
- update golangci-lint action [`#1286`](yorukot/superfile#1286) by @&#8203;renovate[bot]

##### Misc
- update CI input names [`#1120`](yorukot/superfile#1120) by @&#8203;nikero41
- Everforest Dark Hard theme [`#1114`](yorukot/superfile#1114) by @&#8203;fzahner
- migrate tutorial demo assets to local [`#1140`](yorukot/superfile#1140) by @&#8203;yorukot
- new logo asset [`#1145`](yorukot/superfile#1145) by @&#8203;nonepork
- mirror repository to codeberg [`#1141`](yorukot/superfile#1141) by @&#8203;yorukot
- sync package lock [`#1143`](yorukot/superfile#1143) by @&#8203;yorukot
- bump golangci-lint version [`#1135`](yorukot/superfile#1135) by @&#8203;lazysegtree
- add gosec linter [`#1185`](yorukot/superfile#1185) by @&#8203;lazysegtree
- enable MND linter and clean magic numbers [`#1180`](yorukot/superfile#1180) by @&#8203;lazysegtree
- skip permission tests when running as root [`#1186`](yorukot/superfile#1186) by @&#8203;lazysegtree
- release v1.4.1-rc [`#1203`](yorukot/superfile#1203) by @&#8203;lazysegtree
- 1.5.0-rc1 housekeeping changes [`#1264`](yorukot/superfile#1264) by @&#8203;lazysegtree

</p>
</details> 

#### New Contributors
* @&#8203;fzahner made their first contribution in yorukot/superfile#1114
* @&#8203;sarff made their first contribution in yorukot/superfile#1100
* @&#8203;nicolaic made their first contribution in yorukot/superfile#1153
* @&#8203;Yassen-Higazi made their first contribution in yorukot/superfile#1178
* @&#8203;ninetailedtori made their first contribution in yorukot/superfile#1184
* @&#8203;litvinov-git made their first contribution in yorukot/superfile#1197
* @&#8203;wcbing made their first contribution in yorukot/superfile#1212
* @&#8203;majiayu000 made their first contribution in yorukot/superfile#1250

**Full Changelog**: <yorukot/superfile@v1.4.0...v1.5.0>

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0Mi44MC4xIiwidXBkYXRlZEluVmVyIjoiNDIuODAuMSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiUmVub3ZhdGUgQm90IiwiYXV0b21hdGlvbjpib3QtYXV0aG9yZWQiLCJkZXBlbmRlbmN5LXR5cGU6Om1pbm9yIl19-->
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