Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,11 @@ jobs:
RUST_BACKTRACE: 1
RUST_LIB_BACKTRACE: 1
run: cargo test -p windows-platform-probes --locked --no-fail-fast -- --include-ignored
- name: cargo test (windows-platform-probes oracle-in-renderer integration target)
env:
RUST_BACKTRACE: 1
RUST_LIB_BACKTRACE: 1
run: cargo test -p windows-platform-probes --features oracle-in-renderer --locked --test a_real_report_agrees_with_itself -- --include-ignored
# The binaries print the numbers the tests deliberately do not assert:
# host-specific magnitudes, which are exactly what an architecture
# comparison needs and what a pass/fail cannot carry.
Expand Down
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 11 additions & 18 deletions crates/windows-platform-probes/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ path = "src/lib.rs"
# ordinary dependency -- without `cfg(test)` -- for anything under `tests/`, so
# the binding does not reach them. Measured: an integration test rendered a
# report whose banner architecture contradicted its NDJSON and did not panic.
# This feature closes that, via the self dev-dependency below.
# This feature closes that for the explicit integration-test target below.
#
# Never enable it for a shipping build. A real probe run must PRINT a
# self-contradicting report rather than panic: the contradiction is a finding
Expand Down Expand Up @@ -97,6 +97,11 @@ path = "src/bin/long_path_aware.rs"
name = "probe-long-path-unaware"
path = "src/bin/long_path_unaware.rs"

[[test]]
name = "a_real_report_agrees_with_itself"
path = "tests/a_real_report_agrees_with_itself.rs"
required-features = ["oracle-in-renderer"]

