M3a review finding 7, for the other three roles. loopd keeps its config path as a path; bxctl and inferproxy take text arguments and answer one that is not UTF-8 with their usage. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
37 lines
996 B
Rust
37 lines
996 B
Rust
//! A config path that is not UTF-8 is read as a path, not a panic (M3a review finding 7).
|
|
|
|
use std::ffi::OsStr;
|
|
use std::os::unix::ffi::OsStrExt;
|
|
use std::process::Command;
|
|
|
|
#[test]
|
|
fn a_config_path_that_is_not_utf8_is_read_as_a_path() {
|
|
let path = std::env::temp_dir().join(OsStr::from_bytes(b"loopd-missing-\xff.toml"));
|
|
let out = Command::new(env!("CARGO_BIN_EXE_loopd"))
|
|
.args([
|
|
OsStr::new("selftest"),
|
|
OsStr::new("--config"),
|
|
path.as_os_str(),
|
|
])
|
|
.output()
|
|
.unwrap();
|
|
assert_eq!(
|
|
out.status.code(),
|
|
Some(1),
|
|
"a config error, not a panic (101)"
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn a_flag_that_is_not_utf8_is_a_usage_error() {
|
|
let out = Command::new(env!("CARGO_BIN_EXE_loopd"))
|
|
.args([
|
|
OsStr::from_bytes(b"serve\xff"),
|
|
OsStr::new("--config"),
|
|
OsStr::new("x"),
|
|
])
|
|
.output()
|
|
.unwrap();
|
|
assert_eq!(out.status.code(), Some(2));
|
|
}
|