kit

kit
git clone https://git.ryansepassi.com/git/kit.git
Log | Files | Refs | README

commit d8ba4d9aca807f9af346621a85ea7ebef62a1898
parent af964d3659842b90e2f7aa868fd3f6051f366a8a
Author: Ryan Sepassi <rsepassi@gmail.com>
Date:   Thu, 18 Jun 2026 15:39:30 -0700

Add tier1 build coordinator kitchen test

Diffstat:
Mmk/test.mk | 4++++
Atest/tier1/system/buildcoord-kitchen.sh | 226+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 230 insertions(+), 0 deletions(-)

diff --git a/mk/test.mk b/mk/test.mk @@ -209,6 +209,7 @@ TIER1_TEST_TARGETS = \ test-t1-harness \ test-t1-build \ test-t1-driver \ + test-t1-build-coord \ test-t1-core-api \ test-t1-pp \ test-t1-c-front \ @@ -251,6 +252,9 @@ test-t1-build: test-t1-driver: @$(T1_LOG) driver env KIT=$(abspath $(BIN)) sh test/tier1/system/driver-kitchen.sh +test-t1-build-coord: bin + @$(T1_LOG) build-coord env KIT=$(abspath $(BIN)) sh test/tier1/system/buildcoord-kitchen.sh + test-t1-core-api: @$(T1_LOG) core-api $(MAKE) --no-print-directory test-hash test-cas-api test-release-index test-abi-classify diff --git a/test/tier1/system/buildcoord-kitchen.sh b/test/tier1/system/buildcoord-kitchen.sh @@ -0,0 +1,226 @@ +#!/bin/sh +# Coarse Tier 1 kitchen-sink smoke for the build coordinator driver path. + +set -u + +script_dir=$(cd "$(dirname "$0")" && pwd) +repo_root=$(cd "$script_dir/../../.." && pwd) +KIT="${KIT:-$repo_root/build/kit}" + +if [ ! -x "$KIT" ]; then + echo "buildcoord-kitchen: kit binary not found at $KIT" >&2 + exit 2 +fi + +work=$(mktemp -d "${TMPDIR:-/tmp}/kit-t1-buildcoord.XXXXXX") +trap 'rm -rf "$work"' EXIT + +KIT_KIT_DIR="$repo_root/test/lib" +. "$repo_root/test/lib/kit_sh_kit.sh" +kit_report_init + +ws="$work/ws" +store="$work/store" +mkdir -p "$ws/recipes" "$ws/src" "$store" + +cat > "$ws/BUILD.kit" <<'EOF' +kit-build 1 +[target //app:bundle] +recipe recipes/app.sh +[target //argv:echo] +recipe recipes/argv.sh +[target //fail:probe] +recipe recipes/fail.sh +[target //lib:data] +recipe recipes/lib.sh +[target //test:pass] +recipe recipes/test_pass.sh +EOF + +cat > "$ws/src/a.txt" <<'EOF' +alpha +EOF +cat > "$ws/src/b.txt" <<'EOF' +beta +EOF + +cat > "$ws/recipes/lib.sh" <<'EOF' +#!/bin/sh +set -eu +mkdir -p "$KIT_BUILD_OUT" +flavor=$("$KIT" build config-get flavor || true) +printf 'lib:%s\n' "$flavor" > "$KIT_BUILD_OUT/lib.txt" +EOF + +cat > "$ws/recipes/argv.sh" <<'EOF' +#!/bin/sh +set -eu +mkdir -p "$KIT_BUILD_OUT" +printf '%s\n' "$@" > "$KIT_BUILD_OUT/args.txt" +EOF + +cat > "$ws/recipes/app.sh" <<'EOF' +#!/bin/sh +set -eu +mkdir -p "$KIT_BUILD_OUT" +mode=$("$KIT" build config-get mode || true) +printf 'mode:%s\n' "$mode" > "$KIT_BUILD_OUT/mode.txt" +printf '%s\n' "$KIT_BUILD_TARGET" > "$KIT_BUILD_OUT/target.txt" +info=$("$KIT" build source --format id-path src/a.txt) +printf '%s\n' "$info" > "$KIT_BUILD_OUT/source-info.txt" +cat "${info#* }" > "$KIT_BUILD_OUT/a.txt" +for p in $("$KIT" build glob 'src/*.txt'); do + cat "$("$KIT" build source "$p")" +done > "$KIT_BUILD_OUT/sources.txt" +dep_dir=$("$KIT" build need --config flavor=dep //lib:data) +cat "$dep_dir/lib.txt" > "$KIT_BUILD_OUT/lib.txt" +tok=$("$KIT" build need-submit //argv:echo -- async one) +async_dir=$("$KIT" build need-await "$tok") +cat "$async_dir/args.txt" > "$KIT_BUILD_OUT/async.txt" +EOF + +cat > "$ws/recipes/test_pass.sh" <<'EOF' +#!/bin/sh +set -eu +mkdir -p "$KIT_BUILD_OUT" +"$KIT" build source src/a.txt >/dev/null +printf 'test-artifact\n' > "$KIT_BUILD_OUT/result.txt" +printf 'test-stdout\n' +printf 'test-stderr\n' >&2 +EOF + +cat > "$ws/recipes/fail.sh" <<'EOF' +#!/bin/sh +set -eu +exit 9 +EOF + +chmod +x "$ws"/recipes/*.sh + +run_build() { + name=$1 + shift + "$KIT" build --store "$store" --root "$ws" --def BUILD.kit \ + --config "env.KIT=$KIT" "$@" \ + > "$work/$name.out" 2> "$work/$name.err" +} + +run_test() { + name=$1 + shift + "$KIT" build test --store "$store" --root "$ws" --def BUILD.kit \ + --config "env.KIT=$KIT" "$@" \ + > "$work/$name.out" 2> "$work/$name.err" +} + +build_ok() { + name=$1 + shift + if run_build "$name" "$@"; then + ok "$name" + else + not_ok "$name" "$work/$name.err" + fi +} + +test_pass() { + name=$1 + shift + if run_test "$name" "$@" && + awk 'NR == 1 && $1 == "PASS" {ok = 1} END {exit ok ? 0 : 1}' \ + "$work/$name.out"; then + ok "$name" + else + if [ -s "$work/$name.err" ]; then + not_ok "$name" "$work/$name.err" + else + not_ok "$name" "$work/$name.out" + fi + fi +} + +tree_path_from() { + awk 'NF >= 2 {print $2; exit}' "$1" +} + +test_tree_path_from() { + awk 'NF >= 3 {print $3; exit}' "$1" +} + +first_field_from() { + awk 'NF >= 1 {print $1; exit}' "$1" +} + +second_field_from() { + awk 'NF >= 2 {print $2; exit}' "$1" +} + +build_ok buildcoord-kitchen-cold --stats --config mode=debug //app:bundle +contains buildcoord-kitchen-cold-runs "$work/buildcoord-kitchen-cold.err" \ + "recipes_run=3" +cold_path=$(tree_path_from "$work/buildcoord-kitchen-cold.out") +contains buildcoord-kitchen-source-a "$cold_path/a.txt" "alpha" +contains buildcoord-kitchen-glob-a "$cold_path/sources.txt" "alpha" +contains buildcoord-kitchen-glob-b "$cold_path/sources.txt" "beta" +contains buildcoord-kitchen-config "$cold_path/mode.txt" "mode:debug" +contains buildcoord-kitchen-target "$cold_path/target.txt" "//app:bundle" +contains buildcoord-kitchen-need "$cold_path/lib.txt" "lib:dep" +contains buildcoord-kitchen-submit-await "$cold_path/async.txt" "async" +source_id=$(first_field_from "$cold_path/source-info.txt") +source_path=$(second_field_from "$cold_path/source-info.txt") +if [ ${#source_id} -eq 64 ] && [ -f "$source_path" ]; then + ok buildcoord-kitchen-source-format +else + printf 'id=%s\npath=%s\n' "$source_id" "$source_path" \ + > "$work/buildcoord-kitchen-source-format.diag" + not_ok buildcoord-kitchen-source-format \ + "$work/buildcoord-kitchen-source-format.diag" +fi + +build_ok buildcoord-kitchen-cache --stats --config mode=debug //app:bundle +contains buildcoord-kitchen-cache-hit "$work/buildcoord-kitchen-cache.err" \ + "deep_hits=1" +contains buildcoord-kitchen-cache-no-run "$work/buildcoord-kitchen-cache.err" \ + "recipes_run=0" +cache_path=$(tree_path_from "$work/buildcoord-kitchen-cache.out") +if [ "$cache_path" = "$cold_path" ]; then + ok buildcoord-kitchen-cache-reuses-tree +else + printf 'cold=%s\ncache=%s\n' "$cold_path" "$cache_path" \ + > "$work/buildcoord-kitchen-cache-reuses-tree.diag" + not_ok buildcoord-kitchen-cache-reuses-tree \ + "$work/buildcoord-kitchen-cache-reuses-tree.diag" +fi + +cat > "$ws/src/b.txt" <<'EOF' +beta2 +EOF +build_ok buildcoord-kitchen-input-change --stats --config mode=debug \ + //app:bundle +changed_path=$(tree_path_from "$work/buildcoord-kitchen-input-change.out") +contains buildcoord-kitchen-input-change-visible "$changed_path/sources.txt" \ + "beta2" + +test_pass buildcoord-kitchen-test-cold --stats //test:pass +contains buildcoord-kitchen-test-run "$work/buildcoord-kitchen-test-cold.err" \ + "test_runs=1" +test_path=$(test_tree_path_from "$work/buildcoord-kitchen-test-cold.out") +contains buildcoord-kitchen-test-artifact "$test_path/result.txt" \ + "test-artifact" +contains buildcoord-kitchen-test-stdout "$test_path/stdout" "test-stdout" +contains buildcoord-kitchen-test-stderr "$test_path/stderr" "test-stderr" + +test_pass buildcoord-kitchen-test-cache --stats //test:pass +contains buildcoord-kitchen-test-cache-hit \ + "$work/buildcoord-kitchen-test-cache.err" "test_cache_hits=1" +contains buildcoord-kitchen-test-cache-no-run \ + "$work/buildcoord-kitchen-test-cache.err" "test_runs=0" + +run_fail buildcoord-kitchen-failing-recipe \ + "$KIT" build --store "$store" --root "$ws" --def BUILD.kit \ + --config "env.KIT=$KIT" //fail:probe +contains buildcoord-kitchen-failing-recipe-diag \ + "$work/buildcoord-kitchen-failing-recipe.err" "build failed" + +kit_summary buildcoord-kitchen +kit_exit