Something went wrong. Try again.
small gleam coding and persistent agent daemon with a detachable cli and a canvas ui forked from okami.mom/albedo
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475#!/usr/bin/env bash# Run every property suite with fresh seeds and a large budget until a time# budget runs out (robot-docs/testing.md#discovery-runs). Not part of test.sh.## test/discovery.sh [seconds] [cases]## Each round draws one seed and runs every suite under# ALBEDO_PROPERTY_SEED=<seed> ALBEDO_PROPERTY_CASES=<cases>, so a failure's log# names the seed that reproduces it. Logs and a summary go under# ${ALBEDO_DISCOVERY_DIR:-/tmp/albedo-discovery}/<start time>/. Run it inside# `nix develop`. Turn each confirmed failure into a named regression test and a# fix, as robot-docs/writing-tests.md describes.set -uo pipefailcd "$(dirname "$0")/.."budget="${1:-3600}"cases="${2:-2000}"out="${ALBEDO_DISCOVERY_DIR:-/tmp/albedo-discovery}/$(date +%Y%m%d-%H%M%S)"mkdir -p "$out"summary="$out/summary.txt"export ALBEDO_NO_BROWSER=1export ALBEDO_TEST_TMP="$out/scratch"export PYTHONPYCACHEPREFIX="$out/pycache"export ALBEDO_PROPERTY_CASES="$cases"
# Python modules, Go packages, and web scripts that hold properties.mapfile -t python_suites < <(grep -l hypothesis_profiles test/harness/*_test.py e2e/*_test.py 2>/dev/null)mapfile -t go_packages < <(grep -rl 'albedo/cli/internal/property"' cli --include='*_test.go' | xargs -r -n1 dirname | sort -u | sed 's|^cli/|./|')
mapfile -t web_suites < <(grep -l "from './property.mjs'" web/scripts/*.test.mjs 2>/dev/null)
suites=(gleam packages contracts rust photon)[[ $(uname -s) == Linux ]] && suites+=(heic)((${#web_suites[@]})) && suites+=(web)((${#python_suites[@]})) && suites+=(python)((${#go_packages[@]})) && suites+=(go)
run_suite() { case "$1" in gleam) (cd apps/albedo && gleam test) ;; packages) test/packages.sh test ;; contracts) python3 test/contract/run.py ;; rust) cargo test --quiet --release --locked --manifest-path native/render/Cargo.toml ;; python) python3 test/python_test_runner.py --jobs 4 "${python_suites[@]}" ;; go) go -C cli test -count=1 "${go_packages[@]}" ;; heic) env PYTHONPATH=test "$ALBEDO_PHOTON_TEST_PYTHON" tools/photon/test/normalize_heic_test.py ;; photon) node --test tools/photon/test/*.test.mjs ;; web) node --test "${web_suites[@]}" ;; esac}
echo "discovery: ${budget}s, ${cases} cases per property, suites: ${suites[*]}" | tee "$summary"echo "logs: $out" | tee -a "$summary"deadline=$((SECONDS + budget))round=0failures=0while ((SECONDS < deadline)); do round=$((round + 1)) seed=$(od -An -N4 -tu4 /dev/urandom | tr -d ' ') export ALBEDO_PROPERTY_SEED="$seed" for suite in "${suites[@]}"; do ((SECONDS < deadline)) || break log="$out/$suite-$seed.log" started=$SECONDS if run_suite "$suite" >"$log" 2>&1; then echo "ok round $round $suite seed=$seed ($((SECONDS - started))s)" | tee -a "$summary" rm -f "$log" else failures=$((failures + 1)) echo "FAILED round $round $suite seed=$seed ($((SECONDS - started))s) $log" | tee -a "$summary" fi donedoneecho "discovery: $round rounds, $failures failures" | tee -a "$summary"((failures == 0))