Skip to content

Relative import paths in test/src/lib - #142

Merged
thedavidmeister merged 6 commits into
mainfrom
2026-08-18-issue-94-relative-test-imports
Aug 18, 2026
Merged

Relative import paths in test/src/lib#142
thedavidmeister merged 6 commits into
mainfrom
2026-08-18-issue-94-relative-test-imports

Conversation

@thedavidmeister

@thedavidmeister thedavidmeister commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Closes #94

Verified against main

Branched at 9a238f4, origin/main merged in at 7620643.

The claim holds and has grown. grep -rn 'from "\(src\|test\)/' src/ test/ returned 83 hits at 9a238f4 (the issue said 73), all in test/src/lib/, zero in src/, which already imports relatively throughout. remappings.txt carries only forge-std-1.16.1/=dependencies/forge-std-1.16.1/, so these resolve solely through foundry's project-root auto-remap — which points at the consumer's tree, not ours, whenever the package is consumed.

The issue's second ask — LibStackSentinel.t.sol reaching LibUint256Array indirectly through src/lib/LibStackPointer.sol — is already fixed on main: LibStackPointer.sol no longer exists and the import is direct from src/lib/LibUint256Array.sol. Only the bare-path conversion remained.

The issue predicted the convention "gets copied into a new file". It did, during this branch's life: test/src/lib/LibArray.aliasedTail.t.sol, landed on main by #121 after this branch was cut, arrived with two fresh bare src/ imports. They are converted here too, bringing the total to 85.

Changed

