zinzen 0.3.0

Algorithm for auto-scheduling time-constrained tasks on a timeline
//! Regenerate `expected.json` snapshots for all stable fixtures.
//!
//! Run: `cargo run --bin regen_snapshots`

use std::fs;
use std::path::Path;

use scheduler::run_scheduler;
use scheduler::technical::input_output::{self, Input};

fn main() {
    let fixtures_dir = Path::new("./tests/jsons/stable");
    let mut updated = 0;

    for entry in fs::read_dir(fixtures_dir).expect("stable fixtures dir") {
        let path = entry.expect("dir entry").path();
        let input_path = path.join("input.json");
        if !path.is_dir() || !input_path.exists() {
            continue;
        }

        let input: Input =
            input_output::get_input_from_json(&input_path).expect("fixture input should load");
        let output = run_scheduler(&input).expect("scheduler should succeed");
        let json = serde_json::to_string_pretty(&output).expect("serialize output");
        let expected_path = path.join("expected.json");
        fs::write(&expected_path, json).expect("write expected.json");
        println!("updated {}", path.display());
        updated += 1;
    }

    println!("regenerated {updated} fixtures");
}