plushie/testing/tree_hash

Structural tree hash for regression testing.

Computes a SHA-256 hash of the serialized UI tree and compares against golden files. Works on all backends.

On first run, creates a .sha256 file. On subsequent runs, compares the current hash against the stored one. Set PLUSHIE_UPDATE_SNAPSHOTS=1 to force-update golden files.

Types

A tree hash result.

pub type TreeHash {
  TreeHash(name: String, hash: String)
}

Constructors

  • TreeHash(name: String, hash: String)

Values

pub fn assert_tree_hash(
  tree: node.Node,
  name: String,
  path: String,
) -> Nil

Assert that a tree hash matches its golden file.

If no golden file exists, creates one (first run). If PLUSHIE_UPDATE_SNAPSHOTS=1 is set, updates the golden file. Otherwise compares hashes and panics on mismatch.

pub fn hash(tree: node.Node) -> String

Compute a SHA-256 hash of the given tree’s canonical JSON form.

Search Document