Skip to content

Commit 1c24d55

Browse files
committed
t: extend test_lazy_prereq
Allow test_lazy_prereq script to signal a programming error by exiting with status 125 (like how bisect scripts do). This is used to signal a deprecated-and-then-removed prerequisite that should never be used in tests anymore. Signed-off-by: Junio C Hamano <[email protected]>
1 parent ab362fc commit 1c24d55

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

t/README

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -983,8 +983,10 @@ see test-lib-functions.sh for the full list and their options.
983983
SYMLINKS ...". The script is run in a temporary directory inside
984984
a subshell, so you do not have to worry about removing temporary
985985
files you create there. When the script exits with status 0, the
986-
prerequisite is set. Exiting with non-zero status makes the
987-
prerequisite unsatisified.
986+
prerequisite is set. Exiting with non-zero status other than 125
987+
makes the prerequisite unsatisified. Exiting the script with 125
988+
signals a programming error and is used to mark a prerequisite that
989+
should not be used by test scripts.
988990

989991
- test_expect_code <exit-code> <command>
990992

t/test-lib-functions.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -773,6 +773,8 @@ mkdir -p "$TRASH_DIRECTORY/prereq-test-dir-'"$1"'" &&
773773
rm -rf "$TRASH_DIRECTORY/prereq-test-dir-$1"
774774
if test "$eval_ret" = 0; then
775775
say >&3 "prerequisite $1 ok"
776+
elif test "$eval_ret" = 125; then
777+
:;
776778
else
777779
say >&3 "prerequisite $1 not satisfied"
778780
fi
@@ -811,6 +813,9 @@ test_have_prereq () {
811813
if test_run_lazy_prereq_ "$prerequisite" "$script"
812814
then
813815
test_set_prereq $prerequisite
816+
elif test $? = 125
817+
then
818+
BUG "Do not use $prerequisite"
814819
fi
815820
lazily_tested_prereq="$lazily_tested_prereq$prerequisite "
816821
esac

0 commit comments

Comments
 (0)