From 2a39179d10060bf7976b2be501c1b4066f3e78ab Mon Sep 17 00:00:00 2001 From: "melodic-automation-lanes[bot]" <337595936+melodic-automation-lanes[bot]@users.noreply.github.com> Date: Wed, 28 Oct 2026 22:09:02 +0000 Subject: [PATCH] Resolve issue #8757 Lane-Activity: work-resolve-issue/resolve-issue --- scripts/affected-tests.sh | 25 +++++++++-- scripts/affected-tests.test.sh | 23 ++++++++++ scripts/check-affected.sh | 39 +++++++++++----- scripts/check-affected.test.sh | 13 ++++++ scripts/run-plugin-tests.sh | 76 ++++++++++++++++++++++++++++++-- scripts/run-plugin-tests.test.sh | 41 +++++++++++++++++ 6 files changed, 198 insertions(+), 19 deletions(-) diff --git a/scripts/affected-tests.sh b/scripts/affected-tests.sh index 2a6efb3ccce..2e1c42837e4 100755 --- a/scripts/affected-tests.sh +++ b/scripts/affected-tests.sh @@ -11,6 +11,9 @@ # scripts/affected-tests.sh list the suites covering the diff vs the base ref # scripts/affected-tests.sh --run ... and run them, sequentially # scripts/affected-tests.sh --run --jobs N ... N shell suites at a time +# scripts/affected-tests.sh --run --budget S ... timed against an S-second budget, a +# suite over its share failing (run-plugin-tests.sh +# BUDGET) # scripts/affected-tests.sh --run --write-not-run FILE # ... and write each selected suite it did not run # to FILE, one per line (exit 3 names them); a @@ -260,6 +263,8 @@ replay_range="" against_ref="" not_run_file="" jobs=1 +budget="" +budget_given=0 # Whether --shard was SUPPLIED, tracked apart from its value: `--shard=` with an # empty right-hand side is what an unset environment variable produces, and it # must not read as "no shard requested" and run everything on every leg. @@ -312,6 +317,13 @@ while [[ $# -gt 0 ]]; do shift ;; --jobs=*) jobs="${1#--jobs=}" ;; + --budget) + need_value "$1" $# "${2:-}" "seconds, a positive integer" + budget="$2" + budget_given=1 + shift + ;; + --budget=*) budget="${1#--budget=}" budget_given=1 ;; --base) need_value "$1" $# "${2:-}" "a ref" base_ref="$2" @@ -367,6 +379,10 @@ if [[ ! "$jobs" =~ ^[1-9][0-9]*$ ]]; then echo "error: --jobs wants a positive integer; got: $jobs" >&2 exit 2 fi +if [[ "$budget_given" -eq 1 && ! "$budget" =~ ^[1-9][0-9]*$ ]]; then + echo "error: --budget wants a positive number of seconds; got: $budget" >&2 + exit 2 +fi if [[ "$shard_given" -eq 1 ]] && ! parse_shard "$shard_spec"; then echo "error: --shard wants / with total >= 1 and 0 <= index < total; got: $shard_spec" >&2 exit 2 @@ -1597,7 +1613,8 @@ fi # per-suite print lock and scripts/run-plugin-tests-serial.txt, the suites that # must never overlap anything. Three is the proven ceiling on a 4-vCPU runner: # at four, suites failed by producing empty output from an external command -# (#3694). +# (#3694). --budget S hands the selection there too, at any job count, since +# that runner times each suite against its share. # # Only *.test.sh is executable HERE. The other three ecosystems are run by their # own lanes, with invocations this script cannot derive from a suite path @@ -1625,11 +1642,11 @@ if venv_bin=$(pytest_python::venv_bin); then fi failed=0 -if [[ ${#runnable[@]} -gt 0 ]] && [[ "$jobs" -gt 1 ]]; then - echo "Running ${#runnable[@]} selected shell suite(s) across up to $jobs job(s)." >&2 +if [[ ${#runnable[@]} -gt 0 ]] && [[ "$jobs" -gt 1 || -n "$budget" ]]; then + echo "Running ${#runnable[@]} selected shell suite(s) across up to $jobs job(s)${budget:+ within a ${budget}s budget}." >&2 list="$WORK_DIR/selection.txt" printf '%s\n' "${runnable[@]}" >"$list" - bash "$SCRIPT_DIR/run-plugin-tests.sh" --jobs "$jobs" --suites-from "$list" || failed=1 + bash "$SCRIPT_DIR/run-plugin-tests.sh" --jobs "$jobs" ${budget:+--budget "$budget"} --suites-from "$list" || failed=1 elif [[ ${#runnable[@]} -gt 0 ]]; then echo "Running ${#runnable[@]} selected shell suite(s) sequentially." >&2 n=0 diff --git a/scripts/affected-tests.test.sh b/scripts/affected-tests.test.sh index 27ae45ff63c..db91ab04b31 100755 --- a/scripts/affected-tests.test.sh +++ b/scripts/affected-tests.test.sh @@ -630,6 +630,29 @@ for bad in 0 x '' -1; do fi done +# --budget hands the selection to run-plugin-tests.sh even at one job, since +# that runner owns the per-suite share. +out="$(cd "$repo" && MARKER_FILE="$marker" bash scripts/affected-tests.sh --run --budget 600 lib/widget.sh 2>&1)" +RC=$? +if [[ "$RC" -eq 0 ]] && contains "$out" 'within a 600s budget' && contains "$out" 's of the 600s budget.'; then + ok "--run --budget 600 runs the selection through run-plugin-tests.sh against the budget" +else + fail "--run --budget 600 did not run the selection against the budget (rc=$RC): $out" +fi +for bad in 0 x -1 '' '='; do + if [[ "$bad" == = ]]; then + (cd "$repo" && bash scripts/affected-tests.sh --run --budget= lib/widget.sh >/dev/null 2>&1) + else + (cd "$repo" && bash scripts/affected-tests.sh --run --budget "$bad" lib/widget.sh >/dev/null 2>&1) + fi + RC=$? + if [[ "$RC" -eq 2 ]]; then + ok "--budget '$bad' is a usage error (rc=2)" + else + fail "--budget '$bad' should exit 2, got rc=$RC" + fi +done + # --- --shard is a partition, not a filter ----------------------------------- # The claim CI makes when it fans one selection across four runners is that the # legs together ARE the selection and no suite ran twice. Proved on the fixture diff --git a/scripts/check-affected.sh b/scripts/check-affected.sh index d6385534d6b..7ab3326e720 100755 --- a/scripts/check-affected.sh +++ b/scripts/check-affected.sh @@ -7,7 +7,13 @@ # scripts/check-affected.sh --tests ... and scripts/affected-tests.sh --run # scripts/check-affected.sh --jobs N run up to N selected shell suites at # once (default: $CHECK_AFFECTED_JOBS, -# else one less than the core count) +# else one less than the core count, +# at most 3) +# scripts/check-affected.sh --budget S time the selected shell suites against +# an S-second budget (default: +# $CHECK_AFFECTED_BUDGET, else 120); a +# suite over its share fails +# (scripts/run-plugin-tests.sh BUDGET) # scripts/check-affected.sh --base diff against (default: origin/main) # scripts/check-affected.sh --no-fetch skip refreshing before the # stale-base check @@ -56,7 +62,8 @@ # modes the pull_request run uses # - changed-skills: scripts/check-changed-skills.sh , when a skill # file changed -# - tests (--tests): scripts/affected-tests.sh --run --base , after +# - tests (--tests): scripts/affected-tests.sh --run --jobs +# --budget --base , after # scripts/setup-env.sh --node installs any missing or # stale locked npm packages, then the selected Node # suites of scripts/outside-node-packages.txt through @@ -93,18 +100,22 @@ set -uo pipefail usage() { - echo "usage: $(basename "$0") [--tests] [--jobs N] [--base ] [--no-fetch] [--uncommitted]" >&2 + echo "usage: $(basename "$0") [--tests] [--jobs N] [--budget S] [--base ] [--no-fetch] [--uncommitted]" >&2 exit 2 } run_tests=0 # The selected suites run through run-plugin-tests.sh's job pool, which keeps # the suites in scripts/run-plugin-tests-serial.txt off the parallel group. -# One less than the core count: on a 4-vCPU runner, 3 is the proven ceiling -# (scripts/affected-tests.sh, #3694). -cores="$(nproc 2>/dev/null || echo 2)" -jobs="${CHECK_AFFECTED_JOBS:-$((cores > 1 ? cores - 1 : 1))}" +# One less than the core count, at most 3: on a 4-vCPU runner, 3 is the proven +# ceiling, and suites failed at 4 (scripts/affected-tests.sh, #3694). +cores="$(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 2)" +[[ "$cores" =~ ^[1-9][0-9]*$ ]] || cores=2 +jobs=$((cores > 4 ? 3 : cores > 1 ? cores - 1 : 1)) +jobs="${CHECK_AFFECTED_JOBS:-$jobs}" [[ "$jobs" =~ ^[1-9][0-9]*$ ]] || jobs=1 +budget="${CHECK_AFFECTED_BUDGET:-120}" +[[ "$budget" =~ ^[1-9][0-9]*$ ]] || budget=120 fetch=1 uncommitted=0 base= @@ -119,6 +130,12 @@ while (($#)); do shift ;; --jobs=*) jobs="${1#--jobs=}" ;; + --budget) + [[ $# -ge 2 ]] || usage + budget="$2" + shift + ;; + --budget=*) budget="${1#--budget=}" ;; --base) [[ $# -ge 2 && -n "$2" ]] || usage base="$2" @@ -129,7 +146,7 @@ while (($#)); do esac shift done -[[ "$jobs" =~ ^[1-9][0-9]*$ ]] || usage +[[ "$jobs" =~ ^[1-9][0-9]*$ && "$budget" =~ ^[1-9][0-9]*$ ]] || usage tools="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)" || exit 2 top="$(git -C "${CHECK_DATA_ROOT:-$tools}" rev-parse --show-toplevel 2>/dev/null)" || { @@ -193,7 +210,7 @@ if ((uncommitted)); then # A shallow clone's boundary, so history walks stop where the clone does. [[ ! -f "$shallow" ]] || cp "$shallow" "$snap/tree/.git/shallow" || exit 2 git -C "$snap/tree" -c core.hooksPath=/dev/null checkout --quiet --detach "$commit" || exit 2 - args=(--base "$base" --no-fetch --jobs "$jobs") + args=(--base "$base" --no-fetch --jobs "$jobs" --budget "$budget") ((run_tests)) && args+=(--tests) # A snapshot of this tree's own work tree is no foreign code, so the inner # run's tests run here, where the selector reads the same uncommitted edits. @@ -616,7 +633,7 @@ elif ((run_tests)); then local -a pkgs=() exclusions=() node=() unrun=() # Suites run only when the data tree is this tree, so CHECK_DATA_ROOT adds nothing here, and a suite # that inherits it points its checkers at the real tree instead of its fixtures. - env -u CHECK_DATA_ROOT "$tools/scripts/affected-tests.sh" --run --jobs "$jobs" --base "$base" --write-not-run "$out.not-run" || rc=$? + env -u CHECK_DATA_ROOT "$tools/scripts/affected-tests.sh" --run --jobs "$jobs" --budget "$budget" --base "$base" --write-not-run "$out.not-run" || rc=$? ((rc == 3)) || return "$rc" # shellcheck source=lib/read-list.sh . "$tools/scripts/lib/read-list.sh" && @@ -664,7 +681,7 @@ elif ((run_tests)); then if ((npm_failed)); then skip tests "npm dependencies did not install" else - run_check tests "scripts/affected-tests.sh --run --jobs $jobs --base $base" affected + run_check tests "scripts/affected-tests.sh --run --jobs $jobs --budget $budget --base $base" affected fi fi diff --git a/scripts/check-affected.test.sh b/scripts/check-affected.test.sh index cf8a11ea1f0..f866cf74de1 100755 --- a/scripts/check-affected.test.sh +++ b/scripts/check-affected.test.sh @@ -36,6 +36,7 @@ done cat >"$repo/scripts/affected-tests.sh" <<'STUB' #!/usr/bin/env bash echo "affected-tests ran" >&2 +[[ -z "${STUB_ARGS_LOG:-}" ]] || printf '%s\n' "$*" >"$STUB_ARGS_LOG" [[ -z "${STUB_ENV_LOG:-}" ]] || printf '%s' "${CHECK_DATA_ROOT-unset}" >"$STUB_ENV_LOG" # The real selector diffs its own tree's work tree, so the stub logs that. [[ -z "${STUB_STATUS_LOG:-}" ]] || git -C "$(dirname "$0")/.." status --porcelain --untracked-files=all >"$STUB_STATUS_LOG" @@ -225,6 +226,16 @@ check "a check that could not run is a skip, not a failure" \ run -- --base base --tests check "--tests runs the affected suites" '[[ $RC == 0 && $OUT == *"passed"* ]]' +# A passing check's output is not printed, so the stub logs its arguments. +args_log="$tmp/affected-args.log" +run -u CHECK_AFFECTED_JOBS -u CHECK_AFFECTED_BUDGET STUB_ARGS_LOG="$args_log" -- --base base --tests +check "--tests passes a default job count of at most 3 and the 120 s budget" \ + '[[ $RC == 0 && $(cat "$args_log") =~ ^"--run --jobs "[123]" --budget 120 " ]]' +run CHECK_AFFECTED_JOBS=5 CHECK_AFFECTED_BUDGET=300 STUB_ARGS_LOG="$args_log" -- --base base --tests +check "CHECK_AFFECTED_JOBS and CHECK_AFFECTED_BUDGET override the defaults" \ + '[[ $RC == 0 && $(cat "$args_log") == "--run --jobs 5 --budget 300 "* ]]' +run STUB_ARGS_LOG="$args_log" -- --base base --tests --budget 45 +check "--budget sets the budget passed to affected-tests" '[[ $RC == 0 && $(cat "$args_log") == *" --budget 45 "* ]]' run CHECK_DATA_ROOT="$repo" -- --base base --tests check "--tests keeps a caller's CHECK_DATA_ROOT from the suites" '[[ $RC == 0 && $ERR != *"saw CHECK_DATA_ROOT"* ]]' run STUB_AFFECTED_TESTS=3 STUB_NOT_RUN=$'eco/test_x.py\neco/X.Tests.ps1\n' -- --base base --tests @@ -551,6 +562,8 @@ run -- --bogus check "an unknown flag is a usage error" '[[ $RC == 2 ]]' run -- --jobs 0 check "a --jobs count below one is a usage error" '[[ $RC == 2 && $ERR == *"--jobs N"* ]]' +run -- --budget 0 +check "a --budget below one second is a usage error" '[[ $RC == 2 && $ERR == *"--budget S"* ]]' run -- --base no-such-ref check "an unresolvable base is exit 2" '[[ $RC == 2 && $ERR == *"merge-base"* ]]' diff --git a/scripts/run-plugin-tests.sh b/scripts/run-plugin-tests.sh index dbfac21094d..9fb344805aa 100755 --- a/scripts/run-plugin-tests.sh +++ b/scripts/run-plugin-tests.sh @@ -8,7 +8,7 @@ # affected-suite selector, not through a step of its own. # # scripts/run-plugin-tests.sh [--strict-skips] [--jobs N] [--root DIR] [--shard I/N] -# [--suites-from FILE] +# [--suites-from FILE] [--budget SECONDS] # scripts/run-plugin-tests.sh --list [--root DIR] # # Each test is self-contained and cwd-independent; an individual test SKIPs @@ -37,6 +37,17 @@ # suite never starts late and outlasts the rest of its leg; a suite the file # does not list counts 0 and keeps its sorted place after the listed ones. # +# BUDGET. --budget SECONDS is the wall clock the whole run aims to finish in, +# for the local affected-only run (scripts/check-affected.sh --tests). A run +# over it reports the overrun and its three slowest suites, and does not fail. +# Each suite gets a share, and a suite that takes longer than its share fails +# by name: the share is its scripts/suite-seconds.txt median times +# $PLUGIN_TEST_SHARE_MARGIN (default 3), and never less than +# $PLUGIN_TEST_SHARE_DEFAULT seconds (default 30), the share of a suite the file +# does not list. The medians are CI runner measurements, so the margin covers a +# slower host and a loaded job pool. Without --budget no suite is timed against +# anything, which is how CI runs. +# # SHARDING. --shard I/N keeps leg I of N of the sorted discovered suites, by # index modulo N, with scripts/affected-tests.sh's semantics: the union of legs # 0..N-1 is the whole corpus and no two legs share a suite, so N runners run it @@ -102,7 +113,7 @@ SECONDS_LIST="${PLUGIN_TEST_SECONDS_LIST:-$script_dir/suite-seconds.txt}" ADVISORY_LIST="${PLUGIN_TEST_ADVISORY_LIST:-$script_dir/run-plugin-tests-advisory.txt}" usage() { - echo "usage: run-plugin-tests.sh [--strict-skips] [--jobs N] [--root DIR] [--shard I/N] [--suites-from FILE] | --list [--root DIR]" >&2 + echo "usage: run-plugin-tests.sh [--strict-skips] [--jobs N] [--root DIR] [--shard I/N] [--suites-from FILE] [--budget SECONDS] | --list [--root DIR]" >&2 exit 2 } @@ -121,8 +132,8 @@ parse_shard() { } # --worker : internal. Runs ONE suite with its output captured -# under $PLUGIN_TEST_LOG_DIR, records its exit status beside the capture, then -# prints the whole block under the print lock. Reached only from the dispatch +# under $PLUGIN_TEST_LOG_DIR, records its exit status and wall seconds beside +# the capture, then prints the whole block under the print lock. Reached only from the dispatch # below; it exits 0 regardless of the suite's result so xargs never stops # early, and the summary reads the recorded status instead. # @@ -142,7 +153,9 @@ if [[ "${1:-}" == "--worker" ]]; then log="$log_dir/$key" rc=0 test_git_env::isolate "$log.gitconfig" || exit 2 + start=$SECONDS bash "$suite" >"$log.out" 2>&1 || rc=$? + printf '%s\n' "$((SECONDS - start))" >"$log.secs" printf '%s\n' "$rc" >"$log.rc" # noclobber opens the lock with O_EXCL inside bash itself. `mkdir` is not a # safe lock everywhere: uutils mkdir (Ubuntu 25.10+) lets two racers both @@ -164,10 +177,19 @@ jobs="${PLUGIN_TEST_JOBS:-1}" root="" shard_spec="0/1" suites_from="" +budget="" +budget_given=0 list=0 while (($# > 0)); do case "$1" in --strict-skips) strict_skips=1 ;; + --budget) + [[ $# -ge 2 ]] || usage + budget="$2" + budget_given=1 + shift + ;; + --budget=*) budget="${1#--budget=}" budget_given=1 ;; --list) list=1 ;; --suites-from) [[ $# -ge 2 ]] || usage @@ -200,6 +222,16 @@ if [[ ! "$jobs" =~ ^[1-9][0-9]*$ ]]; then echo "error: --jobs must be a positive integer (got '$jobs')" >&2 exit 2 fi +share_margin="${PLUGIN_TEST_SHARE_MARGIN:-3}" +share_default="${PLUGIN_TEST_SHARE_DEFAULT:-30}" +if ((budget_given)); then + for v in "--budget:$budget" "PLUGIN_TEST_SHARE_MARGIN:$share_margin" "PLUGIN_TEST_SHARE_DEFAULT:$share_default"; do + if [[ ! "${v#*:}" =~ ^[1-9][0-9]*$ ]]; then + echo "error: ${v%%:*} must be a positive integer (got '${v#*:}')" >&2 + exit 2 + fi + done +fi if ! parse_shard "$shard_spec"; then echo "error: --shard wants / with total >= 1 and 0 <= index < total (got '$shard_spec')" >&2 exit 2 @@ -319,6 +351,19 @@ if ((${#parallel_suites[@]} > 1)) && [[ -s "$SECONDS_LIST" ]]; then sort -s -t $'\t' -k1,1nr | cut -f2-) fi +# suite_share : its median times the margin, floored at the default. +declare -A median=() +if [[ -n "$budget" && -s "$SECONDS_LIST" ]]; then + while read -r path secs _; do + [[ "$path" == \#* || ! "$secs" =~ ^[0-9]+$ ]] || median["$path"]="$secs" + done <"$SECONDS_LIST" +fi +suite_share() { + local share=$((${median[$1]:-0} * share_margin)) + ((share > share_default)) || share="$share_default" + printf '%s' "$share" +} + log_dir="$(mktemp -d)" trap 'rm -rf "$log_dir"' EXIT export PLUGIN_TEST_LOG_DIR="$log_dir" @@ -338,6 +383,7 @@ if ((${#is_advisory[@]} > 0)); then echo "Advisory nonce: $advisory_nonce" fi +run_start=$SECONDS for t in ${serial_suites[@]+"${serial_suites[@]}"}; do bash "$runner" --worker "$t" done @@ -345,6 +391,7 @@ if [[ ${#parallel_suites[@]} -gt 0 ]]; then # xargs appends one indexed suite path after `--worker` per invocation. printf '%s\0' "${parallel_suites[@]}" | xargs -0 -n 1 -P "$jobs" bash "$runner" --worker fi +run_seconds=$((SECONDS - run_start)) # suite_annotate : one annotation titled by the # suite, so a log reader can group results by suite. Escapes follow actions/toolkit @@ -368,6 +415,7 @@ advisory_failed=0 total_optional_skips=0 total_discriminating_skips=0 skipped_suites=() +timings=() for i in "${!tests[@]}"; do t="${tests[$i]}" @@ -386,6 +434,16 @@ for i in "${!tests[@]}"; do suite_annotate error "$t" "$t failed (exit $rc)" failed=1 fi + if [[ -n "$budget" ]]; then + secs="$(<"$log.secs")" + timings+=("$secs"$'\t'"$t") + share="$(suite_share "$t")" + if ((secs > share)); then + echo "FAIL: $t took ${secs}s, over its ${share}s share of the budget" >&2 + suite_annotate error "$t" "$t took ${secs}s, over its ${share}s share of the budget" + failed=1 + fi + fi opt_skips="$(grep -c '^SKIP:' "$log.out" 2>/dev/null || true)" disc_skips="$(grep -c '^DISCRIMINATING SKIP:' "$log.out" 2>/dev/null || true)" total_optional_skips=$((total_optional_skips + opt_skips)) @@ -408,6 +466,16 @@ if ((${#skipped_suites[@]} > 0)); then done fi +if [[ -n "$budget" ]] && ((run_seconds > budget)); then + { + echo "OVER BUDGET: the suites took ${run_seconds}s, over the ${budget}s budget. Slowest:" + printf '%s\n' ${timings[@]+"${timings[@]}"} | sort -t $'\t' -k1,1nr | head -n 3 | + while IFS=$'\t' read -r secs t; do echo " ${secs}s $t"; done + } >&2 +elif [[ -n "$budget" ]]; then + echo "The suites took ${run_seconds}s of the ${budget}s budget." +fi + if ((total_discriminating_skips > 0)); then { echo "DISCRIMINATING SKIP(s) mean discriminating coverage did not run —" diff --git a/scripts/run-plugin-tests.test.sh b/scripts/run-plugin-tests.test.sh index 3f611f00ca5..de93c00fd0b 100755 --- a/scripts/run-plugin-tests.test.sh +++ b/scripts/run-plugin-tests.test.sh @@ -544,6 +544,47 @@ PLUGIN_TEST_ADVISORY_LIST="$stale_advisory" PLUGIN_TEST_SERIAL_LIST="$empty_list run_runner 2 "an advisory entry that matches no suite is rejected" --root "$r" assert_output_has "the stale advisory entry is named" "plugins/gone/gone.test.sh" +# --- --budget: a suite over its share fails by name ------------------------------ +# +# The slow suite sleeps past two whole seconds, so its whole-second timing is at +# least 2 whatever the clock boundary, over a 1 s share; the quick one is 0 or 1. +r="$(make_root budget)" +write_suite "$r" plugins/slow/slow.test.sh 'sleep 2.1; echo "ok: slow"' +write_suite "$r" plugins/quick/quick.test.sh 'echo "ok: quick"' +no_seconds="$scratch/no-such-seconds.txt" +PLUGIN_TEST_SHARE_MARGIN=1 PLUGIN_TEST_SHARE_DEFAULT=1 PLUGIN_TEST_SECONDS_LIST="$no_seconds" \ + PLUGIN_TEST_SERIAL_LIST="$empty_list" run_runner 1 "a suite over its share fails the run" --root "$r" --jobs 2 --budget 1 +assert_output_has "the over-share suite is named with its time and share" "FAIL: plugins/slow/slow.test.sh took " +assert_output_has "the share it went over is named" "s, over its 1s share of the budget" +assert_output_lacks "a suite inside its share is not failed" "FAIL: plugins/quick/quick.test.sh" +assert_error_count "the over-share suite gets one error annotation" 1 +assert_output_has "the overrun of the whole run is reported" "OVER BUDGET: the suites took " +assert_output_has "the overrun names the slowest suite" "s plugins/slow/slow.test.sh" + +PLUGIN_TEST_SHARE_MARGIN=1 PLUGIN_TEST_SHARE_DEFAULT=1 PLUGIN_TEST_SECONDS_LIST="$no_seconds" \ + PLUGIN_TEST_SERIAL_LIST="$empty_list" run_runner 0 "without --budget no suite is timed against a share" --root "$r" --jobs 2 +assert_output_lacks "without --budget no suite is failed for its time" "share of the budget" +assert_output_lacks "without --budget no overrun is reported" "OVER BUDGET" + +budget_seconds="$scratch/budget-seconds.txt" +printf '%s\n' "# seconds" "plugins/slow/slow.test.sh 5" >"$budget_seconds" +PLUGIN_TEST_SHARE_MARGIN=1 PLUGIN_TEST_SHARE_DEFAULT=1 PLUGIN_TEST_SECONDS_LIST="$budget_seconds" \ + PLUGIN_TEST_SERIAL_LIST="$empty_list" run_runner 0 "a listed median raises the share, and an overrun alone does not fail" \ + --root "$r" --jobs 2 --budget 1 +assert_output_lacks "the listed suite inside its 5 s share is not failed" "over its" +assert_output_has "the overrun is still reported" "OVER BUDGET: the suites took " + +PLUGIN_TEST_SECONDS_LIST="$budget_seconds" PLUGIN_TEST_SERIAL_LIST="$empty_list" \ + run_runner 0 "a run inside the budget says so" --root "$r" --budget 600 +assert_output_has "the time against the budget is reported" "s of the 600s budget." + +for bad in 0 x -1 ''; do + PLUGIN_TEST_SERIAL_LIST="$empty_list" run_runner 2 "--budget '$bad' is rejected" --root "$r" --budget "$bad" +done +PLUGIN_TEST_SERIAL_LIST="$empty_list" run_runner 2 "an empty --budget= is rejected, not a run with no budget" --root "$r" --budget= +PLUGIN_TEST_SHARE_MARGIN=0 PLUGIN_TEST_SERIAL_LIST="$empty_list" run_runner 2 "a zero share margin is rejected" --root "$r" --budget 60 +assert_output_has "the bad margin is named" "PLUGIN_TEST_SHARE_MARGIN must be a positive integer (got '0')" + # --- the shipped lists against the shipped corpus ------------------------------- # # Every entry in scripts/run-plugin-tests-serial.txt and