Skip to content

macOS menu test: use the whole native menu, so clippy passes on a Mac - #2970

Merged
h-a-n-a-s-h-i merged 1 commit into
storytold:mainfrom
Aimarmndz:fix/mac-menu-test-clippy
Oct 30, 2026
Merged

h-a-n-a-s-h-i merged 1 commit into
storytold:mainfrom
Aimarmndz:fix/mac-menu-test-clippy

Conversation

@Aimarmndz

@Aimarmndz Aimarmndz commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Problem

e6df6f4 (strict Clippy) removed the #[allow(unused_imports, dead_code)] on the native_menu module that apps/gridcraft/tests/mac_menu_appkit.rs builds in. That test only compiles on macOS, so since then cargo xtask ci fails at clippy on every Mac, while the Linux gate stays green:

error: unused import: `super::*`                       --> apps/gridcraft/tests/../src/native_menu.rs:393:9
error: fields `events`, `theme_items`, `window_menu`, `window_items`, and `windows` are never read
error: constant `WINDOW_ITEM` is never used
error: function `select_theme` is never used
error: methods `sync_windows` and `poll` are never used
error: could not compile `gridcraft` (test "mac_menu_appkit") due to 5 previous errors
  • The test called only install, so poll and everything it reaches were dead in that build.
  • A harness = false test is built with cfg(test) but without the #[test] functions, so the unit tests' use super::* was unused.

Fix (no allow)

  • mac_menu_appkit now polls the menu with a one-workbook session and checks that the Window menu lists that workbook (MacOS - [Move,Resize,Fill,Arange windows/screen] #716). That uses the rest of the module and tests one more thing AppKit-side.
  • The native_menu unit tests name super:: items instead of a glob import.

Verification (macOS 27, arm64)

  • cargo xtask ci: all 10 steps pass, with CRAFT_FONTS_DIR at the gate's craft-fonts commit (b076417). On main (68a4b1a) it fails at clippy as above.
  • The new check fails when the poll call is removed: the Window menu's last item is "" instead of "Book1".
  • Linux is unaffected (the module is cfg(target_os = "macos") in that test); I couldn't run the Linux gate here, GitHub Actions does.

Summary by CodeRabbit

  • Tests
    • Expanded macOS menu checks to verify the Window menu title and confirm that an open workbook window appears in the menu.
    • Existing main-menu title checks and expected behavior remain unchanged.

e6df6f4 removed the #[allow(unused_imports, dead_code)] on the
native_menu module that tests/mac_menu_appkit.rs builds in. That test
only compiles on macOS, so `cargo xtask ci` has failed at clippy on
every Mac since, while the Linux gate stayed green:

- the test called only `install`, leaving `poll`, `sync_windows`,
  `select_theme`, `WINDOW_ITEM` and most `NativeMenu` fields unused;
- the harness = false build has cfg(test) but drops #[test] functions,
  so the unit tests' `use super::*` was an unused import.

The test now also polls the menu with a one-workbook session and checks
that the Window menu lists that workbook (storytold#716), which uses the rest of
the module. The unit tests name `super::` items instead of a glob import.

Verified on macOS 27 (arm64): `cargo xtask ci` passes all 10 steps (with
CRAFT_FONTS_DIR at the gate's craft-fonts commit), and the new check
fails when the poll is removed (Window menu's last item "" vs "Book1").
@coderabbitai

coderabbitai Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 68a4b1a and 1d38a25.

Files selected for processing: 2
  • apps/gridcraft/src/native_menu.rs
  • apps/gridcraft/tests/mac_menu_appkit.rs

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Walkthrough

The native-menu unit tests now qualify references through super. The macOS AppKit test checks the Window-menu title and verifies that its final item matches the label of the open workbook window.

Changes: Native menu tests

Layer / File(s) Summary
Native-menu unit-test references
apps/gridcraft/src/native_menu.rs
Tests qualify references to tree, SheetApp, and select_theme through super. Test assertions and expected behavior are unchanged.
AppKit Window-menu checks
apps/gridcraft/tests/mac_menu_appkit.rs
The test retains a mutable NativeMenu, checks the Window-menu title, creates a workbook, polls the menu, and checks that the final item matches the open window’s label.

Priority: Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: dylanmtaylor

Merge Risk: Minimal · up to 1d38a

No actionable merge-blocking risk remains in this test-only change.

Pre-merge checks: Passed 4 · Failed 1

Failed 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%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: updating the macOS menu test to exercise the full native menu so Clippy passes on macOS.
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.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 2 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@h-a-n-a-s-h-i
h-a-n-a-s-h-i merged commit 885a5dd into storytold:main Oct 30, 2026
6 checks passed
@echelon

echelon commented Oct 30, 2026

Copy link
Copy Markdown
Member

Landed in main (75f7056). Thank you for the contribution, @Aimarmndz! If you haven't already, come join us on Discord: https://discord.gg/artcraft

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.

3 participants