Skip to content

test: exercise batch 2 packages through public APIs - #985

Open
martintmk wants to merge 7 commits into
mainfrom
martintmk-public-api-tests-batch-2
Open

martintmk wants to merge 7 commits into
mainfrom
martintmk-public-api-tests-batch-2

Conversation

@martintmk

@martintmk martintmk commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

Summary

This is an automated mechanical PR for arty_io_host, arty_macros, arty_macros_impl, arty_tokio, and bytesbuf.

Move 194 unit tests to integration tests through existing public APIs. Keep private-path tests with rationale. Do not add public APIs.

  • arty_io_host: Move 2 error cases to provider callbacks. Keep 2 cases for a private concurrency hook and telemetry wrappers.
  • arty_macros: Leave unchanged. The package has no unit tests.
  • arty_macros_impl: Move 24 expansion and error cases. Keep 2 cases that inject private Cargo dependency metadata.
  • arty_tokio: Leave unchanged. Its 12 unit tests need private startup state or private error types. Existing integration tests cover public behavior.
  • bytesbuf: Move 168 cases into buffers, views, conversions, and memory_providers targets. Keep 37 private layout, iterator, state, and helper cases.

Motivation

Tests through public APIs depend on observable behavior rather than internal structure. Internal refactoring therefore needs fewer test changes.

Evidence

The audit accounts for every original unit test. Migrated tests retain their inputs and assertion meaning, with equivalent public-API inputs where private setup was required. Six macro cases now compare complete expected output instead of fragments, prefixes, or the absence of an error. Relevant error cases include the original input. Worker literals and malformed inputs exercise both macros. These weaker checks also existed before migration.

The source diff changes test code, test-only helpers, and imports under test configuration. It does not change runtime logic or the public API.

The grouped targets use nested module declarations instead of repetitive path attributes. Test names include prefixes such as buffers::buf:: and conversions::from_bytes::. Buffer and view targets share the existing private block fixture through explicit paths. A private test_memory module also reuses the allocation fixture through public Block and Memory APIs. The coordinator received these paths and every pushed head.

The core targets no longer require test-util, so their tests also run without the library's std feature. Standard I/O cases require std. The memory_providers target retains its test-util requirement. Compatibility chunks are initialized before every advance_mut call.

Both Linux coverage jobs at 079b1e73 reported seven uncovered lines in the shared block fixture. The moved metadata tests already exercise those paths. The coverage filter conservatively retains helper counters when source ownership is uncertain. A file-level #![cfg(test)] now makes the fixture's existing test-only scope explicit. Every caller already compiled it only in tests. No assertions, coverage thresholds, ignores, or stress-test selection changed.

The publishing pipeline at 1e649cf4 exposed eight unwrap_used diagnostics in helpers in the host integration target. A file-level #![cfg(test)] now expresses that target's existing test-only scope. This lets Clippy apply the repository's existing test policy. All unwraps, assertions, helpers, and test names remain unchanged. No lint allows were added.

The exact targeted Clippy command reproduced all eight errors before this change and passed afterward on Windows. The package compilation passed. Both original integration cases ran and passed, with zero ignored or filtered cases:

cargo clippy --locked -p arty_io_host --test context_reentrancy --offline --profile dev --all-features -- -D warnings
cargo check -q -p arty_io_host
cargo test --locked -p arty_io_host --test context_reentrancy --offline --all-features

The publishing log at 9d32f29b no longer reports those host errors. It reports three distinct unwrap_used errors in bytesbuf integration helpers. The narrow local reproduction also exposed a Windows-only panic lint in the migrated memory-status helper. Three file-level #![cfg(test)] guards now express the helpers' existing test-only scope. The repair preserves every unwrap, panic, assertion, test name, host-memory guard, and Miri condition. It adds no lint allows or exclusions.

The same targeted Clippy command failed before the repair and passed afterward on Windows. Package compilation also passed:

cargo clippy --locked -p bytesbuf --test buffers --test views --test conversions --test memory_providers --offline --profile dev --all-features -- -D warnings
cargo check -q -p bytesbuf

Formatting passed with the pinned nightly. The macro changes passed the affected-package compilation and all 24 expansion cases:

cargo check -q -p arty_macros_impl
cargo test -q -p arty_macros_impl --test expansion

The block fixture change passed compilation and all 156 tests in its unit, buffer, and view targets: 37, 56, and 63 cases.

cargo check -q -p bytesbuf
cargo test -q -p bytesbuf --features test-util,bytes-compat,seismograph --lib --test buffers --test views

The earlier affected-package compilation passed:

cargo check -q -p bytesbuf --no-default-features --features bytes-compat

The core targets passed 116 tests without the library's std feature: 46 buffer, 58 view, and 12 conversion cases. cargo tree reported only bytes-compat for the library's enabled features.

cargo test -q -p bytesbuf --no-default-features --features bytes-compat --test buffers --test views --test conversions -- --skip test_giant

After the final helper-scope repair, all four targets passed 165 tests with all features: 56 buffer, 63 view, 13 conversion, and 33 memory-provider cases. The counts match the earlier compatibility and telemetry run.

