test: use nextest and shorten weekly survival test

Co-Authored-By: GitHub Copilot <noreply@github.com>
This commit is contained in:
Steve Biedermann 2026-10-13 19:12:55 +02:00
parent db23f87450
commit e5dc752b41
2 changed files with 13 additions and 2 deletions

View File

@ -10,5 +10,9 @@ stop:
admin: admin:
docker compose exec -T app cat /data/admin-password docker compose exec -T app cat /data/admin-password
test:
if ! cargo nextest --version >/dev/null 2>&1; then cargo install cargo-nextest --locked; fi
cargo nextest run --workspace
dev: dev:
SHARD_DATABASE_URL="sqlite://sim-shard-{shard}.db?mode=rwc" cargo run SHARD_DATABASE_URL="sqlite://sim-shard-{shard}.db?mode=rwc" cargo run

View File

@ -3736,7 +3736,7 @@ mod tests {
} }
/// The default script at the size of the original single village, for long-running tests. /// The default script at the size of the original single village, for long-running tests.
fn village_script() -> SimScript { fn village_script_source() -> String {
let source = [ let source = [
("WIDTH", "96"), ("WIDTH", "96"),
("HEIGHT", "64"), ("HEIGHT", "64"),
@ -3757,6 +3757,11 @@ mod tests {
.fold(DEFAULT_SCRIPT.to_string(), |source, (name, value)| { .fold(DEFAULT_SCRIPT.to_string(), |source, (name, value)| {
with_constant(&source, name, value) with_constant(&source, name, value)
}); });
source
}
fn village_script() -> SimScript {
let source = village_script_source();
SimScript::load(&source).unwrap() SimScript::load(&source).unwrap()
} }
@ -4326,7 +4331,9 @@ mod tests {
#[test] #[test]
fn village_survives_until_its_first_weekly_birth_check() { fn village_survives_until_its_first_weekly_birth_check() {
let mut world = World::new_with_script(42, village_script()); let script = with_constant(&village_script_source(), "TICKS_PER_DAY", "240");
let script = SimScript::load(&script).unwrap();
let mut world = World::new_with_script(42, script);
let first_week_tick = let first_week_tick =
world.calendar.ticks_per_day * u64::from(world.calendar.days_per_week); world.calendar.ticks_per_day * u64::from(world.calendar.days_per_week);
let mut daily = Vec::new(); let mut daily = Vec::new();