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::*;

#[test]
fn state_and_output_creation_refuse_other_current_or_legacy_workspaces() {
    for marker in [
        "index.artf",
        "artifactize.json",
        ".artifactizeignore",
        "file.txt.artf",
    ] {
        let root = crate::test_os::tempdir();
        let reviewed = root.path().join("reviewed");
        let other = root.path().join("other");
        std::fs::create_dir(&reviewed).unwrap();
        std::fs::create_dir(&other).unwrap();
        std::fs::write(other.join(marker), "marker").unwrap();
        let state = other.join("state");
        let error = prepare_directory(&state, &reviewed).unwrap_err();
        assert!(
            error.to_string().contains("outside artifactize workspaces"),
            "{marker}: {error}"
        );
        assert!(!state.exists());
    }
}

#[test]
fn workspace_marker_scan_refuses_an_unlistable_ancestor() {
    // Unix root can enumerate a search-only directory regardless of its mode.
    #[cfg(unix)]
    if crate::test_os::current_uid() == 0 {
        return;
    }
    let root = crate::test_os::tempdir();
    let reviewed = root.path().join("reviewed");
    let other = root.path().join("other");
    std::fs::create_dir(&reviewed).unwrap();
    std::fs::create_dir(&other).unwrap();
    std::fs::write(other.join("file.txt.artf"), "marker").unwrap();
    let _permissions = crate::test_os::SearchOnlyDirectory::new(&other);
    let state = other.join("state");
    let error = prepare_directory(&state, &reviewed).unwrap_err();
    assert_eq!(error.kind(), io::ErrorKind::PermissionDenied);
    assert!(
        error
            .to_string()
            .contains("Cannot inspect workspace markers"),
        "{error}"
    );
    assert!(!state.exists());
}