#[cfg(unix)]
use std::fs;
#[cfg(unix)]
use tempfile::tempdir;
#[cfg(unix)]
use super::{CLEAN, run_in_os, status_of, stderr_of, stdout_of};
#[cfg(unix)]
#[test]
fn a_non_utf8_path_argument_exits_error() {
use std::{ffi::OsString, os::unix::ffi::OsStringExt};
let dir = tempdir().expect("create temporary directory");
fs::write(dir.path().join("clean.md"), CLEAN).expect("write fixture");
let invalid = OsString::from_vec(b"bad\xff.md".to_vec());
let output = run_in_os(
dir.path(),
&[
OsString::from("--check"),
OsString::from("clean.md"),
invalid,
],
);
assert_eq!(
status_of(&output),
2,
"a non-UTF-8 argument must exit 2, stderr: {}",
stderr_of(&output)
);
assert!(
stderr_of(&output).contains("UTF-8"),
"the error must name the problem: {}",
stderr_of(&output)
);
assert_eq!(
stdout_of(&output),
"",
"no file may be reported from a run that could not resolve its inputs"
);
}