Skip to content

fix(cg): unify Stylo test locks to prevent cascading test failures#637

Merged
softmarshmallow merged 2 commits intomainfrom
feature/unruffled-vaughan
Apr 7, 2026
Merged

fix(cg): unify Stylo test locks to prevent cascading test failures#637
softmarshmallow merged 2 commits intomainfrom
feature/unruffled-vaughan

Conversation

@softmarshmallow
Copy link
Copy Markdown
Member

@softmarshmallow softmarshmallow commented Apr 7, 2026

Summary

  • The html and htmlcss test modules each had their own mutex guarding Stylo's process-global DOM slot. Since both locks protected the same shared state, tests from the two modules could run concurrently and corrupt Stylo, causing panics that poisoned the htmlcss lock (which used .unwrap()) and cascaded to all 22 htmlcss tests.
  • Consolidate into a single stylo_test::lock() in lib.rs with poison recovery via unwrap_or_else(|e| e.into_inner()), matching the pattern html already used.
  • Fixes the cargo test failure on main after feat(htmlcss): CSS Grid layout + box-shadow support #635 was merged.

Test plan

  • cargo test -p cg passes (683 lib tests, 0 failures)
  • cargo test --workspace --exclude grida-canvas-wasm passes
  • CI test-crates workflow passes

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Refactor
    • Consolidated test infrastructure for HTML-related modules to use a shared synchronization mechanism.

…ures

The `html` and `htmlcss` test modules each had their own mutex guarding
Stylo's process-global DOM slot. Since both locks protected the same
shared state, tests from the two modules could run concurrently and
corrupt Stylo, causing panics that poisoned the htmlcss lock (which used
`.unwrap()`) and cascaded to all 22 htmlcss tests.

Consolidate into a single `stylo_test::lock()` in lib.rs with poison
recovery via `unwrap_or_else(|e| e.into_inner())`.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 7, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview, Comment Apr 7, 2026 0:49am
6 Skipped Deployments
Project Deployment Actions Updated (UTC)
code Ignored Ignored Apr 7, 2026 0:49am
legacy Ignored Ignored Apr 7, 2026 0:49am
backgrounds Skipped Skipped Apr 7, 2026 0:49am
blog Skipped Skipped Apr 7, 2026 0:49am
grida Skipped Skipped Apr 7, 2026 0:49am
viewer Skipped Skipped Apr 7, 2026 0:49am

Request Review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 7, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4c01598b-d498-4ced-8581-e799804c8395

📥 Commits

Reviewing files that changed from the base of the PR and between f4ffe54 and 7dd831c.

📒 Files selected for processing (3)
  • crates/grida-canvas/src/html/mod.rs
  • crates/grida-canvas/src/htmlcss/mod.rs
  • crates/grida-canvas/src/lib.rs

Walkthrough

This change refactors test synchronization across the grida-canvas crate. A new centralized test-locking module (stylo_test) is added to provide a shared Mutex<()> with poison-recovery logic. Local test mutexes in the html and htmlcss modules are removed and replaced with calls to this shared lock function.

Changes

Cohort / File(s) Summary
Test Synchronization Infrastructure
crates/grida-canvas/src/lib.rs
Added new stylo_test module with process-global STYLO_TEST_LOCK and public lock() function that recovers from poisoned mutex states via unwrap_or_else().
Test Lock Migration
crates/grida-canvas/src/html/mod.rs, crates/grida-canvas/src/htmlcss/mod.rs
Removed local Mutex<()> definitions (HTML_TEST_LOCK and TEST_LOCK) from test modules. Updated all HTML and HTML/CSS tests to call crate::stylo_test::lock() instead of local lock acquisitions.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: unifying Stylo test locks to prevent cascading failures. It directly reflects the core objective of consolidating separate mutexes into a single crate-level lock.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/unruffled-vaughan

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.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vercel vercel Bot temporarily deployed to Preview – viewer April 7, 2026 12:49 Inactive
@vercel vercel Bot temporarily deployed to Preview – blog April 7, 2026 12:49 Inactive
@vercel vercel Bot temporarily deployed to Preview – grida April 7, 2026 12:49 Inactive
@vercel vercel Bot temporarily deployed to Preview – backgrounds April 7, 2026 12:49 Inactive
@softmarshmallow softmarshmallow merged commit cb38be0 into main Apr 7, 2026
16 checks passed
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.

1 participant