mirror of
https://github.com/ProjectLeonida/mandy.git
synced 2026-12-06 18:38:36 +00:00
The unit tests of settings_line could only fail on main by not building. This one runs the built binary on a title that does not exist, with two LEONIDA_ settings, one a folder, and reads its log: on main there is no settings line and it fails by assertion; with the change the line names both settings and shows the folder only by its length.
30 lines
1.2 KiB
Rust
30 lines
1.2 KiB
Rust
use std::path::Path;
|
|
use std::process::Command;
|
|
|
|
/// `leonida run` says in its log what it was started with, folders shown only by length.
|
|
#[test]
|
|
fn a_run_logs_the_settings_it_starts_with() {
|
|
let missing = Path::new(env!("CARGO_MANIFEST_DIR")).join("no-such-title.exe");
|
|
assert!(!missing.exists());
|
|
let mut command = Command::new(env!("CARGO_BIN_EXE_leonida"));
|
|
// Only the settings this test sets.
|
|
for (name, _) in std::env::vars() {
|
|
if name.starts_with("LEONIDA_") || name.starts_with(concat!("VIC", "TORY_")) {
|
|
command.env_remove(name);
|
|
}
|
|
}
|
|
let output = command
|
|
.env("NO_COLOR", "1")
|
|
.env("LEONIDA_TEST_KEYS", "5:Enter,10-20:W")
|
|
.env("LEONIDA_TEST_FOLDER", r"C:\Users\someone\folder")
|
|
.arg("run")
|
|
.arg(&missing)
|
|
.output()
|
|
.unwrap();
|
|
let stderr = String::from_utf8_lossy(&output.stderr);
|
|
let line = stderr.lines().find(|l| l.contains("LEONIDA_ settings")).unwrap_or_else(|| panic!("no settings line:\n{stderr}"));
|
|
assert!(line.contains("LEONIDA_TEST_KEYS=5:Enter,10-20:W"), "{line}");
|
|
assert!(line.contains("LEONIDA_TEST_FOLDER=<hidden, 23 chars>"), "{line}");
|
|
assert!(!stderr.contains("someone"), "a folder reached the log:\n{stderr}");
|
|
}
|