cargo test -q --locked -p bytesbuf --test buffers --test views --test conversions --test memory_providers --offline --all-features -- --skip giant_allocation --skip test_giant

Three existing large-allocation tests were compiled but not run locally. CI for the latest head remains pending. The local coverage tool lacks the CI recipe's run command, so the coverage repair still needs CI confirmation. No full local test suite, coverage run, mutation run, or broad feature matrix was run.

Merge Danger

Risk is limited to test setup, placement, feature selection, test-only scope, and stricter macro assertions. Core tests now run without test-util. Compatibility, standard I/O, and telemetry cases keep the gates required by their APIs. The large-allocation cases retain their inputs and host-memory guards. Test selectors must account for the added module prefixes. The known Clippy failure in arty_executor predates this PR and remains outside this batch. CI must cover the remaining configurations before merge.

Move reachable unit tests in arty_io_host, arty_macros_impl, and bytesbuf to integration targets. Keep private-path tests with rationale. Audit arty_macros and arty_tokio without changing them.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 13, 2026 14:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The migrated tests drop coverage for supported no-std configurations, and three advance_mut calls violate the safety contract by marking unwritten bytes as initialized.

2 open issues
What changed in this PR

This PR moves tests for arty_io_host, arty_macros_impl, and bytesbuf to integration targets that use existing public APIs. It reduces dependence on private implementation details without adding public APIs or changing runtime logic.

Changes:

  • Moves 194 tests covering provider callbacks, macro expansion, buffers, views, and conversions.
  • Retains private-path unit tests and adds comments explaining why they remain.
  • Adds a feature-gated buffer test target and relocates its memory-check helper.
File Description
crates/​bytesbuf/​tests/​support/​system_memory.rs Relocates host-memory checks for large-allocation tests.
crates/​bytesbuf/​tests/​public_api/​view_read.rs Moves read-adapter tests to public APIs.
crates/​bytesbuf/​tests/​public_api/​view_get.rs Moves byte and numeric read tests.
crates/​bytesbuf/​tests/​public_api/​vec.rs Moves vector conversion tests.
crates/​bytesbuf/​tests/​public_api/​mem_testing_transparent.rs Moves transparent memory provider tests.
crates/​bytesbuf/​tests/​public_api/​mem_testing_fixed_block.rs Moves fixed-block provider tests.
crates/​bytesbuf/​tests/​public_api/​mem_opaque_memory.rs Moves opaque provider forwarding tests.
crates/​bytesbuf/​tests/​public_api/​mem_memory.rs Moves reference-based reservation tests.
crates/​bytesbuf/​tests/​public_api/​mem_global.rs Moves public memory-pool behavior tests.
crates/​bytesbuf/​tests/​public_api/​mem_callback_memory.rs Moves callback provider tests.
crates/​bytesbuf/​tests/​public_api/​mem_block_ref.rs Moves block-reference lifecycle and metadata tests.
crates/​bytesbuf/​tests/​public_api/​bytes_compat_view.rs Moves bytes::Buf compatibility tests.
crates/​bytesbuf/​tests/​public_api/​bytes_compat_to_bytes.rs Moves conversions to bytes::Bytes.
crates/​bytesbuf/​tests/​public_api/​bytes_compat_from_bytes.rs Moves conversions from bytes::Bytes.
crates/​bytesbuf/​tests/​public_api/​bytes_compat_buf.rs Moves bytes::BufMut compatibility tests.
crates/​bytesbuf/​tests/​public_api/​buf_writer.rs Moves writer behavior and capacity tests.
crates/​bytesbuf/​tests/​public_api/​buf_put.rs Moves byte and numeric write tests.
crates/​bytesbuf/​tests/​public_api.rs Registers test modules and shared helpers.
crates/​bytesbuf/​src/​view.rs Removes migrated tests and a test-only constructor; retains layout checks.
crates/​bytesbuf/​src/​view_read.rs Removes migrated read-adapter unit tests.
crates/​bytesbuf/​src/​view_get.rs Removes migrated numeric-read unit tests.
crates/​bytesbuf/​src/​vec.rs Retains private iterator tests after moving conversions.
crates/​bytesbuf/​src/​telemetry.rs Adds rationale for retaining private identity tests.
crates/​bytesbuf/​src/​span.rs Adds rationale for retaining private span tests.
crates/​bytesbuf/​src/​span_builder.rs Adds rationale for retaining private builder tests.
crates/​bytesbuf/​src/​memory_guard.rs Adds rationale for retaining private collection assertions.
crates/​bytesbuf/​src/​mem/​testing/​transparent.rs Removes migrated provider unit tests.
crates/​bytesbuf/​src/​mem/​testing/​fixed_block.rs Removes migrated fixed-block unit tests.
crates/​bytesbuf/​src/​mem/​opaque_memory.rs Removes migrated wrapper unit tests.
crates/​bytesbuf/​src/​mem/​memory.rs Removes migrated reference-forwarding tests.
crates/​bytesbuf/​src/​mem/​global.rs Retains private pool-state tests after migration.
crates/​bytesbuf/​src/​mem/​callback_memory.rs Removes migrated callback unit tests.
crates/​bytesbuf/​src/​mem/​block_ref.rs Retains private dispatch-table tests after migration.
crates/​bytesbuf/​src/​lib.rs Removes the former unit-test helper module declaration.
crates/​bytesbuf/​src/​bytes_compat/​view.rs Removes migrated Buf unit tests.
crates/​bytesbuf/​src/​bytes_compat/​to_bytes.rs Removes migrated conversion unit tests.
crates/​bytesbuf/​src/​bytes_compat/​from_bytes.rs Retains private iterator tests after moving conversions.
crates/​bytesbuf/​src/​bytes_compat/​buf.rs Removes migrated BufMut unit tests.
crates/​bytesbuf/​src/​buf.rs Moves public behavior tests and retains private-state checks.
crates/​bytesbuf/​src/​buf_writer.rs Removes migrated writer unit tests.
crates/​bytesbuf/​src/​buf_put.rs Retains private fast-path checks after migration.
crates/​bytesbuf/​Cargo.toml Registers public_api with the test-util requirement.
crates/​arty_macros_impl/​tests/​expansion.rs Adds public-entry-point expansion and error tests.
crates/​arty_macros_impl/​src/​lib.rs Retains dependency-discovery unit tests after migration.
crates/​arty_io_host/​tests/​context_reentrancy.rs Exercises nested context retrieval through provider callbacks.
crates/​arty_io_host/​src/​telemetry.rs Adds rationale for retaining private telemetry tests.
crates/​arty_io_host/​src/​runtime.rs Adds rationale for retaining the private concurrency test.
crates/​arty_io_host/​src/​driver_host.rs Removes migrated context-retrieval unit tests.

