mirror of
https://github.com/Felitendo/spotifast.git
synced 2026-11-01 09:23:26 +01:00
The log file, stderr and the panic log are set up by fastframe-log with Spotifast's own default filters and paths, replacing the env_logger set-up, its tee to the log file, and the panic hook. Behaviour changes: - A panic's line in panic.log now keeps its message with any link removed, on the same line as the location (`... on thread "main", panic at src/x.rs:1:2: message`), where it used to write the raw message, which could quote a URL with a token. The default hook is no longer chained, so the raw message and the backtrace hint are not printed to stderr either; the same redacted line is. - Log lines read `[time LEVEL target] message`, with the level no longer padded or coloured on a terminal. - The start line says `Starting spotifast <version> on <os> (<arch>)`, lowercase, and a log file that cannot be created is reported through the log (on stderr) instead of a bare message.
36 lines
1.2 KiB
Rust
36 lines
1.2 KiB
Rust
#![cfg(all(target_os = "linux", feature = "demo"))]
|
|
|
|
use std::process::Command;
|
|
|
|
#[test]
|
|
fn an_unavailable_display_leaves_a_useful_log_without_a_console() {
|
|
let directory = std::env::temp_dir().join(format!(
|
|
"spotifast-startup-diagnostics-{:016x}",
|
|
rand::random::<u64>()
|
|
));
|
|
std::fs::create_dir(&directory).unwrap();
|
|
let output = Command::new(env!("CARGO_BIN_EXE_spotifast"))
|
|
.args(["--demo", "--demo-shot"])
|
|
.arg(directory.join("unused.png"))
|
|
.arg("--demo-data")
|
|
.arg(&directory)
|
|
.env_remove("RUST_LOG")
|
|
.env("DISPLAY", "")
|
|
.env("WAYLAND_DISPLAY", "missing-display")
|
|
.env("XDG_RUNTIME_DIR", &directory)
|
|
.output()
|
|
.unwrap();
|
|
let log = std::fs::read_to_string(directory.join("state/spotifast.log")).unwrap();
|
|
std::fs::remove_dir_all(directory).unwrap();
|
|
|
|
assert!(!output.status.success(), "the unavailable display opened");
|
|
assert!(
|
|
log.contains(&format!("Starting spotifast {}", env!("CARGO_PKG_VERSION"))),
|
|
"missing startup identity: {log}"
|
|
);
|
|
assert!(
|
|
log.contains("Native window failed:"),
|
|
"missing error: {log}"
|
|
);
|
|
}
|