Re: [PATCH] t: avoid sed-based chain-linting in some expensive cases

2 messages, 2 authors, 2021-05-13 · open the first message on its own page

Re: [PATCH] t: avoid sed-based chain-linting in some expensive cases

From: Junio C Hamano <hidden>
Date: 2021-05-13 06:50:00

Jeff King [off-list ref] writes:
Of course those extra lint checks are doing something useful, so paying
a few extra seconds (at least on Linux) isn't so bad (though note the
CPU time; we're bounded in our parallel run here by the slowest test, so
it really is ~120s of CPU improvement).
Nice.
quoted hunk
diff --git a/t/test-lib.sh b/t/test-lib.sh
index adaa2db601..adaf03543e 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -947,8 +947,11 @@ test_run_ () {
 		trace=
 		# 117 is magic because it is unlikely to match the exit
 		# code of other programs
-		if $(printf '%s\n' "$1" | sed -f "$GIT_BUILD_DIR/t/chainlint.sed" | grep -q '?![A-Z][A-Z]*?!') ||
-			test "OK-117" != "$(test_eval_ "(exit 117) && $1${LF}${LF}echo OK-\$?" 3>&1)"
+		if test "OK-117" != "$(test_eval_ "(exit 117) && $1${LF}${LF}echo OK-\$?" 3>&1)" ||
+		   {
+			test "${GIT_TEST_CHAIN_LINT_HARDER:-${GIT_TEST_CHAIN_LINT_HARDER_DEFAULT:-1}}" != 0 &&
+			$(printf '%s\n' "$1" | sed -f "$GIT_BUILD_DIR/t/chainlint.sed" | grep -q '?![A-Z][A-Z]*?!')
+		   }
We have been doing the more expensive one first, but we now
optionally skip it while retaining the one that uses the shell.
OK.

Nicely done.
 		then
 			BUG "broken &&-chain or run-away HERE-DOC: $1"
 		fi

Re: [PATCH] t: avoid sed-based chain-linting in some expensive cases

From: Jeff King <hidden>
Date: 2021-05-13 07:23:27

On Thu, May 13, 2021 at 03:49:52PM +0900, Junio C Hamano wrote:
quoted
diff --git a/t/test-lib.sh b/t/test-lib.sh
index adaa2db601..adaf03543e 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -947,8 +947,11 @@ test_run_ () {
 		trace=
 		# 117 is magic because it is unlikely to match the exit
 		# code of other programs
-		if $(printf '%s\n' "$1" | sed -f "$GIT_BUILD_DIR/t/chainlint.sed" | grep -q '?![A-Z][A-Z]*?!') ||
-			test "OK-117" != "$(test_eval_ "(exit 117) && $1${LF}${LF}echo OK-\$?" 3>&1)"
+		if test "OK-117" != "$(test_eval_ "(exit 117) && $1${LF}${LF}echo OK-\$?" 3>&1)" ||
+		   {
+			test "${GIT_TEST_CHAIN_LINT_HARDER:-${GIT_TEST_CHAIN_LINT_HARDER_DEFAULT:-1}}" != 0 &&
+			$(printf '%s\n' "$1" | sed -f "$GIT_BUILD_DIR/t/chainlint.sed" | grep -q '?![A-Z][A-Z]*?!')
+		   }
We have been doing the more expensive one first, but we now
optionally skip it while retaining the one that uses the shell.
OK.
Oh yeah, I meant to call that out. I flipped them mostly because it made
the conditional easier to read (though as you can see, it's already
quite a mouthful).

In practice the short-circuit doesn't help us much, though. Unless a
test is buggy, we end up having to run both tests either way, no matter
the order.

-Peff
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help