Every import in test/src/lib/** converted to relative, matching src/:

shape before after
library under test "src/lib/X.sol" "../../../src/lib/X.sol"
errors "src/error/X.sol" "../../../src/error/X.sol"
slow reference impls "test/lib/XSlow.sol" "../../lib/XSlow.sol"
sibling harnesses "test/src/lib/XHarness.sol" "./XHarness.sol"

Relative rather than the rain-solmem/=src/ self-remapping the issue offers as an alternative: .soldeerignore drops remappings.txt from the package, so a remapping would split the repo's own convention between src/ (relative) and test/ (remapped) for no consumer-visible gain.

Imports only. No source, no test logic, no assertion changed. The full suite passes before and after with the same counts.

QA

  • Discriminating tests: n/a — no new tests. The change is import resolution, and the discriminator is the existing suite: it only compiles and passes if every rewritten path binds to the same file the bare path bound to. Baseline at 9a238f4 and post-change are both 349 passed, 0 failed across 33 suites; after merging 7620643 in, 353 passed, 0 failed across 34 suites — the 4 extra tests are LibArray.aliasedTail.t.sol, which main added.
  • Mutations applied:
# mutation proves result
M1 src/lib/LibUint256Array.sol:399 mstore(left, mload(right))mstore(left, mload(left)) ../../../src/lib/ binds to the real source KILLEDtestReverse(uint256[]); suite ran 5 tests, 4 passed / 1 failed
M2 test/lib/LibUint256ArraySlow.sol:165 b[i] = a[a.length - i - 1]b[i] = a[i] ../../lib/ binds to the real reference impl KILLEDtestReverse(uint256[]); suite ran 5 tests, 4 passed / 1 failed
M3 test/src/lib/LibMatrixFlattenWrapHarness.sol:148 canary[3] = CANARYcanary[3] = SCRIBBLE ./ binds to the sibling harness SURVIVED — 9 ran, 0 failed. That test's stated design, not a gap; see below
M3b test/src/lib/LibMatrixFlattenWrapHarness.sol:49 mstore(matrix, 2)mstore(matrix, 0) ./ binds to the sibling harness KILLEDtestUint256ItemCountUncheckedSumUnderreportsTheTotal, testUint256ItemCountOverflowRevertsWithArithmeticPanic, testFlattenNonWrappingOversizedLengthFailsLoudly; 9 ran, 6 passed / 3 failed
M4 test/src/lib/LibPointer.t.sol:7 ../../../src/lib/../../src/lib/ a wrong depth must not resolve KILLEDError (6275): Source "test/src/lib/LibPointer.sol" not found
M5 test/src/lib/LibUint256Array.reverse.t.sol:8 ../../lib/../lib/ a wrong depth must not resolve KILLEDError (6275): Source "test/src/lib/LibUint256ArraySlow.sol" not found
M6 test/src/lib/LibMatrix.flattenWrap.t.sol:6 ./../ a wrong depth must not resolve KILLEDError (6275): Source "test/src/LibMatrixFlattenWrapHarness.sol" not found

M1–M3b break the target file and watch the suite notice, which is what proves each rewritten path still reaches the file it used to. M4–M6 break the path and watch resolution fail, which is the negative control the shape change needs: it proves the new paths resolve relatively and that no root auto-remap silently rescues a wrong one. Every run's own Suite result / Ran N test suites line is quoted, so no result rests on a filter that matched nothing.

M3's survival is the documented design of LibMatrix.flattenWrap.t.sol, not a gap this diff created. Its header states that every assertion lives in the success branch of a try so that any guard rejecting the forged count takes the empty catch and passes. The #62 guard is on main, so uint256FlattenThenWriteThroughResult reverts and the assertion never runs. Confirmed by planting assertTrue(false, "catch taken") in all four catch bodies: all four report [FAIL: catch taken], 9 ran / 5 passed / 4 failed. These are regression sentinels for #62, so no mutation to that call path could have killed M3. M3b re-probes the same ./ binding through itemCount, which the suite does observe.

  • Oracle: foundry's import resolver. A path either binds to the file the bare path bound to — in which case every assertion in the suite still holds — or it binds elsewhere, and either the compiler or an assertion says so. There is no third outcome, and the two mutation families cover both.
  • Category check: the issue asks for (a) all bare src/ and test/ imports converted and (b) LibStackSentinel.t.sol's indirect import through LibStackPointer.sol. (a) covers all 85 — the 73 that existed when the issue was filed, the 10 added since, and the 2 that landed on main mid-branch — and grep -rn 'from "\(src\|test\)/' src/ test/ now returns zero. (b) was already fixed on main before this branch.

Not done here

Nothing stops the next new test file from arriving with bare paths again, as #121's did. A mechanical guard is the durable answer, but per the org convention that rainix owns shared CI, the lint belongs in the rainix reusable workflow rather than in this repo — a separate change against a separate repo.

Summary by CodeRabbit

  • Chores

    • Standardized test imports to use repository-relative paths.
    • Improved consistency and portability across the test suite.
  • Tests

    • Test logic and behavior remain unchanged.
    • No public or exported interfaces were modified.

Bare project-root paths only resolve through foundry's root auto-remap, which
points at the consumer's tree when the package is consumed. src/ already
imports relatively.

Closes #94
@thedavidmeister thedavidmeister self-assigned this Aug 18, 2026
@coderabbitai

coderabbitai Bot commented Aug 18, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

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

Next review available in: 45 minutes

Limit details: You’ve used all 1 included review currently available under your plan.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

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.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 12854e17-90c3-4df2-820a-66dabd9f9999

📥 Commits

Reviewing files that changed from the base of the PR and between f44f701 and 660830c.

📒 Files selected for processing (35)
  • test/src/error/ErrTruncate.t.sol
  • test/src/lib/LibArray.aliasedTail.t.sol
  • test/src/lib/LibArray.selfExtend.t.sol
  • test/src/lib/LibArraySlow.copySlow.t.sol
  • test/src/lib/LibBytes.t.sol
  • test/src/lib/LibBytes32Array.allocation.t.sol
  • test/src/lib/LibBytes32Array.arrayFrom.t.sol
  • test/src/lib/LibBytes32Array.extend.t.sol
  • test/src/lib/LibBytes32Array.pointer.t.sol
  • test/src/lib/LibBytes32Array.reverse.t.sol
  • test/src/lib/LibBytes32Array.truncate.t.sol
  • test/src/lib/LibBytes32Matrix.allocation.t.sol
  • test/src/lib/LibBytes32Matrix.endPointer.t.sol
  • test/src/lib/LibBytes32Matrix.flatten.t.sol
  • test/src/lib/LibBytes32Matrix.itemCount.t.sol
  • test/src/lib/LibBytes32Matrix.matrixFrom.t.sol
  • test/src/lib/LibBytes32Matrix.pointer.t.sol
  • test/src/lib/LibMatrix.flattenWrap.t.sol
  • test/src/lib/LibMemCpy.Bytes.t.sol
  • test/src/lib/LibMemCpy.Words.t.sol
  • test/src/lib/LibPointer.t.sol
  • test/src/lib/LibStackSentinel.t.sol
  • test/src/lib/LibStackSentinel.tupleSizeWrap.t.sol
  • test/src/lib/LibUint256Array.allocation.t.sol
  • test/src/lib/LibUint256Array.arrayFrom.t.sol
  • test/src/lib/LibUint256Array.extend.t.sol
  • test/src/lib/LibUint256Array.pointer.t.sol
  • test/src/lib/LibUint256Array.reverse.t.sol
  • test/src/lib/LibUint256Array.truncate.t.sol
  • test/src/lib/LibUint256Matrix.allocation.t.sol
  • test/src/lib/LibUint256Matrix.endPointer.t.sol
  • test/src/lib/LibUint256Matrix.flatten.t.sol
  • test/src/lib/LibUint256Matrix.itemCount.t.sol
  • test/src/lib/LibUint256Matrix.matrixFrom.t.sol
  • test/src/lib/LibUint256Matrix.pointer.t.sol

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 1fccec3d-1841-457a-82a9-71d61d86453b

📥 Commits

Reviewing files that changed from the base of the PR and between bc5a1b2 and f44f701.

📒 Files selected for processing (37)
  • test/src/error/ErrTruncate.t.sol
  • test/src/lib/LibArray.aliasedTail.t.sol
  • test/src/lib/LibArray.selfExtend.t.sol
  • test/src/lib/LibArraySlow.copySlow.t.sol
  • test/src/lib/LibBytes.t.sol
  • test/src/lib/LibBytes32Array.allocation.t.sol
  • test/src/lib/LibBytes32Array.arrayFrom.t.sol
  • test/src/lib/LibBytes32Array.extend.t.sol
  • test/src/lib/LibBytes32Array.pointer.t.sol
  • test/src/lib/LibBytes32Array.reverse.t.sol
  • test/src/lib/LibBytes32Array.truncate.t.sol
  • test/src/lib/LibBytes32Matrix.allocation.t.sol
  • test/src/lib/LibBytes32Matrix.endPointer.t.sol
  • test/src/lib/LibBytes32Matrix.flatten.t.sol
  • test/src/lib/LibBytes32Matrix.itemCount.t.sol
  • test/src/lib/LibBytes32Matrix.matrixFrom.t.sol
  • test/src/lib/LibBytes32Matrix.pointer.t.sol
  • test/src/lib/LibMatrix.flattenWrap.t.sol
  • test/src/lib/LibMatrixFlattenWrapHarness.sol
  • test/src/lib/LibMemCpy.Bytes.t.sol
  • test/src/lib/LibMemCpy.Words.t.sol
  • test/src/lib/LibPointer.t.sol
  • test/src/lib/LibStackSentinel.t.sol
  • test/src/lib/LibStackSentinel.tupleSizeWrap.t.sol
  • test/src/lib/LibStackSentinelWrapHarness.sol
  • test/src/lib/LibUint256Array.allocation.t.sol
  • test/src/lib/LibUint256Array.arrayFrom.t.sol
  • test/src/lib/LibUint256Array.extend.t.sol
  • test/src/lib/LibUint256Array.pointer.t.sol
  • test/src/lib/LibUint256Array.reverse.t.sol
  • test/src/lib/LibUint256Array.truncate.t.sol
  • test/src/lib/LibUint256Matrix.allocation.t.sol
  • test/src/lib/LibUint256Matrix.endPointer.t.sol
  • test/src/lib/LibUint256Matrix.flatten.t.sol
  • test/src/lib/LibUint256Matrix.itemCount.t.sol
  • test/src/lib/LibUint256Matrix.matrixFrom.t.sol
  • test/src/lib/LibUint256Matrix.pointer.t.sol

Included review availability: Your plan includes up to 1 review per rolling hour; 0 remain after this review.


Walkthrough

The change replaces bare or remapped Solidity imports in test and harness files with repository-relative paths. Imported entities and test behavior remain unchanged.

Changes

Test import path normalization

Layer / File(s) Summary
Convert test imports to relative paths
test/src/error/ErrTruncate.t.sol, test/src/lib/*
Updated imports for array, matrix, bytes, memory, pointer, sentinel, error, and slow-reference libraries. No declarations or test logic changed.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Merge Risk: ⚪ Minimal · up to f44f7

This PR only updates test import paths without changing production code or test behavior; no actionable merge-blocking risk remains after normal checks and review.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change: converting imports in test/src/lib to relative paths.
Linked Issues check ✅ Passed The PR converts the bare src/ and test/ imports identified in issue #94 to relative paths and preserves test logic.
Out of Scope Changes check ✅ Passed All changes are limited to import-path updates within test/src/lib, with no unrelated logic or behavior changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 2026-08-18-issue-94-relative-test-imports

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.

baku-ccron and others added 3 commits August 18, 2026 12:50
…elative-test-imports

Eight test files conflicted. Every conflict was the same shape: main changed
which symbols are imported and from where, this branch changed only the shape
of the path. Each is resolved by taking main's import list verbatim and
re-applying this branch's rewrite, so the error consolidation from #140 and
the new coverage from #133/#126/#127 land intact with relative paths.

  LibBytes.t.sol                  TruncateError -> OutOfBoundsTruncate, now
                                  from src/error/ErrTruncate.sol
  LibBytes32Array.truncate.t.sol  OutOfBoundsTruncate moved off
  LibUint256Array.truncate.t.sol  ErrUint256Array.sol onto ErrTruncate.sol
  LibStackSentinel.t.sol          sentinel errors moved out of the library and
                                  into src/error/ErrStackSentinel.sol, and
                                  MissingSentinel/ZeroSentinelTupleSize added
  LibBytes32Matrix.flatten.t.sol  main added imports for new tests
  LibUint256Matrix.flatten.t.sol
  LibBytes32Matrix.itemCount.t.sol
  LibUint256Matrix.itemCount.t.sol

Imports only. The merged tree differs from main on import lines alone, and
all 112 first-party imports resolve to the same files they do on main.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
test/src/error/ErrTruncate.t.sol landed on main with #140 after this branch
was cut, carrying four fresh bare src/ imports. Same situation as
LibArray.aliasedTail.t.sol in 67ff20b, and converted the same way, so that
the invariant this PR claims holds on the merge result:

  grep -rn 'from "\(src\|test\)/' src/ test/

now returns nothing.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…elative-test-imports

# Conflicts:
#	test/src/error/ErrTruncate.t.sol
#	test/src/lib/LibArray.aliasedTail.t.sol
#	test/src/lib/LibArray.selfExtend.t.sol
#	test/src/lib/LibBytes.t.sol
#	test/src/lib/LibBytes32Array.pointer.t.sol
#	test/src/lib/LibBytes32Array.reverse.t.sol
#	test/src/lib/LibBytes32Array.truncate.t.sol
#	test/src/lib/LibBytes32Matrix.flatten.t.sol
#	test/src/lib/LibBytes32Matrix.itemCount.t.sol
#	test/src/lib/LibBytes32Matrix.matrixFrom.t.sol
#	test/src/lib/LibBytes32Matrix.pointer.t.sol
#	test/src/lib/LibMatrix.flattenWrap.t.sol
#	test/src/lib/LibStackSentinel.tupleSizeWrap.t.sol
#	test/src/lib/LibUint256Array.pointer.t.sol
#	test/src/lib/LibUint256Array.reverse.t.sol
#	test/src/lib/LibUint256Array.truncate.t.sol
#	test/src/lib/LibUint256Matrix.flatten.t.sol
#	test/src/lib/LibUint256Matrix.itemCount.t.sol
#	test/src/lib/LibUint256Matrix.matrixFrom.t.sol
#	test/src/lib/LibUint256Matrix.pointer.t.sol
@thedavidmeister
thedavidmeister merged commit 5db528a into main Aug 18, 2026
4 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.

[A32] [LOW] Bare src/ and test/ import paths in all 28 test files

1 participant