kit

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

commit b0b93cc1caf3e43f8dfc363912764803e9c9dd25
parent 484bda40cbd5795ea697cb19404e6da34e33888d
Author: Ryan Sepassi <rsepassi@gmail.com>
Date:   Thu, 18 Jun 2026 02:36:15 -0700

test: expand build coordinator smoke coverage

Diffstat:
Mtest/buildcoord/run.sh | 113++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 112 insertions(+), 1 deletion(-)

diff --git a/test/buildcoord/run.sh b/test/buildcoord/run.sh @@ -26,10 +26,18 @@ mkdir -p "$ws/recipes" "$ws/src" "$store" cat > "$ws/BUILD.kit" <<'EOF' kit-build 1 +[target //absent:probe] +recipe recipes/absent.sh [target //app:bundle] recipe recipes/app.sh +[target //argv:echo] +recipe recipes/argv.sh [target //lib:data] recipe recipes/lib.sh +[target //needargv:probe] +recipe recipes/needargv.sh +[target //recipe:stamp] +recipe recipes/recipe.sh EOF cat > "$ws/src/a.txt" <<'EOF' @@ -59,7 +67,40 @@ done > "$KIT_BUILD_OUT/sources.txt" cat "$lib_dir/lib.txt" > "$KIT_BUILD_OUT/lib.txt" printf '%s\n' "$KIT_BUILD_TARGET" > "$KIT_BUILD_OUT/target.txt" EOF -chmod +x "$ws/recipes/app.sh" "$ws/recipes/lib.sh" + +cat > "$ws/recipes/absent.sh" <<'EOF' +#!/bin/sh +set -eu +mkdir -p "$KIT_BUILD_OUT" +if p=$("$KIT" build source src/optional.txt 2>/dev/null); then + cat "$p" > "$KIT_BUILD_OUT/optional.txt" +else + printf 'absent\n' > "$KIT_BUILD_OUT/optional.txt" +fi +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/needargv.sh" <<'EOF' +#!/bin/sh +set -eu +mkdir -p "$KIT_BUILD_OUT" +dep_dir=$("$KIT" build need --arg dep-one --arg dep-two //argv:echo) +cat "$dep_dir/args.txt" > "$KIT_BUILD_OUT/dep-args.txt" +EOF + +cat > "$ws/recipes/recipe.sh" <<'EOF' +#!/bin/sh +set -eu +mkdir -p "$KIT_BUILD_OUT" +printf 'recipe:v1\n' > "$KIT_BUILD_OUT/stamp.txt" +EOF +chmod +x "$ws"/recipes/*.sh run_build() { name=$1 @@ -69,6 +110,16 @@ run_build() { > "$work/$name.out" 2> "$work/$name.err" } +build_assert_ok() { + name=$1 + shift + if run_build "$name" "$@"; then + ok "$name" + else + not_ok "$name" "$work/$name.err" + fi +} + tree_path_from() { awk 'NF >= 2 {print $2; exit}' "$1" } @@ -137,5 +188,65 @@ run_fail "buildcoord-missing-target-fails" \ contains "buildcoord-missing-target-diag" "$work/buildcoord-missing-target-fails.err" \ "build failed" +run_fail "buildcoord-helper-outside-recipe-fails" \ + "$KIT" build --store "$store" --root "$ws" --def BUILD.kit glob 'src/*.txt' +contains "buildcoord-helper-outside-recipe-diag" \ + "$work/buildcoord-helper-outside-recipe-fails.err" "unexpected argument" + +build_assert_ok buildcoord-absent-cold //absent:probe +absent_path=$(tree_path_from "$work/buildcoord-absent-cold.out") +contains "buildcoord-absent-cold-output" "$absent_path/optional.txt" "absent" +cat > "$ws/src/optional.txt" <<'EOF' +present +EOF +build_assert_ok buildcoord-absent-created //absent:probe +present_path=$(tree_path_from "$work/buildcoord-absent-created.out") +contains "buildcoord-absent-created-output" "$present_path/optional.txt" "present" +if [ "$present_path" != "$absent_path" ]; then + ok "buildcoord-absent-created-new-tree" +else + printf 'unchanged tree path=%s\n' "$present_path" > "$work/absent-tree.diag" + not_ok "buildcoord-absent-created-new-tree" "$work/absent-tree.diag" +fi + +build_assert_ok buildcoord-argv-top --arg one --arg two //argv:echo +argv_path=$(tree_path_from "$work/buildcoord-argv-top.out") +contains "buildcoord-argv-top-one" "$argv_path/args.txt" "one" +contains "buildcoord-argv-top-two" "$argv_path/args.txt" "two" +build_assert_ok buildcoord-argv-changed --arg three //argv:echo +argv_changed_path=$(tree_path_from "$work/buildcoord-argv-changed.out") +contains "buildcoord-argv-changed-output" "$argv_changed_path/args.txt" "three" +if [ "$argv_changed_path" != "$argv_path" ]; then + ok "buildcoord-argv-changed-new-tree" +else + printf 'unchanged tree path=%s\n' "$argv_changed_path" > "$work/argv-tree.diag" + not_ok "buildcoord-argv-changed-new-tree" "$work/argv-tree.diag" +fi + +build_assert_ok buildcoord-need-argv //needargv:probe +need_argv_path=$(tree_path_from "$work/buildcoord-need-argv.out") +contains "buildcoord-need-argv-one" "$need_argv_path/dep-args.txt" "dep-one" +contains "buildcoord-need-argv-two" "$need_argv_path/dep-args.txt" "dep-two" + +build_assert_ok buildcoord-recipe-v1 //recipe:stamp +recipe_v1_path=$(tree_path_from "$work/buildcoord-recipe-v1.out") +contains "buildcoord-recipe-v1-output" "$recipe_v1_path/stamp.txt" "recipe:v1" +cat > "$ws/recipes/recipe.sh" <<'EOF' +#!/bin/sh +set -eu +mkdir -p "$KIT_BUILD_OUT" +printf 'recipe:v2\n' > "$KIT_BUILD_OUT/stamp.txt" +EOF +chmod +x "$ws/recipes/recipe.sh" +build_assert_ok buildcoord-recipe-v2 //recipe:stamp +recipe_v2_path=$(tree_path_from "$work/buildcoord-recipe-v2.out") +contains "buildcoord-recipe-v2-output" "$recipe_v2_path/stamp.txt" "recipe:v2" +if [ "$recipe_v2_path" != "$recipe_v1_path" ]; then + ok "buildcoord-recipe-edit-new-tree" +else + printf 'unchanged tree path=%s\n' "$recipe_v2_path" > "$work/recipe-tree.diag" + not_ok "buildcoord-recipe-edit-new-tree" "$work/recipe-tree.diag" +fi + kit_summary "buildcoord" kit_exit