chainlint.pl: don't require `&` background command to end with `&&`
The exit status of the `&` asynchronous operator which starts a command in the background is unconditionally zero, and the few places in the test scripts which launch commands asynchronously are not interested in the exit status of the `&` operator (though they often capture the background command's PID). As such, there is little value in complaining about broken &&-chain for a command launched in the background, and doing so would only make busy-work for test authors. Therefore, take this special case into account when checking for &&-chain breakage. Signed-off-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Eric Sunshine committed
Sep 1, 2022 at 00:29 UTC
aabc3258a1da5f06e0b2492f450d4b8e7e8137e5
3 files changed
+20
-1
t/chainlint.pl
+1
-1
@@ -483,7 +483,7 @@ sub match_ending {
483
}
484
485
my @safe_endings = (
486
- [qr/^(?:&&|\|\||\|)$/],
486
+ [qr/^(?:&&|\|\||\||&)$/],
487
[qr/^(?:exit|return)$/, qr/^(?:\d+|\$\?)$/],
488
[qr/^(?:exit|return)$/, qr/^(?:\d+|\$\?)$/, qr/^;$/],
489
[qr/^(?:exit|return|continue)$/],
t/chainlint/chain-break-background.expect
new
+9
@@ -0,0 +1,9 @@
1
+JGIT_DAEMON_PID= &&
2
+git init --bare empty.git &&
3
+> empty.git/git-daemon-export-ok &&
4
+mkfifo jgit_daemon_output &&
5
+{
6
+ jgit daemon --port="$JGIT_DAEMON_PORT" . > jgit_daemon_output &
7
+ JGIT_DAEMON_PID=$!
8
+} &&
9
+test_expect_code 2 git ls-remote --exit-code git://localhost:$JGIT_DAEMON_PORT/empty.git
t/chainlint/chain-break-background.test
new
+10
@@ -0,0 +1,10 @@
1
+JGIT_DAEMON_PID= &&
2
+git init --bare empty.git &&
3
+>empty.git/git-daemon-export-ok &&
4
+mkfifo jgit_daemon_output &&
5
+{
6
+# LINT: exit status of "&" is always 0 so &&-chaining immaterial
7
+ jgit daemon --port="$JGIT_DAEMON_PORT" . >jgit_daemon_output &
8
+ JGIT_DAEMON_PID=$!
9
+} &&
10
+test_expect_code 2 git ls-remote --exit-code git://localhost:$JGIT_DAEMON_PORT/empty.git