qua 0.74.0

Structure-aware query CLI for the Quarb engine
//! The command reads its arguments as the system gives them. On
//! Unix they are bytes: a file's name need not be UTF-8, and the
//! path of such a file is a path all the same.

#![cfg(unix)]

use std::ffi::OsStr;
use std::os::unix::ffi::OsStrExt;
use std::process::{Command, Stdio};

/// Until 0.73 the command read every argument as text before
/// anything else, to see whether the first was `man`, and the
/// runtime's reading panics on bytes that are no UTF-8
/// (`called Result::unwrap() on an Err value: "caf\xE9.json"`, exit
/// 101). The first argument is still looked at as text, lossily;
/// the paths go to the parser as they came.
#[test]
fn a_path_that_is_no_utf8_is_read() {
    let dir = std::env::temp_dir().join(format!("qua-arguments-{}", std::process::id()));
    std::fs::create_dir_all(&dir).unwrap();
    let path = dir.join(OsStr::from_bytes(b"caf\xe9.json"));
    std::fs::write(&path, r#"{"a": 1}"#).unwrap();
    let out = Command::new(env!("CARGO_BIN_EXE_qua"))
        .arg("/a::")
        .arg(&path)
        .stdin(Stdio::null())
        .output()
        .unwrap();
    let err = String::from_utf8_lossy(&out.stderr);
    assert!(!err.contains("panicked"), "{err}");
    assert!(out.status.success(), "{err}");
    assert_eq!(out.stdout, b"1\n", "{err}");
    std::fs::remove_dir_all(&dir).ok();
}