Skip to content

test: cover imported and nested-imported dotrain resolution#142

Merged
thedavidmeister merged 2 commits into
mainfrom
2026-06-14-issue-98
Jun 15, 2026
Merged

test: cover imported and nested-imported dotrain resolution#142
thedavidmeister merged 2 commits into
mainfrom
2026-06-14-issue-98

Conversation

@thedavidmeister

Copy link
Copy Markdown
Contributor

Adds tests for @import resolution, including nested imports, per the issue.

What

Two RainDocument parse tests in crates/dotrain/src/parser/raindocument/mod.rs (the source-organized test module that already houses the parse/import-resolution tests). Imported dotrains are stored as DotrainV1 metas in the Store (keyed by keccak256 hash via set_dotrain) and referenced from the importing dotrain by @<hash>.

  • test_parse_imported_dotrain — a dotrain that @imports another. Asserts:

    • resolution succeeds with no problems and exactly one recorded import pointing at the stored hash;
    • the imported dotrain is parsed and carried in the import sequence at import_depth 1;
    • the importer's own binding is an owned leaf (import_index == -1);
    • the imported binding merges into the root namespace as an imported leaf (import_index == 0) carrying the import hash and the value declared in the imported dotrain — discriminating on the merged result, not just that it parsed.
  • test_parse_nested_imported_dotrain — a top dotrain @imports a middle dotrain that itself @imports an inner dotrain. Asserts:

    • the whole nested chain resolves cleanly;
    • import depths are 1 (middle) and 2 (inner) in the nested import sequence;
    • the middle binding merges into the top namespace, and the transitively imported inner binding is also reachable from the top namespace with the inner import hash — the defining property of nested import resolution.

Verification

  • cargo test -p dotrain --lib: 24 passed, 0 failed (the two new tests included).
  • Mutation-validated: breaking the import-resolution line in build_imports_namespaces (the copy_namespace import-index argument) makes both new tests fail with left: -1, right: 0 while all pre-existing tests stay green; restoring it makes them pass. Confirms the new tests cover the resolution path and that it was previously uncovered.

Test-only; no source/bytecode change.

Closes #98

🤖 Generated with Claude Code

Adds two RainDocument parse tests exercising @import resolution:

- test_parse_imported_dotrain: a dotrain that @imports another whose
  DotrainV1 meta is stored in the Store keyed by its hash. Asserts the
  import resolves without problems, the imported dotrain is parsed at
  depth 1, the importer's own binding stays an owned leaf (import_index
  -1), and the imported binding merges into the root namespace as an
  imported leaf (import_index 0) carrying the import hash and the value
  declared in the imported dotrain.

- test_parse_nested_imported_dotrain: a top dotrain @imports a middle
  dotrain that itself @imports an inner dotrain. Asserts the whole chain
  resolves cleanly, the import depths are 1 (middle) and 2 (inner) in the
  nested sequence, and that the transitively imported inner binding is
  reachable from the top namespace with the inner import hash, which is
  the defining property of nested import resolution.

Closes #98

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@thedavidmeister thedavidmeister self-assigned this Jun 14, 2026
@coderabbitai

coderabbitai Bot commented Jun 14, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@thedavidmeister, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 9 minutes and 48 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 18345269-27df-43d6-aadd-302a8a498bb1

📥 Commits

Reviewing files that changed from the base of the PR and between 34ab3e7 and 2124d55.

📒 Files selected for processing (1)
  • crates/dotrain/src/parser/raindocument/mod.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 2026-06-14-issue-98

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.

cargo clippy with -D clippy::all rejects the needless reference passed to
alloy_primitives::hex::encode_prefixed, whose argument is taken by an
AsRef<[u8]> generic bound. Pass the owned hash by value in the imported
and nested-imported RainDocument parse tests.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@thedavidmeister

Copy link
Copy Markdown
Contributor Author

Reviewed 2124d55: approved by maintainer; all checks green, mergeable, CodeRabbit clean, comments current-behavior-only. Merging.

@thedavidmeister thedavidmeister merged commit eefd3b6 into main Jun 15, 2026
6 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

@coderabbitai assess this PR size classification for the totality of the PR with the following criterias and report it in your comment:

S/M/L PR Classification Guidelines:

This guide helps classify merged pull requests by effort and complexity rather than just line count. The goal is to assess the difficulty and scope of changes after they have been completed.

Small (S)

Characteristics:

  • Simple bug fixes, typos, or minor refactoring
  • Single-purpose changes affecting 1-2 files
  • Documentation updates
  • Configuration tweaks
  • Changes that require minimal context to review

Review Effort: Would have taken 5-10 minutes

Examples:

  • Fix typo in variable name
  • Update README with new instructions
  • Adjust configuration values
  • Simple one-line bug fixes
  • Import statement cleanup

Medium (M)

Characteristics:

  • Feature additions or enhancements
  • Refactoring that touches multiple files but maintains existing behavior
  • Breaking changes with backward compatibility
  • Changes requiring some domain knowledge to review

Review Effort: Would have taken 15-30 minutes

Examples:

  • Add new feature or component
  • Refactor common utility functions
  • Update dependencies with minor breaking changes
  • Add new component with tests
  • Performance optimizations
  • More complex bug fixes

Large (L)

Characteristics:

  • Major feature implementations
  • Breaking changes or API redesigns
  • Complex refactoring across multiple modules
  • New architectural patterns or significant design changes
  • Changes requiring deep context and multiple review rounds

Review Effort: Would have taken 45+ minutes

Examples:

  • Complete new feature with frontend/backend changes
  • Protocol upgrades or breaking changes
  • Major architectural refactoring
  • Framework or technology upgrades

Additional Factors to Consider

When deciding between sizes, also consider:

  • Test coverage impact: More comprehensive test changes lean toward larger classification
  • Risk level: Changes to critical systems bump up a size category
  • Team familiarity: Novel patterns or technologies increase complexity

Notes:

  • the assessment must be for the totality of the PR, that means comparing the base branch to the last commit of the PR
  • the assessment output must be exactly one of: S, M or L (single-line comment) in format of: SIZE={S/M/L}
  • do not include any additional text, only the size classification
  • your assessment comment must not include tips or additional sections
  • do NOT tag me or anyone else on your comment

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.

add tests with imported and nested imported dotrains

1 participant