artifactize-core 0.27.0

The library behind artifactize: Artifacts, evals, reviews, the monitor and review models, and the shared operations every interface calls.
Documentation
use super::*;
use std::fs;

#[test]
fn runtime_evidence_requires_a_regular_completion_marker() {
    let state = crate::test_os::tempdir();
    let run = state.path().join("runs/run-1");
    fs::create_dir_all(&run).unwrap();
    let capture = run.join("runtime.stdout");
    fs::write(&capture, "output\n").unwrap();
    let marker = run.join("runtime.stdout.complete");
    let view = crate::test_request::request(
        "app/check",
        "RUNNING",
        serde_json::json!({"runDir": platform::path_text(&run)}),
    );
    let inspect = || {
        excerpt(
            state.path(),
            Some(&view),
            true,
            Stream::Stdout,
            &LogQuery::default(),
        )
    };
    let evidence = || {
        let excerpt = inspect().unwrap();
        assert_eq!(excerpt.lines[0].text, "output");
        excerpt.evidence
    };
    assert!(matches!(evidence(), Evidence::Partial));
    let outside = state.path().join("outside");
    fs::write(&outside, "").unwrap();
    crate::test_os::file_link(&outside, &marker);
    assert!(matches!(evidence(), Evidence::Partial));
    crate::test_os::remove_file_link(&marker);
    fs::write(marker, "").unwrap();
    assert!(matches!(evidence(), Evidence::Complete));

    fs::remove_file(&capture).unwrap();
    assert!(matches!(inspect().unwrap().evidence, Evidence::Missing));
    crate::test_os::file_link(&outside, &capture);
    assert!(
        inspect().is_err(),
        "a linked capture must not expose its target"
    );
}