Merge main into the fixture branch
Keeps both halves of the Cargo.toml conflict: the reference_scenarios bench from this branch and the dev profile from main.
This commit is contained in:
commit
3331531d4a
14 files changed
+1108
-80
No files matched your search
@@ -0,0 +1,65 @@
|
||||
//! The recipe's density fallback is reported, not silent.
|
||||
//!
|
||||
//! [`recipes::default_density`] returns NRLMSISE-00 inside the measured space weather
|
||||
//! record and Harris-Priester outside it. That is a real change of physics, so it is
|
||||
//! logged at warning level. This lives in its own integration test because installing a
|
||||
//! logger is process-wide and each test file is its own binary, so nothing else is
|
||||
//! disturbed by it.
|
||||
//!
|
||||
//! What the resolved force list says is covered by unit tests in `recipes`; this covers
|
||||
//! only that the warning reaches a logger, which those cannot see.
|
||||
|
||||
// There is no fallback to report without NRLMSISE-00 in the build, so the whole file
|
||||
// compiles away rather than leaving an unused logger behind.
|
||||
#![cfg(feature = "msis")]
|
||||
|
||||
use astrokit::prelude::*;
|
||||
use log::{Metadata, Record};
|
||||
use std::sync::{Mutex, OnceLock};
|
||||
|
||||
static LINES: OnceLock<Mutex<Vec<String>>> = OnceLock::new();
|
||||
|
||||
struct Collect;
|
||||
|
||||
impl log::Log for Collect {
|
||||
fn enabled(&self, _: &Metadata) -> bool {
|
||||
true
|
||||
}
|
||||
fn log(&self, record: &Record) {
|
||||
LINES
|
||||
.get_or_init(Default::default)
|
||||
.lock()
|
||||
.expect("the collector is not poisoned")
|
||||
.push(format!("{} {}", record.level(), record.args()));
|
||||
}
|
||||
fn flush(&self) {}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_falling_back_to_the_fixed_profile_is_logged() {
|
||||
log::set_boxed_logger(Box::new(Collect)).expect("no other logger in this binary");
|
||||
log::set_max_level(log::LevelFilter::Trace);
|
||||
|
||||
// Inside the record: the measured model, and nothing to report.
|
||||
let covered = Epoch::from_gregorian_utc_hms(2026, 1, 1, 0, 0, 0);
|
||||
let _ = Regime::LowEarth.forces(Fidelity::Balanced, covered);
|
||||
assert!(
|
||||
LINES
|
||||
.get_or_init(Default::default)
|
||||
.lock()
|
||||
.unwrap()
|
||||
.is_empty(),
|
||||
"an epoch inside the record should say nothing"
|
||||
);
|
||||
|
||||
// Far enough ahead to stay outside it however fresh the embedded drivers become.
|
||||
let distant = Epoch::from_gregorian_utc_hms(2100, 1, 1, 0, 0, 0);
|
||||
let _ = Regime::LowEarth.forces(Fidelity::Balanced, distant);
|
||||
|
||||
let lines = LINES.get_or_init(Default::default).lock().unwrap().clone();
|
||||
assert_eq!(lines.len(), 1, "exactly one warning expected: {lines:?}");
|
||||
assert!(lines[0].starts_with("WARN"), "{}", lines[0]);
|
||||
// It has to name both models, or it does not tell the reader what changed.
|
||||
assert!(lines[0].contains("NRLMSISE-00"), "{}", lines[0]);
|
||||
assert!(lines[0].contains("Harris-Priester"), "{}", lines[0]);
|
||||
}
|
||||
Reference in new issue
Block a user