Your browser sucks, JavaScript disabled! Gunnar's console needs JavaScript and WebAssembly. Git over SSH on port 2222 does not.

nordisk/holger

crates/holger-monetize-guest/tests/the_build_reference.rs

//! **The plugin is holger's own build**: `build.rs` stamps the module with the commit it was
//! built from, what holger-server-lib stamps. (The proto test went with the guest's network
//! half in monetize v2.0 P2 12.5 and T13: the guest compiles no proto and calls no holger RPC.)

use std::path::Path;

use holger_monetize_guest::{BUILD_REF, PRODUCT};

#[test]
fn the_stamp_is_this_checkouts_commit() {
    assert_eq!(PRODUCT, "holger");
    // HOLGER_BUILD_REF overrides the stamp on purpose (a build with no .git);
    // otherwise it is HEAD's short hash, exactly what holger-server-lib stamps.
    let repo = Path::new(env!("CARGO_MANIFEST_DIR")).join("../..");
    if std::env::var_os("HOLGER_BUILD_REF").is_some() || !repo.join(".git").exists() {
        return;
    }
    assert_eq!(
        BUILD_REF.len(),
        7,
        "a 7-hex short hash, as HOLGER_GIT_HASH: {BUILD_REF:?}"
    );
    assert!(
        BUILD_REF.chars().all(|c| c.is_ascii_hexdigit()),
        "{BUILD_REF:?}"
    );
}