# kache-e2e fixture: the configured fallback wrapper, delegating to a
# real sccache.
#
# `rust-fallback` proves the `KACHE_FALLBACK` wiring with a synthetic
# wrapper script. This fixture proves the same path composes with the
# tool the feature exists for (#109): sccache. It catches what a fake
# fallback cannot — argument-order mismatches, double-wrapping, or env
# conflicts between kache's passthrough and sccache.
#
# `requires = ["sccache"]`: the fixture is SKIPPED (not failed) when
# sccache is not on PATH — so a dev box or fork PR without sccache
# stays green. CI installs sccache, so it runs there.
#
# The project is a dependency-free `bin`. kache never caches a
# user-facing executable, so building it ALWAYS takes the passthrough
# path — which, with `KACHE_FALLBACK` set, hands the compile to the
# `e2e-fallback` wrapper in `sccache` delegate mode: it `exec`s the real
# `sccache` and appends `--cfg via_sccache`, which `src/main.rs` reads
# via `cfg!`, so the binary's own output proves the compile travelled
# through sccache rather than a degraded plain passthrough.
#
# NOT `negative_control_exempt`: `KACHE_DISABLED=1` routes straight to
# the real compiler — sccache is skipped, the marker cfg is unset, and
# `[verify]` flips to fail. That makes the fixture falsifiable.

name = "e2e-rust-sccache"
tags = ["suite:e2e", "lang:rust", "mode:fallback"]
requires = ["sccache"]

[source]
kind = "fixture"
path = "source"

[env]
RUSTC_WRAPPER = "$KACHE"
# Cross-platform fallback wrapper (`e2e-fallback`), built next to the
# harness; `$FALLBACK` is its absolute path (works after relocate and on
# Windows). `E2E_FALLBACK_DELEGATE = sccache` makes it `exec sccache
# <compiler> <args>` — sccache's own `<wrapper> <compiler>` form,
# byte-identical to `RUSTC_WRAPPER=sccache`.
KACHE_FALLBACK = "$FALLBACK"
E2E_FALLBACK_DELEGATE = "sccache"
# This fixture only proves kache delegates to the sccache wrapper; the
# separate `scripts/sccache-fallback-check.sh` step proves a real sccache
# cache hit. On persistent Windows CI, sccache's daemon can occasionally reset
# while cargo probes `rustc -vV`; let this delegation fixture fall back to the
# compiler instead of failing on daemon I/O.
SCCACHE_IGNORE_SERVER_IO_ERROR = "1"
# Append `--cfg via_sccache` to the fixture crate's own compile only.
E2E_FALLBACK_CRATE = "rust_sccache"
E2E_FALLBACK_CFG = "via_sccache"

[commands]
build = "cargo build"
clean = "rm -rf target"

[verify]
run = "./target/debug/rust-sccache"
# Printed only when the compile went through `e2e-fallback` -> sccache.
# With the fallback broken the binary prints `rust-sccache: no sccache`
# and this assertion fails.
expected_stdout_contains = ["rust-sccache: via sccache"]

# kache declines to cache the executable on every phase, so nothing is
# ever stored in *kache's* cache. (sccache does not cache `bin` crates
# either — its rlib-caching path behind the fallback is asserted
# separately by scripts/sccache-fallback-check.sh.) The contract here
# is narrower: "the compile was delegated to sccache", asserted by
# `[verify]` via the `--cfg via_sccache` marker.
[assertions.cold]
max_entries_after = 0

[assertions.warm]
max_entries_after = 0

# A no-op rebuild: cargo's own freshness check sees nothing changed and
# does not recompile.
[assertions.noop]
should_not_recompile = true
recompile_marker = "Compiling"

# Built from a different absolute path: still passthrough, still
# delegated to sccache, still nothing in kache's cache.
[assertions.relocate]
max_entries_after = 0
