Skip to content

100% test coverage on rhai_components#39

Merged
mcharytoniuk merged 4 commits into
mainfrom
coverage
May 16, 2026
Merged

100% test coverage on rhai_components#39
mcharytoniuk merged 4 commits into
mainfrom
coverage

Conversation

@mcharytoniuk
Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI review requested due to automatic review settings May 16, 2026 14:24
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR focuses on bringing rhai_components up to 100% test coverage by adding targeted unit tests across the component syntax pipeline and helper utilities, along with small refactors to make key error paths testable. It also introduces supporting build/CI tooling (Makefile targets + GitHub Actions jobs) and includes a few minor cleanups in the main poet crate.

Changes:

  • Added unit tests throughout rhai_components (template renderer, helpers, HTML escaping, component syntax parser/evaluator/combiner).
  • Refactored portions of the component-syntax implementation to isolate error-prone logic and enable direct testing.
  • Added/updated project tooling for running tests/clippy and measuring Rust coverage (Makefile + new Node dev dependency + CI workflow additions).

Reviewed changes

Copilot reviewed 32 out of 33 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
rhai_components/src/rhai_template_renderer.rs Adds tests validating renderer build, template lookup, render, and expression error context.
rhai_components/src/rhai_helpers/has.rs Adjusts has implementation and adds unit tests for supported Dynamic types.
rhai_components/src/rhai_helpers/error.rs Adds a unit test for runtime error behavior.
rhai_components/src/rhai_helpers/clsx.rs Simplifies boolean handling and adds unit tests for joining/error cases.
rhai_components/src/rhai_call_template_function.rs Adds tests for module resolution failures and missing template function.
rhai_components/src/escape_html.rs Adds test coverage for escaping behavior.
rhai_components/src/escape_html_attribute.rs Adds test coverage for attribute escaping behavior.
rhai_components/src/component_syntax/tag_name.rs Adds tests for component/void-element detection.
rhai_components/src/component_syntax/parser_state.rs Adds tests for TryFrom<i32> mapping and invalid values.
rhai_components/src/component_syntax/parse_component.rs Refactors parser state handling and adds extensive unit tests for error/transition paths.
rhai_components/src/component_syntax/mod.rs Reworks existing test into assertions and adds extra syntax-level tests.
rhai_components/src/component_syntax/fixtures/ThrowingComponent.rhai Adds fixture component that throws to exercise error propagation.
rhai_components/src/component_syntax/fixtures/NoTemplate.rhai Adds fixture module without template for negative testing.
rhai_components/src/component_syntax/fixtures/Bare.rhai Adds fixture to test no-value attributes and props inspection.
rhai_components/src/component_syntax/expression_collection.rs Extracts expression lookup helper and adds out-of-bounds test coverage.
rhai_components/src/component_syntax/evaluator_factory.rs Extracts Dynamic→TagStackNode cast helper and adds tests for evaluator error behavior.
rhai_components/src/component_syntax/eval_tag_stack_node.rs Minor refactor + adds tests covering component invocation, expression failures, attribute cases, and array body concatenation.
rhai_components/src/component_syntax/component_registry.rs Adds tests for default state and registration behavior.
rhai_components/src/component_syntax/combine_tag_stack.rs Simplifies unclosed-tag handling and adds tests for multiple error/success paths.
rhai_components/src/component_syntax/combine_output_symbols.rs Splits combining into merge/assemble steps and adds tests for many invalid/edge cases.
rhai_components/src/builds_engine.rs Removes unused template pre-registration logic and adds tests for helper/syntax registration and error propagation.
poet/src/mcp/mcp_http_service/respond_to_post/handler/resources_list_handler.rs Minor simplification using unwrap_or_default().
poet/src/generate_sitemap.rs Uses Path instead of PathBuf for a static comparison.
poet/src/eval_mdx_element.rs Removes unnecessary .into() during tag-name extraction.
poet/src/build_project/mod.rs Minor style cleanup in struct initialization.
package.json Adds @intentee/rust-coverage-check dev dependency.
package-lock.json Locks new coverage-check dependency and updates lock metadata.
Makefile Adds test, clippy, and coverage targets; reorders lockfile rule; minor target adjustments.
.github/workflows/unit-tests.yml Adds CI jobs for make test and make clippy.
.github/actions/setup-rust/action.yml Adds a composite action for Rust caching.
.github/actions/setup-node/action.yml Adds a composite action for Node setup (used by dev-environment action).
.github/actions/setup-dev-environment/action.yml Adds composite action to set up Node + Rust toolchains.
.claude/rules/code-coverage.md Documents make coverage as the authoritative coverage measurement command.
Comments suppressed due to low confidence (1)

Makefile:57

  • make coverage runs npx rust-coverage-check, but the newly added @intentee/rust-coverage-check package declares engines.node >=24. This can fail or behave inconsistently when developers/CI run the Makefile with Node 22 (as configured in .github/actions/setup-node). Either bump the Node version used by the project/tooling to >=24 or pin/use a coverage-check version compatible with the chosen Node version.
.PHONY: coverage
coverage: node_modules
	cargo llvm-cov clean --workspace
	cargo llvm-cov --workspace --no-report
	cargo llvm-cov report --json --output-path target/llvm-cov.json
	cargo llvm-cov report
	npx rust-coverage-check target/llvm-cov.json \
		--workspace-root $(CURDIR) \
		--gated rhai_components \
		--required-percent 100

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Makefile
Comment thread .github/actions/setup-node/action.yml
@mcharytoniuk mcharytoniuk merged commit 0e9cf06 into main May 16, 2026
2 checks passed
@mcharytoniuk mcharytoniuk deleted the coverage branch May 16, 2026 14:49
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