geolith-cli 0.4.2

Rust vector tile generator — OSM + Overture Maps → protomaps PMTiles
Documentation
#![allow(clippy::unwrap_used)] // tests and benches may unwrap (AGENTS.md).

//! The release and bench profiles must unwind on a panic.
//!
//! `catch_unwind` guards (`geometry::guard`, `mlt::encode_tile`), mutex
//! poisoning errors and thread-join errors all need unwinding. With
//! `panic = "abort"` they do nothing in a release binary while every test
//! (the test profile always unwinds) still passes. Cargo ignores `panic` in
//! the test profile, so this test reads the manifest instead.

use std::path::Path;

/// The lines of the `[profile.<name>]` table of the workspace manifest.
fn profile_lines(manifest: &str, name: &str) -> Vec<String> {
    let header = format!("[profile.{name}]");
    manifest
        .lines()
        .skip_while(|l| l.trim() != header)
        .skip(1)
        .take_while(|l| !l.trim_start().starts_with('['))
        .map(|l| l.trim().to_owned())
        .collect()
}

#[test]
fn no_profile_sets_panic_abort() {
    let manifest =
        std::fs::read_to_string(Path::new(env!("CARGO_MANIFEST_DIR")).join("../Cargo.toml"))
            .unwrap();
    let release = profile_lines(&manifest, "release");
    assert!(
        release.iter().any(|l| l.starts_with("lto")),
        "the release table was found: {release:?}"
    );
    for name in ["release", "bench", "dev", "test"] {
        let abort = profile_lines(&manifest, name)
            .into_iter()
            .any(|l| l.replace(' ', "") == "panic=\"abort\"");
        assert!(!abort, "[profile.{name}] sets panic = \"abort\"");
    }
}