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

nordisk/nornir

xtask/tests/demo_goes_the_container_road.rs

//! **`cargo xtask demo-wasm` / `deploy-pages` go the container road** (THE LAW: a
//! build thing builds in a container or a KVM, never on the host).
//!
//! Until 2026-09-30 they called `nornir_pages::demo_wasm(&cfg())`, which ran HOST
//! `cargo build --target wasm32…` and the HOST's wasm-bindgen. Now they hand edda
//! nornir's declaration and a row name, and edda builds that row in the pinned image.
//! nornir declares no demo row yet (the set is pinned to the five matrix atoms), so
//! the verbs are REFUSED BY NAME — held here, without an engine.

use std::path::PathBuf;

fn root() -> PathBuf {
    PathBuf::from(env!("CARGO_MANIFEST_DIR")).parent().unwrap().to_path_buf()
}

#[test]
fn the_verbs_hand_edda_the_declaration_not_a_host_build() {
    let src = std::fs::read_to_string(root().join("xtask/src/main.rs")).unwrap();
    assert!(!src.contains("nornir_pages::demo_wasm(&cfg())"), "the host-road call is back");
    assert!(!src.contains("nornir_pages::deploy_pages(&cfg())"), "the host-road call is back");
    assert!(src.contains("nornir_pages::demo_wasm(&cfg(), &set, DEMO_VARIANT)"));
    assert!(src.contains("nornir_pages::deploy_pages(&cfg(), &set, DEMO_VARIANT)"));
}

#[test]
fn without_a_declared_demo_row_the_demo_is_refused_by_name() {
    let set = nornir_build_thing::BuildVariantSet::discover(&root())
        .expect("read .nornir/build-variants.toml")
        .expect("nornir declares a set");
    let cfg = nornir_pages::PagesConfig {
        demo_crate: "nornir-demo",
        canvas_id: "demo_canvas",
        state_export: "__nornir_state",
        title: "nornir — live web demo",
        description: "d",
        pages_url: "https://nordisk.codeberg.page/nornir",
        pages_host: "nordisk.codeberg.page",
        pages_branch: "pages",
        remote_env: "NORNIR_PAGES_REMOTE",
        commit_label: "nornir live web demo",
        extra_build_args: &[],
        workspace_root: root(),
    };
    match nornir_pages::demo_row(&cfg, &set, "nornir-demo-wasm") {
        // The day the owner declares the row, this arm is what holds: the row's
        // cell must produce what the page imports.
        Ok((row, dist)) => assert!(dist.starts_with(root()) && row.name == "nornir-demo-wasm"),
        Err(e) => assert!(e.to_string().contains("nornir-demo-wasm"), "refused without naming the row: {e}"),
    }
}