[fix](trx-config): keep the generated example off the machine that made it
CI / lint (pull_request) Successful in 2m17s
CI / frontend (pull_request) Successful in 3m28s
CI / reuse (pull_request) Successful in 3s
CI / lint (push) Successful in 2m16s
CI / test (pull_request) Successful in 7m50s
CI / frontend (push) Successful in 4m11s
CI / reuse (push) Successful in 9s
CI / test (push) Failing after 17m15s
CI / lint (pull_request) Successful in 2m17s
CI / frontend (pull_request) Successful in 3m28s
CI / reuse (pull_request) Successful in 3s
CI / lint (push) Successful in 2m16s
CI / test (pull_request) Successful in 7m50s
CI / frontend (push) Successful in 4m11s
CI / reuse (push) Successful in 9s
CI / test (push) Failing after 17m15s
The example is generated from the config defaults, and [decode_logs].dir defaults to the running user's cache directory. So the file rendered /Users/sjg/Library/Caches/trx-rs/decoders on the machine that generated it and /root/.cache/trx-rs/decoders in CI, and the up-to-date test failed for everyone but its author. Pin dir to an illustrative /var/lib/trx-rs/decoders in the example config; omitting the key still falls back to the per-user directory. A new test asserts the rendered example contains none of this machine's home, cache or config directories, so the next environment-derived default cannot slip through the same way. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SyX26FCpMQxiBoC7r5K1A7 Signed-off-by: Stan Grams <sjg@haxx.space>
This commit was merged in pull request #48.
This commit is contained in:
@@ -63,7 +63,8 @@ const SECTION_COMMENTS: &[(&str, &str)] = &[
|
||||
(
|
||||
"trx-server.decoders",
|
||||
"Which decoders run. Trimming this list saves real CPU on small boxes.\n\
|
||||
Valid names: aprs, aprs_hf, ais, cw, ft2, ft4, ft8, lrpt, sstv, vdes, wefax, wspr.",
|
||||
Valid names: aprs, aprs_hf, ais, cw, ft2, ft4, ft8, lrpt, sstv, vdes, wefax, wspr.\n\
|
||||
output_dir sets where sstv/wefax/lrpt write images (default: user cache dir).",
|
||||
),
|
||||
(
|
||||
"trx-server.pskreporter",
|
||||
@@ -232,6 +233,25 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
/// Nothing in the example may be derived from the machine that generated
|
||||
/// it: [decode_logs].dir defaults to the running user's cache directory,
|
||||
/// which made the generated file differ between a developer's laptop and
|
||||
/// CI, and the up-to-date test fail for everyone but its author.
|
||||
#[test]
|
||||
fn test_example_has_no_machine_specific_paths() {
|
||||
let example = combined_example();
|
||||
for dir in [dirs::home_dir(), dirs::cache_dir(), dirs::config_dir()]
|
||||
.into_iter()
|
||||
.flatten()
|
||||
{
|
||||
let dir = dir.to_string_lossy().into_owned();
|
||||
assert!(
|
||||
!example.contains(&dir),
|
||||
"the example contains this machine's {dir}; pin the value in example_config()"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_example_loads_and_validates() {
|
||||
let mut file = tempfile::NamedTempFile::new().unwrap();
|
||||
|
||||
@@ -755,7 +755,14 @@ impl ServerConfig {
|
||||
audio: AudioConfig::default(),
|
||||
pskreporter: PskReporterConfig::default(),
|
||||
aprsfi: AprsFiConfig::default(),
|
||||
decode_logs: DecodeLogsConfig::default(),
|
||||
decode_logs: DecodeLogsConfig {
|
||||
// Pinned rather than defaulted: the default is derived from the
|
||||
// running user's cache directory, which would make the generated
|
||||
// example differ from machine to machine. Omitting the key
|
||||
// falls back to that per-user directory.
|
||||
dir: "/var/lib/trx-rs/decoders".to_string(),
|
||||
..DecodeLogsConfig::default()
|
||||
},
|
||||
decoders: DecodersConfig::default(),
|
||||
sdr: SdrConfig::default(),
|
||||
timeouts: TimeoutsConfig::default(),
|
||||
|
||||
+2
-1
@@ -86,7 +86,7 @@ beacon_symbol_code = "-"
|
||||
# Write decodes to JSON Lines files.
|
||||
[trx-server.decode_logs]
|
||||
enabled = false
|
||||
dir = "/Users/sjg/Library/Caches/trx-rs/decoders"
|
||||
dir = "/var/lib/trx-rs/decoders"
|
||||
aprs_file = "TRXRS-APRS-%YYYY%-%MM%-%DD%.log"
|
||||
cw_file = "TRXRS-CW-%YYYY%-%MM%-%DD%.log"
|
||||
ft8_file = "TRXRS-FT8-%YYYY%-%MM%-%DD%.log"
|
||||
@@ -95,6 +95,7 @@ wefax_file = "TRXRS-WEFAX-%YYYY%-%MM%-%DD%.log"
|
||||
|
||||
# Which decoders run. Trimming this list saves real CPU on small boxes.
|
||||
# Valid names: aprs, aprs_hf, ais, cw, ft2, ft4, ft8, lrpt, sstv, vdes, wefax, wspr.
|
||||
# output_dir sets where sstv/wefax/lrpt write images (default: user cache dir).
|
||||
[trx-server.decoders]
|
||||
enabled = [
|
||||
"aprs",
|
||||
|
||||
Reference in New Issue
Block a user