[pr-tests] darner-core logging: unit tests for the async queue, flush and filter fallback #316

Manually merged
TrustNo1 merged 2 commits from elgibbone/logging-async-queue into main 2026-12-05 04:48:43 +00:00 AGit
Contributor

What it changes

  • The problem on main: read from the code only. darner-core::logging (queue counters, writer loop, filter choice, DARNER_LOG_SYNC) had no unit tests.

Factors the queue counters, the writer loop, the filter choice and the sync switch into small helpers that can be tested without the global logger, with no change in behaviour, and adds six tests: lines reach console and file in order; a full queue drops without blocking and reports the count on both outputs; a disconnected receiver rolls back the queued count so flush does not wait; flush waits for pending lines and stops at its timeout; DARNER_LOG wins over RUST_LOG and bad syntax uses the default; sync mode is on only for 1.

How it was tested

  • Tested revision: a38a8e3
  • Commands and results (macOS aarch64, toolchain 1.98.1):
    • cargo test -p darner-core --locked: 39 passed, 0 failed
    • cargo clippy -p darner-core --all-targets --locked -- -D warnings, and with --all-features: clean
    • the same two with cargo xwin clippy --target x86_64-pc-windows-msvc: clean
    • cargo xtask policy: 555 files ok
    • On Windows, andrewpozdnakov7-jpg ran cargo test --offline --locked -p darner-core --lib logging::tests on a38a8e3: all six passed; cargo xtask policy passed (comment below).
  • Changes a default: no
  • Gates run on that revision: the three on darner-core only, on macOS, plus Windows-target clippy. Not --workspace.
  • Gameplay: not relevant (tests only).
  • Hardware dependence: none.
  • Coverage gaps: workspace-wide gates not run.

Checklist

  • I ran this change in the game, or say below why it can't be (docs, tests only). Not run in the game: tests only, no behaviour change.
  • This PR contains one change based on main.
  • The diff follows docs/asset-policy.md.
  • I recorded this PR's dependencies below.
    • Depends on: none

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches.
  • Related PRs: #205 and #249 also change crates/darner-core/src/logging.rs; both merge with this branch without a conflict (git merge-tree).
  • Replaces or overlaps: none found
## What it changes - The problem on main: read from the code only. darner-core::logging (queue counters, writer loop, filter choice, DARNER_LOG_SYNC) had no unit tests. Factors the queue counters, the writer loop, the filter choice and the sync switch into small helpers that can be tested without the global logger, with no change in behaviour, and adds six tests: lines reach console and file in order; a full queue drops without blocking and reports the count on both outputs; a disconnected receiver rolls back the queued count so flush does not wait; flush waits for pending lines and stops at its timeout; DARNER_LOG wins over RUST_LOG and bad syntax uses the default; sync mode is on only for 1. ## How it was tested - Tested revision: a38a8e3 - Commands and results (macOS aarch64, toolchain 1.98.1): - `cargo test -p darner-core --locked`: 39 passed, 0 failed - `cargo clippy -p darner-core --all-targets --locked -- -D warnings`, and with `--all-features`: clean - the same two with `cargo xwin clippy --target x86_64-pc-windows-msvc`: clean - `cargo xtask policy`: 555 files ok - On Windows, andrewpozdnakov7-jpg ran `cargo test --offline --locked -p darner-core --lib logging::tests` on a38a8e3: all six passed; `cargo xtask policy` passed (comment below). - Changes a default: no - Gates run on that revision: the three on darner-core only, on macOS, plus Windows-target clippy. Not --workspace. - Gameplay: not relevant (tests only). - Hardware dependence: none. - Coverage gaps: workspace-wide gates not run. ## Checklist - [ ] I ran this change in the game, or say below why it can't be (docs, tests only). Not run in the game: tests only, no behaviour change. - [x] This PR contains one change based on `main`. - [x] The diff follows `docs/asset-policy.md`. - [x] I recorded this PR's dependencies below. - Depends on: none ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. - Related PRs: #205 and #249 also change crates/darner-core/src/logging.rs; both merge with this branch without a conflict (git merge-tree). - Replaces or overlaps: none found
Factors the queue counters, writer loop, filter precedence and sync switch in darner-core::logging into unit-testable helpers without changing runtime behaviour, and adds six tests covering ordering, overflow drop reporting, disconnected receivers, bounded flush and DARNER_LOG/RUST_LOG/DARNER_LOG_SYNC parsing.
Contributor

The disconnected-receiver test can fail on a loaded runner even when the rollback works. Its 50 ms wall-clock limit also counts any time the OS deschedules the test thread. The queued-count assertion already catches a failed rollback. Consider using that invariant for this test and keeping the separate pending-line test for the wait behavior.

The disconnected-receiver test can fail on a loaded runner even when the rollback works. Its 50 ms wall-clock limit also counts any time the OS deschedules the test thread. The queued-count assertion already catches a failed rollback. Consider using that invariant for this test and keeping the separate pending-line test for the wait behavior.
The 50 ms wall-clock limit could fail on a loaded machine even when the
rollback works. flush only waits while written < queued, so asserting
that both counters are equal checks the same thing without timing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Contributor

Thanks, good point. Pushed a38a8e3: the test now asserts that written == queued (both 0 after the rollback), which is exactly the condition flush waits on, instead of timing it. flush_waits_for_pending_lines_and_stops_at_the_timeout still covers the wait. On a38a8e3, on macOS (aarch64): cargo test -p darner-core --locked 39 passed; both clippy gates on darner-core clean for the host and for x86_64-pc-windows-msvc (cargo-xwin).

Thanks, good point. Pushed a38a8e3: the test now asserts that written == queued (both 0 after the rollback), which is exactly the condition flush waits on, instead of timing it. flush_waits_for_pending_lines_and_stops_at_the_timeout still covers the wait. On a38a8e3, on macOS (aarch64): `cargo test -p darner-core --locked` 39 passed; both clippy gates on darner-core clean for the host and for `x86_64-pc-windows-msvc` (cargo-xwin).
Contributor

I tested a38a8e3 on Windows. All six logging tests passed with cargo test --offline --locked -p darner-core --lib logging::tests, including the rollback and bounded-flush cases. cargo xtask policy also passed.

I tested a38a8e3 on Windows. All six logging tests passed with `cargo test --offline --locked -p darner-core --lib logging::tests`, including the rollback and bounded-flush cases. `cargo xtask policy` also passed.
ElGibbone changed title from Add unit tests for async logging queue, flush and filter fallback to [pr-tests] darner-core logging: unit tests for the async queue, flush and filter fallback 2026-12-04 14:41:59 +00:00
TrustNo1 manually merged commit 765e63e133 into main 2026-12-05 04:48:43 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
TrustNo1/Darner!316
No description provided.