artifactize-tools 0.27.0

Portable scoped tools and safe file access for artifactize.
Documentation
use super::*;
use std::os::unix::process::ExitStatusExt;

/// A Unix wait status holds a normal exit's code in bits 8–15.
const EXIT_CODE_SHIFT: i32 = 8;

/// An exit status with `code`, in the wait-status encoding `from_raw` takes.
fn exited(code: i32) -> ExitStatus {
    ExitStatus::from_raw(code << EXIT_CODE_SHIFT)
}

#[test]
fn wsl_explorer_status_counts_as_opened_only_on_wsl() {
    assert!(opened(&exited(0), false));
    assert!(opened(&exited(0), true));
    assert!(opened(&exited(4), true));
    assert!(!opened(&exited(4), false));
    for code in [1, 2, 3] {
        assert!(!opened(&exited(code), true));
    }
}