crates.sage_test_harness.compile_tests.project_isolation

Each test gets an isolated materialized Cargo project whose source is the supplied fixture, with deterministic logical paths and no dependence on the caller’s working directory or enclosing workspace’s default members. The fixture is compiled as an ordinary library, with cfg(test) disabled and no enabled Cargo features; running the enclosing Rust test does not enable test compilation for the fixture.

Read in specification context · design/crates/sage_test_harness/compile-tests.md

Implementation

Implemented crates/sage-ir/src/db.rs:1–6

sage_ir::db · lib:sage_ir

#![allow(unused)]
fn main() {
// {anchor}`crates.sage_test_harness.compile_tests.project_isolation`
// {anchor}`crates.sage_test_harness.compile_tests.query_capture`
use std::collections::HashMap;

use crate::source::SourceFile;
use crate::tcx::{NoopTcxDb, TcxDb};

}

See more source ↗

Implemented crates/sage-ir/src/parse/attrs.rs:2–7

sage_ir::parse::attrs · lib:sage_ir

#![allow(unused)]
fn main() {
// {anchor}`crates.sage_test_harness.compile_tests.project_isolation`
// {anchor}`crates.sage_test_harness.compile_tests.fixtures`
use sage_stash::{Slice, Stash};

use crate::cst::attrs::{AttrCst, AttrCstKind};
use crate::cst::paths::Path;

}

See more source ↗

Implemented crates/sage-ir/src/parse/items.rs:1414–1414

sage_ir::parse::items · lib:sage_ir

#![allow(unused)]
fn main() {
// {anchor}`crates.sage_test_harness.compile_tests.project_isolation`

}

See more source ↗

Implemented crates/sage-ir/src/parse/mod.rs:1–6

sage_ir::parse · lib:sage_ir

#![allow(unused)]
fn main() {
// {anchor}`crates.sage_test_harness.compile_tests.project_isolation`
// {anchor}`crates.sage_test_harness.compile_tests.diagnostic_counts`
// {anchor}`crates.sage_test_harness.compile_tests.checking_scope`
mod attrs;
mod exprs;
mod generics;

}

See more source ↗

Implemented crates/sage-ir/src/source.rs:15–20

sage_ir::source · lib:sage_ir