[dependencies]
# **Optional, and reached only through `oracle-in-renderer`.** The report
# oracle's job is to answer "would a consumer be able to parse this row", and
Expand Down Expand Up @@ -218,24 +223,12 @@ windows-waitable-queues = { path = "../windows-waitable-queues", features = [
# rather than by cutting the text.
#
# **Not to satisfy `report_oracle`'s gate, which an earlier version of this
# comment claimed.** That claim was backwards: it said `cfg(test)` builds compile
# the module without `oracle-in-renderer`. They do not. The self dev-dependency
# below is an edge from this package to itself, so under resolver 2 the feature
# unifies onto the package in ANY build that includes dev-dependencies -- the
# `cfg(test)` lib build included. Measured with a `compile_error!` probe in both
# directions: `cargo check --tests` succeeds under `not(feature = ...)` and fails
# under `feature = ...`, while a plain `--lib` build has the feature off.
#
# So the two arms of `cfg(any(test, feature = "oracle-in-renderer"))` are never
# exercised separately, the optional `serde`/`serde_json` are already active in
# every test build, and a matching `serde` dev-dependency was dead weight --
# removed after confirming all 213 tests still pass without it.
# comment claimed.** The integration test that needs that gate is instead
# declared explicitly above with `required-features = ["oracle-in-renderer"]`,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated in 646526a: regenerated Cargo.lock and removed the stale windows-platform-probes self-dependency entry from the package dependencies list.

# so ordinary unit-test builds keep exercising the `cfg(test)` arm while that
# one target runs with the feature on.
Comment on lines +227 to +229

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated in befe334: corrected the stale oracle-in-renderer wiring references in src/lib.rs and src/topology_report.rs, and updated crates/windows-platform-probes/README.md test command to run with --features oracle-in-renderer.

serde = "1.0"
serde_json = "1.0"
Comment thread
Copilot marked this conversation as resolved.
# A dependency on ITSELF, which cargo permits for dev-dependencies and which is
# the only way to turn a feature on for this package's own integration tests:
# a test under `tests/` links the library as a plain dependency, so `cfg(test)`
# is not set for it and the renderer's oracle binding would be compiled out.
windows-platform-probes = { path = ".", features = ["oracle-in-renderer"] }

[dependencies.windows-sys]
version = "0.61.2"
Expand Down
2 changes: 1 addition & 1 deletion crates/windows-platform-probes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ probe that no longer compiles has already rotted.
## Running

```text
cargo test --package windows-platform-probes # the asserted tier
cargo test --package windows-platform-probes --features oracle-in-renderer # asserted tier + required-feature integration target
cargo run --bin probe-error-mode # observations, including the irreversible one
cargo run --bin probe-handle-state
```
Expand Down
10 changes: 5 additions & 5 deletions crates/windows-platform-probes/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@
//! # Running them
//!
//! ```text
//! cargo test -p windows-platform-probes # asserted tier
//! cargo test -p windows-platform-probes -- --include-ignored # both tiers
//! cargo test -p windows-platform-probes -- --ignored # ignored tier only
//! cargo test -p windows-platform-probes --features oracle-in-renderer # asserted tier
//! cargo test -p windows-platform-probes --features oracle-in-renderer -- --include-ignored # both tiers
//! cargo test -p windows-platform-probes --features oracle-in-renderer -- --ignored # ignored tier only
//! cargo run -p windows-platform-probes --bin probe-cancel-io # binary only
//!
//! # binary only, and --release is not optional: a debug build reports
Expand Down Expand Up @@ -159,8 +159,8 @@ pub mod report;
/// The report oracle. **Test-support: present only where it is used.**
///
/// Every caller is already behind this gate -- the renderers' `assert_row_is_well_formed`
/// bindings, the unit tests, and the integration tests, which reach it through the
/// self dev-dependency. Stating that here rather than leaving it implied is what
/// bindings, unit tests, and the required-feature integration target that enables
/// `oracle-in-renderer`. Stating that here rather than leaving it implied is what
/// lets the module depend on a real JSON parser without putting one in a shipping
/// probe binary.
#[cfg(any(test, feature = "oracle-in-renderer"))]
Expand Down
24 changes: 12 additions & 12 deletions crates/windows-platform-probes/src/topology_report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -960,8 +960,8 @@ pub fn report(banner: &str, observation: &Observation) -> String {
// library as an ordinary dependency, WITHOUT `cfg(test)`, for anything under
// `tests/`. Found by a review and measured -- an integration test rendered a
// report whose banner architecture contradicted its NDJSON `arch` and did
// not panic. The `oracle-in-renderer` feature, switched on by this crate's
// dev-dependency on itself, closes that.
// not panic. The `oracle-in-renderer` feature, enabled explicitly for the
// required-feature integration target, closes that.
//
// **A DEFAULT-FEATURE build still prints rather than panics**, which is the
// contract this gate exists to preserve: a self-contradicting report is a
Expand All @@ -982,12 +982,13 @@ pub fn report(banner: &str, observation: &Observation) -> String {
// than to claim one the mechanism cannot hold. Found by a review.
//
// Two consequences, both deliberate and both named here rather than left to
// be discovered: binaries built by `cargo test` assert, so a probe spawned
// by an integration test aborts on a contradiction instead of printing it;
// and so does an `--all-features` build. The evidence survives in every
// case, because the assertion's message carries the whole report -- what is
// lost is the NDJSON row a survey would have mined, which is why the default
// build is the one that matters and is the one pinned above.
// be discovered: binaries built by the feature-on test command assert, so a
// probe spawned by the required-feature integration target aborts on a
// contradiction instead of printing it; and so does an `--all-features`
// build. The evidence survives in every case, because the assertion's
// message carries the whole report -- what is lost is the NDJSON row a
// survey would have mined, which is why the default build is the one that
// matters and is the one pinned above.
//
// **The schema's SHAPES are bound here for the same reason.** Well-formed
// says the row parses; the schema says `processors` is a number and each
Expand All @@ -999,10 +1000,9 @@ pub fn report(banner: &str, observation: &Observation) -> String {
// `#[cfg]` attribute governs the single statement that follows it, so
// adding a second call beneath the gated one left that call ungated -- and
// `report_oracle` does not exist in a default build. Nothing local caught
// it: this crate's dev-dependency on itself turns `oracle-in-renderer` on
// for every `cargo test` and `cargo check --all-targets`, so the
// feature-off arm is never compiled here. CI's `cargo run --bin` is, and
// that is where it broke.
// it: the feature-on test wiring compiles only the enabled arm in those
// runs, so the feature-off arm was never checked there. CI's `cargo run
// --bin` is, and that is where it broke.
#[cfg(any(test, feature = "oracle-in-renderer"))]
{
crate::report_oracle::assert_row_is_well_formed(&out);
Expand Down