Skip to content

Commit 5c6f6b8

Browse files
committed
Auto merge of #61655 - RalfJung:checktools, r=kennytm
checktools: unify grepping the TOOLSTATE file The file was grepped twice but in a different way. This unifies the code to make sure it is consistent. Or were these deliberately not doing the same thing? That seems strange though. I wouldn't know how to test these changes.
2 parents 5c45343 + fea10c4 commit 5c6f6b8

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/ci/docker/x86_64-gnu-tools/checktools.sh

+10-3
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,17 @@ set -e
3535
cat "$TOOLSTATE_FILE"
3636
echo
3737

38+
# This function checks if a particular tool is *not* in status "test-pass".
39+
check_tool_failed() {
40+
grep -vq '"'"$1"'":"test-pass"' "$TOOLSTATE_FILE"
41+
}
42+
3843
# This function checks that if a tool's submodule changed, the tool's state must improve
3944
verify_status() {
4045
echo "Verifying status of $1..."
4146
if echo "$CHANGED_FILES" | grep -q "^M[[:blank:]]$2$"; then
4247
echo "This PR updated '$2', verifying if status is 'test-pass'..."
43-
if grep -vq '"'"$1"'":"test-pass"' "$TOOLSTATE_FILE"; then
48+
if check_tool_failed "$1"; then
4449
echo
4550
echo "⚠️ We detected that this PR updated '$1', but its tests failed."
4651
echo
@@ -55,14 +60,16 @@ verify_status() {
5560
fi
5661
}
5762

58-
# deduplicates the submodule check and the assertion that on beta some tools MUST be passing
63+
# deduplicates the submodule check and the assertion that on beta some tools MUST be passing.
64+
# $1 should be "submodule_changed" to only check tools that got changed by this PR,
65+
# or "beta_required" to check all tools that have $2 set to "beta".
5966
check_dispatch() {
6067
if [ "$1" = submodule_changed ]; then
6168
# ignore $2 (branch id)
6269
verify_status $3 $4
6370
elif [ "$2" = beta ]; then
6471
echo "Requiring test passing for $3..."
65-
if grep -q '"'"$3"'":"\(test\|build\)-fail"' "$TOOLSTATE_FILE"; then
72+
if check_tool_failed "$3"; then
6673
exit 4
6774
fi
6875
fi

0 commit comments

Comments
 (0)