#![allow(unused)]
fn main() {
// {anchor}`crates.sage_test_harness.compile_tests.project_isolation`
pub fn normalize_path(path: &str) -> String {
    let mut parts = Vec::new();
    for part in path.split('/') {
        match part {
            "" | "." => {}

}

See more source ↗

Implemented crates/sage-test-harness/src/compile/observe.rs:2–7

sage_test_harness::compile::observe · lib:sage_test_harness

#![allow(unused)]
fn main() {
// {anchor}`crates.sage_test_harness.compile_tests.project_isolation`
// {anchor}`crates.sage_test_harness.compile_tests.annotation_validation`
// {anchor}`crates.sage_test_harness.compile_tests.compiler_conditions`
// {anchor}`crates.sage_test_harness.compile_tests.fixtures`
use super::annotations::Compiler;
use super::types::FrozenType;

}

See more source ↗

Implemented crates/sage-test-harness/src/compile/rustc.rs:18–23

sage_test_harness::compile::rustc · lib:sage_test_harness

#![allow(unused)]
fn main() {
// {anchor}`crates.sage_test_harness.compile_tests.project_isolation`
pub(super) fn check(
    project: &Path,
    files: &BTreeMap<String, String>,
    edition: &str,
    markers: &[Marker],

}

See more source ↗

Implemented crates/sage-test-harness/src/compile/mod.rs:125–130

sage_test_harness::compile · lib:sage_test_harness

#![allow(unused)]
fn main() {
        // {anchor}`crates.sage_test_harness.compile_tests.project_isolation`
        let project = tempfile::tempdir().map_err(|e| e.to_string())?;
        std::fs::write(project.path().join("Cargo.toml"), format!(
            "[package]\nname = \"compile_test_fixture\"\nversion = \"0.0.0\"\nedition = \"{edition}\"\n[workspace]\n"
        )).map_err(|e| e.to_string())?;
        for (path, source) in &files {

}

See more source ↗

Implemented crates/sage-host/src/driver.rs:10–15

sage_host::driver · lib:sage_host

#![allow(unused)]
fn main() {
// {anchor}`crates.sage_test_harness.compile_tests.project_isolation`
// {anchor}`crates.sage_test_harness.compile_tests.edition`
// {anchor}`crates.sage_test_harness.compile_tests.query_capture`
use std::path::{Path, PathBuf};
use std::sync::atomic::{AtomicU64, Ordering};
use std::sync::mpsc;

}

See more source ↗

Implemented crates/sage-host/src/metadata.rs:5–10

sage_host::metadata · lib:sage_host

#![allow(unused)]
fn main() {
// {anchor}`crates.sage_test_harness.compile_tests.project_isolation`
use std::collections::{HashMap, HashSet};
use std::path::{Path, PathBuf};
use std::process::Command;

use serde::Deserialize;

}

See more source ↗

Tests and review

Indexed tests and the implementation-completeness and test-adequacy review; no test run is implied.

Implemented sage_test_harness::compile::tests::cold_queries_are_stable_across_isolated_projects

crates/sage-test-harness/src/compile/mod.rs · lib:sage_test_harness

#![allow(unused)]
fn main() {
#[test]
    #[sage::test(crates.sage_test_harness.compile_tests.query_capture)]
    #[sage::test(crates.sage_test_harness.compile_tests.query_projection)]
    #[sage::test(crates.sage_test_harness.compile_tests.project_isolation)]
    #[sage::test(crates.sage_test_harness.compile_tests.rendering)]
    fn cold_queries_are_stable_across_isolated_projects() {
        let mut first = CompileTest::default();
        first.source("fn f() -> u16 { 22 }");
        first.queries(expect![""]);
        let first = first.prepare().unwrap();
        let mut second = CompileTest::default();
        second.source("fn f() -> u16 { 22 }");
        second.queries(expect![""]);
        let second = second.prepare().unwrap();
        assert_eq!(first.queries, second.queries);
        assert!(first.queries.contains("executed"), "{}", first.queries);
        assert!(first.queries.contains("body"), "{}", first.queries);
        assert!(!first.queries.contains("/tmp/"));
        assert!(!first.queries.contains("Id("));
    }
}

Conditional source: #[cfg(test)]

See more source ↗

Implemented sage_test_harness::configuration_selects_items_before_checking

crates/sage-test-harness/tests/compile_tests.rs · test:compile_tests

#![allow(unused)]
fn main() {
#[test]
#[sage::test(crates.sage_test_harness.compile_tests.project_isolation)]
fn configuration_selects_items_before_checking() {
    compile_test! {
        source: indoc! {r#"
            #[cfg(all(not(test), not(feature = "unused")))]
            fn included() -> u16 { 22 }
            #[cfg(any())]
            mod absent;
            struct Value;
            impl Value {
                #[cfg(test)]
                fn excluded() -> u16 { true }
                #[cfg(not(test))]
                fn included() -> u16 { included() }
            }
        "#},
    }
}
}

See more source ↗

Implemented sage_test_harness::fixtures_ignore_caller_directory_and_workspace_defaults

crates/sage-test-harness/tests/review_fixture.rs · test:review_fixture

#![allow(unused)]
fn main() {
#[test]
#[sage::test(crates.sage_test_harness.compile_tests.project_isolation)]
fn fixtures_ignore_caller_directory_and_workspace_defaults() {
    const CHILD: &str = "SAGE_PROJECT_ISOLATION_CHILD";
    if std::env::var_os(CHILD).is_some() {
        // Identical logical filenames and item names must still use each
        // invocation's own source, with stable fixture-relative observations.
        compile_test! {
            source: "fn value() -> u16 {\n 22 //# ty\n}",
            observations: expect_test::expect!["src/lib.rs: literal `22`\n  type: u16\n"],
        }
        compile_test! {
            source: "fn value() -> bool {\n true //# ty\n}",
            observations: expect_test::expect!["src/lib.rs: literal `true`\n  type: bool\n"],
        }
        return;
    }

    let unrelated = tempfile::tempdir().unwrap();
    let workspace = tempfile::tempdir().unwrap();
    std::fs::create_dir_all(workspace.path().join("default/src")).unwrap();
    std::fs::write(
        workspace.path().join("Cargo.toml"),
        "[workspace]\nmembers = [\"default\"]\ndefault-members = [\"default\"]\nresolver = \"3\"\n",
    )
    .unwrap();
    std::fs::write(
        workspace.path().join("default/Cargo.toml"),
        "[package]\nname = \"unrelated_default\"\nversion = \"0.0.0\"\nedition = \"2024\"\n",
    )
    .unwrap();
    std::fs::write(
        workspace.path().join("default/src/lib.rs"),
        "compile_error!(\"caller workspace must not be compiled\");",
    )
    .unwrap();
    for directory in [unrelated.path(), workspace.path()] {
        let output = std::process::Command::new(std::env::current_exe().unwrap())
            .args([
                "--exact",
                "fixtures_ignore_caller_directory_and_workspace_defaults",
                "--nocapture",
            ])
            .env(CHILD, "1")
            .env_remove("UPDATE_EXPECT")
            .current_dir(directory)
            .output()
            .unwrap();
        assert!(
            output.status.success(),
            "fixture failed from {}:\n{}\n{}",
            directory.display(),
            String::from_utf8_lossy(&output.stdout),
            String::from_utf8_lossy(&output.stderr),
        );
        assert!(String::from_utf8_lossy(&output.stdout).contains("1 passed"));
    }
}
}

See more source ↗

Implemented sage_test_harness::ordinary_library_disables_test_configuration

crates/sage-test-harness/tests/review_fixture.rs · test:review_fixture

#![allow(unused)]
fn main() {
#[test]
#[sage::test(crates.sage_test_harness.compile_tests.project_isolation)]
fn ordinary_library_disables_test_configuration() {
    compile_test! {
        source: "#[cfg(test)]\nfn excluded() -> u16 { true }\nfn included() {}",
    }
}
}

See more source ↗

Implemented sage_test_harness::ordinary_library_disables_unselected_features

crates/sage-test-harness/tests/review_fixture.rs · test:review_fixture

#![allow(unused)]
fn main() {
#[test]
#[sage::test(crates.sage_test_harness.compile_tests.project_isolation)]
fn ordinary_library_disables_unselected_features() {
    compile_test! {
        source: "#[cfg(feature = \"unused\")]\nfn excluded() -> u16 { true }\nfn included() {}",
    }
}
}

See more source ↗

Review: Accepted · /root/final_quality.

Fresh review of project_isolation's complete claim, ten ordinary implementation entries and five ordinary tests. No TODO/N/A evidence. This is source/assertion inspection, with no source edits or fresh build/test execution. Initial whole-file captures contain the relevant helper implementations; no uncaptured implementation is used as evidence here.

Project and caller independence: compile/mod.rs creates a new tempfile directory per prepare, writes the supplied validated fixture paths there and generates a standalone package manifest with an explicit empty [workspace]. It opens SageHost using that directory. rustc.rs executes the pinned compiler with current_dir set to the same project and explicitly compiles src/lib.rs as --crate-type lib, without --test or feature flags. The generated manifest contains no features or dependencies. sage-host metadata.rs runs cargo metadata in the supplied project directory and selects its ordinary library target, so the caller's directory/default workspace members do not select the fixture. Driver.rs constructs its own metadata stub and provider instance, loads that package's text files and initializes a new Database. db.rs with_proxy_and_cfgs creates fresh storage, source map and logs for each host. Same-named files/items in successive fixtures cannot reuse a previous fixture's database or source contents.

Ordinary-library configuration: metadata.rs obtains target cfg values from rustc --print cfg and the generated package's resolved enabled features. The fixture manifest defines none; the driver therefore adds no feature predicates, and neither fixture compiler nor metadata compiler requests test compilation. db.rs stores the known cfg list as a Salsa input. parse/attrs.rs evaluates cfg predicates against it, including all/any/not and feature key-value forms. parse/mod.rs applies cfg before creating enabled top-level item identities, and parse/items.rs applies the same gate for associated items; excluded modules are not loaded and excluded erroneous bodies are not checked. No enclosing test-process cfg leaks into that explicit configuration.

Deterministic logical paths: driver.rs registers package inputs relative to the selected target source directory. source.rs normalizes logical paths, including parent components needed for supported explicit module paths. parse/items.rs resolves modules from those logical names. observe.rs emits fixture-relative src/ paths rather than materialization-directory paths. rustc.rs matches structured diagnostic locations against the fixture map. These mechanisms establish source path isolation; the shared query-projection test additionally checks stable externally observable query output across independent hosts, without this review claiming a separate exhaustive query-projection audit.

All five tests: cold_queries_are_stable_across_isolated_projects prepares identical source in two fresh projects, asserts equal query text, requires executed/body evidence and rejects /tmp/ and Id( tokens. configuration_selects_items_before_checking combines all(not(test),not(feature)), any() exclusion of a nonexistent module, and associated cfg(test)/not(test) functions; an included impl method calls the enabled function, while excluded bodies would be ill-typed. fixtures_ignore_caller_directory_and_workspace_defaults launches this test executable in two child processes with updating disabled: one from an unrelated directory and another from a separate workspace whose default crate contains compile_error. Each child runs two fixtures with identical logical filenames/item names but different literal/type expectations (u16 and bool), and the parent requires process success and '1 passed' to exclude accidentally selecting no tests. This directly exercises caller-directory/default-member independence, fresh source isolation and stable snapshot paths. ordinary_library_disables_test_configuration and ordinary_library_disables_unselected_features each include an ill-typed body behind the forbidden cfg and require normal fixture success. Together these verify the two compilers see ordinary-library configuration rather than the enclosing test harness configuration. All ten implementation associations and each claim qualification are accounted for; no concrete defect or requested edit found.

Browse crates anchors

139 anchors

Specification anchors and declared coverage
AnchorImplementationTests
crates (139)114 Implemented37 TODO2 N/A74 Implemented107 TODO
crates.sage_inspector (15)13 Implemented1 TODO2 N/A3 Implemented15 TODO
crates.sage_inspector.inspection (15)13 Implemented1 TODO2 N/A3 Implemented15 TODO
balanced_tracesImplementedTODO
canonical_ownershipImplementedImplementedTODO
derive_reflectionImplementedImplementedTODO
detail_free_indexImplementedTODO
deterministic_traceImplementedTODO
durable_navigationN/ATODO
generic_browserN/ATODO
owned_reflectionImplementedImplementedTODO
product_availabilityImplementedTODO
revision_and_demandImplementedTODO
semantic_phase_boundaryImplementedTODO
source_evidenceImplementedTODO
typed_serviceImplementedTODO
unknown_workImplementedTODOTODO
workspace_actorImplementedTODO
crates.sage_ir (90)67 Implemented34 TODO40 Implemented88 TODO
crates.sage_ir.checking (12)12 Implemented3 TODO5 Implemented12 TODO
crates.sage_ir.checking.body (5)5 Implemented2 TODO3 Implemented5 TODO
elaborationImplementedImplementedTODO
expected_typesImplementedTODOTODO
interface_dependenciesImplementedImplementedTODO
isolated_completionImplementedImplementedTODO
operator_callsImplementedTODOTODO
identity_mintingImplementedTODO
owned_productsImplementedImplementedTODO
crates.sage_ir.checking.signature (4)4 Implemented1 TODO1 Implemented4 TODO
body_independenceImplementedTODO
narrow_detailImplementedTODOTODO
owner_binderImplementedImplementedTODO
storageImplementedTODO
symbol_keyed_interfacesImplementedTODO
crates.sage_ir.crate (9)9 TODO9 TODO
explicit_restrictionsTODOTODO
identity_before_detailTODOTODO
incremental_evidenceTODOTODO
narrow_demandsTODOTODO
reexecution_and_invalidationTODOTODO
represented_completenessTODOTODO
restrictions_and_gapsTODOTODO
semantic_query_boundariesTODOTODO
terminal_incompletenessTODOTODO
crates.sage_ir.inference (8)8 Implemented6 Implemented8 TODO
atomic_checkingImplementedImplementedTODO
body_local_quiescenceImplementedImplementedTODO
canonical_boundaryImplementedImplementedTODO
completed_body_boundaryImplementedTODO
numeric_domainsImplementedImplementedTODO
subtyping_and_coercionImplementedImplementedTODO
terminal_obligationsImplementedTODO
transaction_isolationImplementedImplementedTODO
crates.sage_ir.metadata (4)4 Implemented1 TODO4 TODO
explicit_incompletenessImplementedTODO
keyed_reuseImplementedTODOTODO
product_boundariesImplementedTODO
provider_authorityImplementedTODO
crates.sage_ir.modules (8)7 Implemented1 TODO4 Implemented8 TODO
crates.sage_ir.modules.expand (4)4 Implemented2 Implemented4 TODO
completenessImplementedImplementedTODO
dependenciesImplementedTODO
direct_membersImplementedTODO
recursion_and_fixpointImplementedImplementedTODO
crates.sage_ir.modules.parse (4)3 Implemented1 TODO2 Implemented4 TODO
dependenciesImplementedTODO
detail_firewallImplementedImplementedTODO
recovery_completenessTODOTODO
syntax_identitiesImplementedImplementedTODO
crates.sage_ir.resolution (5)5 Implemented1 TODO3 Implemented4 TODO
crates.sage_ir.resolution.lookup (5)5 Implemented1 TODO3 Implemented4 TODO
completenessImplementedTODOImplementedTODO
dependenciesImplementedTODO
expansion_import_ambiguityImplementedImplemented
identity_onlyImplementedTODO
precedenceImplementedImplementedTODO
crates.sage_ir.solver (9)7 Implemented7 TODO5 Implemented9 TODO
alternative_isolationImplementedTODOImplementedTODO
bounded_completenessImplementedTODOTODO
candidate_completenessImplementedTODO
canonical_cyclesTODOTODO
canonical_outputsImplementedImplementedTODO
local_index_firewallTODOTODO
normalization_demandImplementedTODOImplementedTODO
schedule_independenceImplementedTODOImplementedTODO
shared_final_resultImplementedTODOImplementedTODO
crates.sage_ir.symbols (8)8 Implemented4 Implemented7 TODO
associated_identityImplementedImplemented
associated_interfacesImplementedTODO
body_interfacesImplementedImplementedTODO
definition_identityImplementedTODO
external_fact_queriesImplementedTODO
external_identityImplementedTODO
kind_wrappersImplementedImplementedTODO
local_identityImplementedImplementedTODO
crates.sage_ir.types (27)16 Implemented12 TODO13 Implemented27 TODO
crates.sage_ir.types.aliases (2)1 Implemented1 TODO1 Implemented2 TODO
identityImplementedImplementedTODO
revelationTODOTODO
crates.sage_ir.types.binder (1)1 Implemented1 TODO1 Implemented1 TODO
owner_parametersImplementedTODOImplementedTODO
crates.sage_ir.types.body (13)4 Implemented9 TODO3 Implemented13 TODO
awaitTODOTODO
closuresTODOTODO
conditional_patternsTODOTODO
coroutinesTODOTODO
diagnosed_recoveryImplementedImplementedTODO
elaboratedTODOImplementedTODO
for_iterationTODOTODO
indexingTODOTODO
macro_expansionTODOTODO
no_inferenceImplementedImplementedTODO
resolved_referencesImplementedTODO
try_residualTODOTODO
typed_provenanceImplementedTODO
crates.sage_ir.types.calls (2)1 Implemented1 TODO1 Implemented2 TODO
dispatch_familiesTODOTODO
selected_semanticsImplementedImplementedTODO
crates.sage_ir.types.lifetimes (2)2 Implemented2 Implemented2 TODO
dummyImplementedImplementedTODO
unchecked_borrowsImplementedImplementedTODO
crates.sage_ir.types.operators (2)2 Implemented1 Implemented2 TODO
lazy_control_flowImplementedTODO
trait_callsImplementedImplementedTODO
scoped_identitiesImplementedTODO
crates.sage_ir.types.spans (4)4 Implemented4 Implemented4 TODO
generated_identityImplementedImplementedTODO
item_originImplementedImplementedTODO
offset_reuseImplementedImplementedTODO
relative_compositionImplementedImplementedTODO
crates.sage_oracle_harness (4)4 Implemented2 TODO1 Implemented4 TODO
crates.sage_oracle_harness.crate (4)4 Implemented2 TODO1 Implemented4 TODO
deterministic_emissionImplementedTODO
exact_comparisonImplementedTODOImplementedTODO
fixed_projectionImplementedTODO
independent_coverageImplementedTODOTODO
crates.sage_stash (5)5 Implemented5 Implemented
crates.sage_stash.storage (5)5 Implemented5 Implemented
handle_ownershipImplementedImplemented
immutable_entriesImplementedImplemented
query_valueImplementedImplemented
rooted_equalityImplementedImplemented
typed_interningImplementedImplemented
crates.sage_test_harness (25)25 Implemented25 Implemented
crates.sage_test_harness.compile_tests (25)25 Implemented25 Implemented
annotation_validationImplementedImplemented
blessing_gateImplementedImplemented
callsite_updatesImplementedImplemented
checking_scopeImplementedImplemented
compiler_conditionsImplementedImplemented
completed_typesImplementedImplemented
coordinatesImplementedImplemented
dependenciesImplementedImplemented
diagnostic_countsImplementedImplemented
diagnostic_locationsImplementedImplemented
editionImplementedImplemented
fixturesImplementedImplemented
grouped_observationsImplementedImplemented
invocationImplementedImplemented
production_executionImplementedImplemented
project_isolationImplementedImplemented
query_captureImplementedImplemented
query_projectionImplementedImplemented
renderingImplementedImplemented
resolved_symbolsImplementedImplemented
review_visibilityImplementedImplemented
rustc_executionImplementedImplemented
rustc_lintsImplementedImplemented
starting_expressionsImplementedImplemented
target_lineImplementedImplemented