#!/usr/bin/env bash # SPDX-License-Identifier: MIT # Rung 1: ay8910-python's tests, transcribed (tests/chip.rs, variants.rs, conformance.rs with # its 19 vendored conformance examples), and the save-state test; built and linted as CI does, # with and without the serde feature. Needs nothing but cargo: not the reference. set -euo pipefail ROOT=$(cd "$(dirname "$0")/.." && pwd) STABLE="$HOME/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin" [ -x "$STABLE/cargo" ] && PATH="$STABLE:$PATH" cd "$ROOT" cargo fmt --check || { echo "rung 1: FAIL (cargo fmt)"; exit 1; } nice cargo clippy --release -q --all-targets --features serde -- -D warnings || { echo "rung 1: FAIL (clippy)"; exit 1; } nice cargo clippy --release -q --lib --tests -- -D warnings || { echo "rung 1: FAIL (clippy, no serde)"; exit 1; } nice cargo test --release -q --tests >/dev/null 2>&1 || { echo "rung 1: FAIL (cargo test, no serde)"; exit 1; } out=$(nice cargo test --release -q --features serde --tests 2>&1) || { echo "$out"; echo "rung 1: FAIL"; exit 1; } echo "$out" | grep -E "^test result" || true passed=$(echo "$out" | grep -oE '[0-9]+ passed' | awk '{n+=$1} END{print n}') examples=$(ls tests/conformance/*.json | wc -l) echo "rung 1: PASS ($passed test functions; the $examples conformance examples traced identically)"