Review effort: Balanced

Comment thread crates/bytesbuf/Cargo.toml Resolved
Use nested module discovery for buffer, view, conversion, and memory-provider targets. Share test fixtures without expanding public APIs.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 13, 2026 15:02
Initialize compatibility chunks before advancing them and use public memory contracts in core integration fixtures.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Active findings identify uninitialized bytes marked as initialized, feature-gating regressions that remove supported test coverage, and 5 GB tests left enabled under Miri.

3 open issues
2 resolved since last review

Review effort: Balanced

// This is a giant allocation that does not fit into one memory block.

let memory = TransparentMemory::new();
let buf = memory.reserve(5_000_000_000);
Copilot AI balanced review requested due to automatic review settings November 13, 2026 15:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Three large-allocation tests remain enabled under Miri despite disabled memory guards, requiring reasoned test-level ignores while preserving native boundary and small-test coverage.

2 open issues
1 previously missed issue

In code that hasn't changed since last review

Medium severity Ignore 5 GB allocation boundary tests under Miri

crates/​bytesbuf/​tests/​conversions/​from_vec.rs:47

Under Miri, the memory guard is disabled, but this test still allocates 5,000,000,000 bytes; Anvil selects integration tests with all features (justfiles/anvil/checks/miri.just:46–58). Add a reasoned test-level Miri ignore, keeping the native boundary test and small conversion tests enabled, as prescribed by docs/runtime-analysis.md:29–46. Apply the same change to crates/bytesbuf/tests/conversions/from_bytes.rs:33, which initializes the same number of bytes.

1 resolved since last review

Review effort: Balanced

Preserve all migrated cases and compare full expected tokens. Exercise both macros for worker literals and malformed inputs.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 13, 2026 15:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The transparent-provider test still allocates 5 GB under Miri because only its memory guard is gated, requiring a test-level Miri exclusion while preserving native large-allocation coverage.

1 open issue
1 resolved since last review

Review effort: Balanced

@codecov

codecov Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.0%. Comparing base (2be413c) to head (921ac49).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##            main     #985      +/-   ##
=========================================
  Coverage   99.9%   100.0%              
=========================================
  Files        808      287     -521     
  Lines      68565    20731   -47834     
=========================================
- Hits       68556    20731   -47825     
+ Misses         9        0       -9     
Flag Coverage Δ
linux 100.0% <ø> (ø)
linux-arm 100.0% <ø> (ø)
scheduled ?
windows 100.0% <ø> (+<0.1%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Declare the fixture's existing test-only scope in the file so released-surface coverage filtering can classify it across module paths.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 13, 2026 15:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The shared fixture’s cfg change alters coverage source classification, while CI coverage confirmation and remaining feature configurations are pending and require human verification before approval.

1 open issue

Review effort: Balanced

Keep helper unwraps inside their existing test-only scope so Clippy applies the repository's test policy. Preserve both discovered cases and all assertions.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 13, 2026 16:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Changes to test-target feature selection and coverage ownership still need latest-head CI evidence validating the coverage-filter repair and remaining coverage, mutation, and runtime-analysis configurations.

1 open issue

Review effort: Balanced

Express the helpers' existing test-only scope for Clippy. Preserve unwraps, panic behavior, assertions, test selection, and memory guards.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 13, 2026 17:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

There are no active review issues requiring changes before approval.

1 open issue

Review effort: Balanced

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