1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//! External-context check for the `KTSTR_TESTS` distributed
//! slice.
//!
//! The `#[ktstr_test]` macro has been covered by every integration
//! test that uses it — if the macro emission broke, the whole suite
//! would fail to compile or link. This file covers the complementary
//! surface: the *manual* `#[distributed_slice]` path documented at
//! `test_support::KTSTR_TESTS`, for downstream crates that
//! programmatically populate entries without going through the
//! macro.
//!
//! Manual registration depends on `ktstr::distributed_slice` and
//! `ktstr::linkme` being re-exported at the crate root so consumers
//! can spell the `#[distributed_slice]` attribute and the companion
//! `#[linkme(crate = ktstr::linkme)]` annotation. If either re-export
//! disappears or the path changes, this file fails to compile. At
//! runtime, the framework's `--list` protocol must surface the
//! manually-registered entry under its declared name; nextest
//! discovery proves that by listing the entry below as a runnable
//! test.
//!
//! No standalone `#[test]` assertions live here: once a binary holds
//! any real `#[ktstr_test]` entry, `test_support::ktstr_main`
//! intercepts nextest's `--list` and hides plain `#[test]`
//! functions. The registration proof is in the entry's presence in
//! the nextest list, not in a separate assertion.
use anyhow::Result;
use ktstr::assert::AssertResult;
use ktstr::scenario::Ctx;
use ktstr::test_support::KtstrTestEntry;
fn external_context_test_fn(_ctx: &Ctx) -> Result<AssertResult> {
Ok(AssertResult::pass())
}
/// Manual `#[distributed_slice]` registration reachable through
/// `ktstr::distributed_slice` and `ktstr::linkme`. If nextest
/// `--list` for this binary does not emit
/// `ktstr::distributed_slice_registration ktstr/external_context_marker`,
/// the manual-registration surface regressed — the macro expansion
/// still works but programmatic test generation has silently broken.
#[ktstr::distributed_slice(ktstr::test_support::KTSTR_TESTS)]
#[linkme(crate = ktstr::linkme)]
static EXTERNAL_CONTEXT_MARKER: KtstrTestEntry = KtstrTestEntry {
name: "external_context_marker",
func: external_context_test_fn,
auto_repro: false,
..KtstrTestEntry::DEFAULT
};