chainlint.pl: check line numbers in expected output

While working on chainlint.pl recently, we introduced some bugs that
showed incorrect line numbers in the output. But it was hard to notice,
since we sanitize the output by removing all of the line numbers! It
would be nice to retain these so we can catch any regressions.

The main reason we sanitize is for maintainability: we concatenate all
of the test snippets into a single file, so it's hard for each ".expect"
file to know at which offset its test input will be found. We can handle
that by storing the per-test line numbers in the ".expect" files, and
then dynamically offsetting them as we build the concatenated test and
expect files together.

The changes to the ".expect" files look like tedious boilerplate, but it
actually makes adding new tests easier. You can now just run:

  perl chainlint.pl chainlint/foo.test |
  tail -n +2 >chainlint/foo.expect

to save the output of the script minus the comment headers (after
checking that it is correct, of course). Whereas before you had to strip
the line numbers. The conversions here were done mechanically using
something like the script above, and then spot-checked manually.

It would be possible to do all of this in shell via the Makefile, but it
gets a bit complicated (and requires a lot of extra processes). Instead,
I've written a short perl script that generates the concatenated files
(we already depend on perl, since chainlint.pl uses it). Incidentally,
this improves a few other things:

  - we incorrectly used $(CHAINLINTTMP_SQ) inside a double-quoted
    string. So if your test directory required quoting, like:

       make "TEST_OUTPUT_DIRECTORY=/tmp/h'orrible"

    we'd fail the chainlint tests.

  - the shell in the Makefile didn't handle &&-chaining correctly in its
    loops (though in practice the "sed" and "cat" invocations are not
    likely to fail).

  - likewise, the sed invocation to strip numbers was hiding the exit
    code of chainlint.pl itself. In practice this isn't a big deal;
    since there are linter violations in the test files, we expect it to
    exit non-zero. But we could later use exit codes to distinguish
    serious errors from expected ones.

  - we now use a constant number of processes, instead of scaling with
    the number of test scripts. So it should be a little faster (on my
    machine, "make check-chainlint" goes from 133ms to 73ms).

There are some alternatives to this approach, but I think this is still
a good intermediate step:

  1. We could invoke chainlint.pl individually on each test file, and
     compare it to the expected output (and possibly using "make" to
     avoid repeating already-done checks). This is a much bigger change
     (and we'd have to figure out what to do with the "# LINT" lines in
     the inputs). But in this case we'd still want the "expect" files to
     be annotated with line numbers. So most of what's in this patch
     would be needed anyway.

  2. Likewise, we could run a single chainlint.pl and feed it all of the
     scripts (with "--jobs=1" to get deterministic output). But we'd
     still need to annotate the scripts as we did here, and we'd still
     need to either assemble the "expect" file, or break apart the
     script output to compare to each individual ".expect" file.

So we may pursue those in the long run, but this patch gives us more
robust tests without too much extra work or moving in a useless
direction.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Jeff King 2024-07-10 04:37:55 -04:00 committed by Junio C Hamano
parent 382f6edaee
commit 03763e68fb
74 changed files with 913 additions and 894 deletions

View File

@ -108,18 +108,8 @@ clean-chainlint:
check-chainlint: check-chainlint:
@mkdir -p '$(CHAINLINTTMP_SQ)' && \ @mkdir -p '$(CHAINLINTTMP_SQ)' && \
for i in $(CHAINLINTTESTS); do \ '$(PERL_PATH_SQ)' chainlint-cat.pl '$(CHAINLINTTMP_SQ)' $(CHAINLINTTESTS) && \
sed -e '/^# LINT: /d' chainlint/$$i.test; \ { $(CHAINLINT) --emit-all '$(CHAINLINTTMP_SQ)'/tests >'$(CHAINLINTTMP_SQ)'/actual || true; } && \
done >'$(CHAINLINTTMP_SQ)'/tests && \
{ \
echo "# chainlint: $(CHAINLINTTMP_SQ)/tests" && \
for i in $(CHAINLINTTESTS); do \
echo "# chainlint: $$i" && \
cat chainlint/$$i.expect; \
done \
} >'$(CHAINLINTTMP_SQ)'/expect && \
$(CHAINLINT) --emit-all '$(CHAINLINTTMP_SQ)'/tests | \
sed -e 's/^[1-9][0-9]* //' >'$(CHAINLINTTMP_SQ)'/actual && \
diff -u '$(CHAINLINTTMP_SQ)'/expect '$(CHAINLINTTMP_SQ)'/actual diff -u '$(CHAINLINTTMP_SQ)'/expect '$(CHAINLINTTMP_SQ)'/actual
test-lint: test-lint-duplicates test-lint-executable test-lint-shell-syntax \ test-lint: test-lint-duplicates test-lint-executable test-lint-shell-syntax \

29
t/chainlint-cat.pl Normal file
View File

@ -0,0 +1,29 @@
#!/usr/bin/env perl
my $outdir = shift;
open(my $tests, '>', "$outdir/tests")
or die "unable to open $outdir/tests: $!";
open(my $expect, '>', "$outdir/expect")
or die "unable to open $outdir/expect: $!";
print $expect "# chainlint: $outdir/tests\n";
my $offset = 0;
for my $script (@ARGV) {
print $expect "# chainlint: $script\n";
open(my $expect_in, '<', "chainlint/$script.expect")
or die "unable to open chainlint/$script.expect: $!";
while (<$expect_in>) {
s/^\d+/$& + $offset/e;
print $expect $_;
}
open(my $test_in, '<', "chainlint/$script.test")
or die "unable to open chainlint/$script.test: $!";
while (<$test_in>) {
/^# LINT: / and next;
print $tests $_;
$offset++;
}
}

View File

@ -1,9 +1,9 @@
( 2 (
foo && 3 foo &&
bar=$((42 + 1)) && 4 bar=$((42 + 1)) &&
baz 5 baz
) && 6 ) &&
( 7 (
bar=$((42 + 1)) ?!AMP?! 8 bar=$((42 + 1)) ?!AMP?!
baz 9 baz
) 10 )

View File

@ -1,10 +1,10 @@
( 2 (
foo && 3 foo &&
bar=(gumbo stumbo wumbo) && 4 bar=(gumbo stumbo wumbo) &&
baz 5 baz
) && 6 ) &&
( 7 (
foo && 8 foo &&
bar=${#bar[@]} && 9 bar=${#bar[@]} &&
baz 10 baz
) 11 )

View File

@ -1,18 +1,18 @@
test_done () { 2 test_done () {
case "$test_failure" in 3 case "$test_failure" in
0) 4 0)
test_at_end_hook_ 5 test_at_end_hook_
6
exit 0 ;; 7 exit 0 ;;
8
*) 9 *)
if test $test_external_has_tap -eq 0 10 if test $test_external_has_tap -eq 0
then 11 then
say_color error "# failed $test_failure among $msg" 12 say_color error "# failed $test_failure among $msg"
say "1..$test_count" 13 say "1..$test_count"
fi 14 fi
15
exit 1 ;; 16 exit 1 ;;
17
esac 18 esac
} 19 }

View File

@ -1,8 +1,8 @@
( 2 (
3
nothing && 4 nothing &&
5
something 6 something
7
8
) 9 )

View File

@ -1,8 +1,8 @@
( 2 (
{ 3 {
# show a 4 # show a
echo a && 5 echo a &&
# show b 6 # show b
echo b 7 echo b
} 8 }
) 9 )

View File

@ -1,23 +1,23 @@
( 2 (
foo && 3 foo &&
{ 4 {
echo a ?!AMP?! 5 echo a ?!AMP?!
echo b 6 echo b
} && 7 } &&
bar && 8 bar &&
{ 9 {
echo c 10 echo c
} ?!AMP?! 11 } ?!AMP?!
baz 12 baz
) && 13 ) &&
14
{ 15 {
echo a; ?!AMP?! echo b 16 echo a; ?!AMP?! echo b
} && 17 } &&
{ echo a; ?!AMP?! echo b; } && 18 { echo a; ?!AMP?! echo b; } &&
19
{ 20 {
echo "${var}9" && 21 echo "${var}9" &&
echo "done" 22 echo "done"
} && 23 } &&
finis 24 finis

View File

@ -1,6 +1,6 @@
( 2 (
foo && 3 foo &&
bar ?!AMP?! 4 bar ?!AMP?!
baz && 5 baz &&
wop 6 wop
) 7 )

View File

@ -1,11 +1,11 @@
( 2 (
case "$x" in 3 case "$x" in
# found foo 4 # found foo
x) foo ;; 5 x) foo ;;
# found other 6 # found other
*) 7 *)
# treat it as bar 8 # treat it as bar
bar 9 bar
;; 10 ;;
esac 11 esac
) 12 )

View File

@ -1,19 +1,19 @@
( 2 (
case "$x" in 3 case "$x" in
x) foo ;; 4 x) foo ;;
*) bar ;; 5 *) bar ;;
esac && 6 esac &&
foobar 7 foobar
) && 8 ) &&
( 9 (
case "$x" in 10 case "$x" in
x) foo ;; 11 x) foo ;;
*) bar ;; 12 *) bar ;;
esac ?!AMP?! 13 esac ?!AMP?!
foobar 14 foobar
) && 15 ) &&
( 16 (
case "$x" in 1) true;; esac && 17 case "$x" in 1) true;; esac &&
case "$y" in 2) false;; esac ?!AMP?! 18 case "$y" in 2) false;; esac ?!AMP?!
foobar 19 foobar
) 20 )

View File

@ -1,9 +1,9 @@
JGIT_DAEMON_PID= && 2 JGIT_DAEMON_PID= &&
git init --bare empty.git && 3 git init --bare empty.git &&
>empty.git/git-daemon-export-ok && 4 >empty.git/git-daemon-export-ok &&
mkfifo jgit_daemon_output && 5 mkfifo jgit_daemon_output &&
{ 6 {
jgit daemon --port="$JGIT_DAEMON_PORT" . >jgit_daemon_output & 7 jgit daemon --port="$JGIT_DAEMON_PORT" . >jgit_daemon_output &
JGIT_DAEMON_PID=$! 8 JGIT_DAEMON_PID=$!
} && 9 } &&
test_expect_code 2 git ls-remote --exit-code git://localhost:$JGIT_DAEMON_PORT/empty.git 10 test_expect_code 2 git ls-remote --exit-code git://localhost:$JGIT_DAEMON_PORT/empty.git

View File

@ -1,12 +1,12 @@
git ls-tree --name-only -r refs/notes/many_notes | 2 git ls-tree --name-only -r refs/notes/many_notes |
while read path 3 while read path
do 4 do
test "$path" = "foobar/non-note.txt" && continue 5 test "$path" = "foobar/non-note.txt" && continue
test "$path" = "deadbeef" && continue 6 test "$path" = "deadbeef" && continue
test "$path" = "de/adbeef" && continue 7 test "$path" = "de/adbeef" && continue
8
if test $(expr length "$path") -ne $hexsz 9 if test $(expr length "$path") -ne $hexsz
then 10 then
return 1 11 return 1
fi 12 fi
done 13 done

View File

@ -1,9 +1,9 @@
if condition not satisified 2 if condition not satisified
then 3 then
echo it did not work... 4 echo it did not work...
echo failed! 5 echo failed!
false 6 false
else 7 else
echo it went okay ?!AMP?! 8 echo it went okay ?!AMP?!
congratulate user 9 congratulate user
fi 10 fi

View File

@ -1,19 +1,19 @@
case "$(git ls-files)" in 2 case "$(git ls-files)" in
one) echo pass one ;; 3 one) echo pass one ;;
*) echo bad one; return 1 ;; 4 *) echo bad one; return 1 ;;
esac && 5 esac &&
( 6 (
case "$(git ls-files)" in 7 case "$(git ls-files)" in
two) echo pass two ;; 8 two) echo pass two ;;
*) echo bad two; exit 1 ;; 9 *) echo bad two; exit 1 ;;
esac 10 esac
) && 11 ) &&
case "$(git ls-files)" in 12 case "$(git ls-files)" in
dir/two"$LF"one) echo pass both ;; 13 dir/two"$LF"one) echo pass both ;;
*) echo bad; return 1 ;; 14 *) echo bad; return 1 ;;
esac && 15 esac &&
16
for i in 1 2 3 4 ; do 17 for i in 1 2 3 4 ; do
git checkout main -b $i || return $? 18 git checkout main -b $i || return $?
test_commit $i $i $i tag$i || return $? 19 test_commit $i $i $i tag$i || return $?
done 20 done

View File

@ -1,9 +1,9 @@
OUT=$( ((large_git; echo $? 1>&3) | :) 3>&1 ) && 2 OUT=$( ((large_git; echo $? 1>&3) | :) 3>&1 ) &&
test_match_signal 13 "$OUT" && 3 test_match_signal 13 "$OUT" &&
4
{ test-tool sigchain >actual; ret=$?; } && 5 { test-tool sigchain >actual; ret=$?; } &&
{ 6 {
test_match_signal 15 "$ret" || 7 test_match_signal 15 "$ret" ||
test "$ret" = 3 8 test "$ret" = 3
} && 9 } &&
test_cmp expect actual 10 test_cmp expect actual

View File

@ -1,9 +1,9 @@
echo nobody home && { 2 echo nobody home && {
test the doohicky ?!AMP?! 3 test the doohicky ?!AMP?!
right now 4 right now
} && 5 } &&
6
GIT_EXTERNAL_DIFF=echo git diff | { 7 GIT_EXTERNAL_DIFF=echo git diff | {
read path oldfile oldhex oldmode newfile newhex newmode && 8 read path oldfile oldhex oldmode newfile newhex newmode &&
test "z$oh" = "z$oldhex" 9 test "z$oh" = "z$oldhex"
} 10 }

View File

@ -1,10 +1,10 @@
mkdir sub && ( 2 mkdir sub && (
cd sub && 3 cd sub &&
foo the bar ?!AMP?! 4 foo the bar ?!AMP?!
nuff said 5 nuff said
) && 6 ) &&
7
cut "-d " -f actual | (read s1 s2 s3 && 8 cut "-d " -f actual | (read s1 s2 s3 &&
test -f $s1 ?!AMP?! 9 test -f $s1 ?!AMP?!
test $(cat $s2) = tree2path1 && 10 test $(cat $s2) = tree2path1 &&
test $(cat $s3) = tree3path1) 11 test $(cat $s3) = tree3path1)

View File

@ -1,3 +1,3 @@
(cd foo && 2 (cd foo &&
(bar && 3 (bar &&
baz)) 4 baz))

View File

@ -1,26 +1,26 @@
( 2 (
foo 3 foo
) && 4 ) &&
( 5 (
bar 6 bar
) >out && 7 ) >out &&
( 8 (
baz 9 baz
) 2>err && 10 ) 2>err &&
( 11 (
boo 12 boo
) <input && 13 ) <input &&
( 14 (
bip 15 bip
) | wuzzle && 16 ) | wuzzle &&
( 17 (
bop 18 bop
) | fazz \ 19 ) | fazz \
fozz && 20 fozz &&
( 21 (
bup 22 bup
) | 23 ) |
fuzzle && 24 fuzzle &&
( 25 (
yop 26 yop
) 27 )

View File

@ -1,2 +1,2 @@
OUT=$( ((large_git 1>&3) | :) 3>&1 ) && 2 OUT=$( ((large_git 1>&3) | :) 3>&1 ) &&
test_match_signal 13 "$OUT" 3 test_match_signal 13 "$OUT"

View File

@ -1,9 +1,9 @@
( 2 (
foo && 3 foo &&
bar=$(gobble) && 4 bar=$(gobble) &&
baz 5 baz
) && 6 ) &&
( 7 (
bar=$(gobble blocks) ?!AMP?! 8 bar=$(gobble blocks) ?!AMP?!
baz 9 baz
) 10 )

View File

@ -1,8 +1,8 @@
( 2 (
# comment 1 3 # comment 1
nothing && 4 nothing &&
# comment 2 5 # comment 2
something 6 something
# comment 3 7 # comment 3
# comment 4 8 # comment 4
) 9 )

View File

@ -1,9 +1,9 @@
(for i in a b c; do 2 (for i in a b c; do
if test "$(echo $(waffle bat))" = "eleventeen" && 3 if test "$(echo $(waffle bat))" = "eleventeen" &&
test "$x" = "$y"; then 4 test "$x" = "$y"; then
: 5 :
else 6 else
echo >file 7 echo >file
fi ?!LOOP?! 8 fi ?!LOOP?!
done) && 9 done) &&
test ! -f file 10 test ! -f file

View File

@ -1,6 +1,6 @@
(if test -z ""; then 2 (if test -z ""; then
echo empty 3 echo empty
else 4 else
echo bizzy 5 echo bizzy
fi) && 6 fi) &&
echo foobar 7 echo foobar

View File

@ -1,4 +1,4 @@
( while read x 2 ( while read x
do foobar bop || exit 1 3 do foobar bop || exit 1
done <file ) && 4 done <file ) &&
outside subshell 5 outside subshell

View File

@ -1,17 +1,17 @@
(cd foo && 2 (cd foo &&
bar 3 bar
) && 4 ) &&
5
(cd foo ?!AMP?! 6 (cd foo ?!AMP?!
bar 7 bar
) && 8 ) &&
9
( 10 (
cd foo && 11 cd foo &&
bar) && 12 bar) &&
13
(cd foo && 14 (cd foo &&
bar) && 15 bar) &&
16
(cd foo ?!AMP?! 17 (cd foo ?!AMP?!
bar) 18 bar)

View File

@ -1,12 +1,12 @@
run_sub_test_lib_test_err run-inv-range-start \ 2 run_sub_test_lib_test_err run-inv-range-start \
"--run invalid range start" \ 3 "--run invalid range start" \
--run="a-5" <<-\EOF && 4 --run="a-5" <<-\EOF &&
test_expect_success "passing test #1" "true" 5 test_expect_success "passing test #1" "true"
test_done 6 test_done
EOF 7 EOF
check_sub_test_lib_test_err run-inv-range-start \ 8 check_sub_test_lib_test_err run-inv-range-start \
<<-\EOF_OUT 3<<-EOF_ERR 9 <<-\EOF_OUT 3<<-EOF_ERR
> FATAL: Unexpected exit with code 1 10 > FATAL: Unexpected exit with code 1
EOF_OUT 11 EOF_OUT
> error: --run: invalid non-numeric in range start: ${SQ}a-5${SQ} 12 > error: --run: invalid non-numeric in range start: ${SQ}a-5${SQ}
EOF_ERR 13 EOF_ERR

View File

@ -1,5 +1,5 @@
2
echo 'fatal: reword option of --fixup is mutually exclusive with' '--patch/--interactive/--all/--include/--only' >expect && 3 echo 'fatal: reword option of --fixup is mutually exclusive with' '--patch/--interactive/--all/--include/--only' >expect &&
test_must_fail git commit --fixup=reword:HEAD~ $1 2>actual && 4 test_must_fail git commit --fixup=reword:HEAD~ $1 2>actual &&
test_cmp expect actual 5 test_cmp expect actual
6

View File

@ -1,12 +1,12 @@
grep "^ ! [rejected][ ]*$BRANCH -> $BRANCH (non-fast-forward)$" out && 2 grep "^ ! [rejected][ ]*$BRANCH -> $BRANCH (non-fast-forward)$" out &&
3
grep "^\.git$" output.txt && 4 grep "^\.git$" output.txt &&
5
6
( 7 (
cd client$version && 8 cd client$version &&
GIT_TEST_PROTOCOL_VERSION=$version git fetch-pack --no-progress .. $(cat ../input) 9 GIT_TEST_PROTOCOL_VERSION=$version git fetch-pack --no-progress .. $(cat ../input)
) >output && 10 ) >output &&
cut -d ' ' -f 2 <output | sort >actual && 11 cut -d ' ' -f 2 <output | sort >actual &&
test_cmp expect actual 12 test_cmp expect actual
13

View File

@ -1,4 +1,4 @@
git ls-tree $tree path >current && 2 git ls-tree $tree path >current &&
cat >expected <<\EOF && 3 cat >expected <<\EOF &&
EOF 4 EOF
test_output 5 test_output

View File

@ -1,4 +1,4 @@
if ! condition; then echo nope; else yep; fi && 2 if ! condition; then echo nope; else yep; fi &&
test_prerequisite !MINGW && 3 test_prerequisite !MINGW &&
mail uucp!address && 4 mail uucp!address &&
echo !whatever! 5 echo !whatever!

View File

@ -1,24 +1,24 @@
( 2 (
for i in a b c 3 for i in a b c
do 4 do
foo || exit 1 5 foo || exit 1
bar && 6 bar &&
baz 7 baz
done 8 done
) && 9 ) &&
( 10 (
while true 11 while true
do 12 do
foo || exit 1 13 foo || exit 1
bar && 14 bar &&
baz 15 baz
done 16 done
) && 17 ) &&
( 18 (
i=0 && 19 i=0 &&
while test $i -lt 10 20 while test $i -lt 10
do 21 do
echo $i || exit 22 echo $i || exit
i=$(($i + 1)) 23 i=$(($i + 1))
done 24 done
) 25 )

View File

@ -1,5 +1,5 @@
( 2 (
foo || exit 1 3 foo || exit 1
bar && 4 bar &&
baz 5 baz
) 6 )

View File

@ -1,5 +1,5 @@
for it 2 for it
do 3 do
path=$(expr "$it" : ([^:]*)) && 4 path=$(expr "$it" : ([^:]*)) &&
git update-index --add "$path" || exit 5 git update-index --add "$path" || exit
done 6 done

View File

@ -1,14 +1,14 @@
( 2 (
for i in a b c 3 for i in a b c
do 4 do
echo $i ?!AMP?! 5 echo $i ?!AMP?!
cat <<-\EOF ?!LOOP?! 6 cat <<-\EOF ?!LOOP?!
bar 7 bar
EOF 8 EOF
done ?!AMP?! 9 done ?!AMP?!
10
for i in a b c; do 11 for i in a b c; do
echo $i && 12 echo $i &&
cat $i ?!LOOP?! 13 cat $i ?!LOOP?!
done 14 done
) 15 )

View File

@ -1,11 +1,11 @@
sha1_file() { 2 sha1_file() {
echo "$*" | sed "s#..#.git/objects/&/#" 3 echo "$*" | sed "s#..#.git/objects/&/#"
} && 4 } &&
5
remove_object() { 6 remove_object() {
file=$(sha1_file "$*") && 7 file=$(sha1_file "$*") &&
test -e "$file" ?!AMP?! 8 test -e "$file" ?!AMP?!
rm -f "$file" 9 rm -f "$file"
} ?!AMP?! 10 } ?!AMP?!
11
sha1_file arg && remove_object arg 12 sha1_file arg && remove_object arg

View File

@ -1,4 +1,4 @@
( 2 (
cat <<-\INPUT) 3 cat <<-\INPUT)
fizz 4 fizz
INPUT 5 INPUT

View File

@ -1,11 +1,11 @@
cat >expect <<- EOF && 2 cat >expect <<- EOF &&
header: 43475048 1 $(test_oid oid_version) $NUM_CHUNKS 0 3 header: 43475048 1 $(test_oid oid_version) $NUM_CHUNKS 0
num_commits: $1 4 num_commits: $1
chunks: oid_fanout oid_lookup commit_metadata generation_data bloom_indexes bloom_data 5 chunks: oid_fanout oid_lookup commit_metadata generation_data bloom_indexes bloom_data
EOF 6 EOF
7
cat >expect << -EOF ?!AMP?! 8 cat >expect << -EOF ?!AMP?!
this is not indented 9 this is not indented
-EOF 10 -EOF
11
cleanup 12 cleanup

View File

@ -1,8 +1,8 @@
( 2 (
x=$(bobble <<-\END && 3 x=$(bobble <<-\END &&
fossil 4 fossil
vegetable 5 vegetable
END 6 END
wiffle) ?!AMP?! 7 wiffle) ?!AMP?!
echo $x 8 echo $x
) 9 )

View File

@ -1,7 +1,7 @@
( 2 (
cat <<-\TXT && echo "multi-line 3 cat <<-\TXT && echo "multi-line
string" ?!AMP?! 4 string" ?!AMP?!
fizzle 5 fizzle
TXT 6 TXT
bap 7 bap
) 8 )

View File

@ -1,25 +1,25 @@
boodle wobba \ 2 boodle wobba \
gorgo snoot \ 3 gorgo snoot \
wafta snurb <<EOF && 4 wafta snurb <<EOF &&
quoth the raven, 5 quoth the raven,
nevermore... 6 nevermore...
EOF 7 EOF
8
cat <<-Arbitrary_Tag_42 >foo && 9 cat <<-Arbitrary_Tag_42 >foo &&
snoz 10 snoz
boz 11 boz
woz 12 woz
Arbitrary_Tag_42 13 Arbitrary_Tag_42
14
cat <<"zump" >boo && 15 cat <<"zump" >boo &&
snoz 16 snoz
boz 17 boz
woz 18 woz
zump 19 zump
20
horticulture <<\EOF 21 horticulture <<\EOF
gomez 22 gomez
morticia 23 morticia
wednesday 24 wednesday
pugsly 25 pugsly
EOF 26 EOF

View File

@ -1,7 +1,7 @@
if bob && 2 if bob &&
marcia || 3 marcia ||
kevin 4 kevin
then 5 then
echo "nomads" ?!AMP?! 6 echo "nomads" ?!AMP?!
echo "for sure" 7 echo "for sure"
fi 8 fi

View File

@ -1,12 +1,12 @@
( 2 (
for i in a b c 3 for i in a b c
do 4 do
if false 5 if false
then 6 then
echo "err" 7 echo "err"
exit 1 8 exit 1
fi ?!AMP?! 9 fi ?!AMP?!
foo 10 foo
done ?!AMP?! 11 done ?!AMP?!
bar 12 bar
) 13 )

View File

@ -1,22 +1,22 @@
( 2 (
if test -n "" 3 if test -n ""
then 4 then
echo very ?!AMP?! 5 echo very ?!AMP?!
echo empty 6 echo empty
elif test -z "" 7 elif test -z ""
then 8 then
echo foo 9 echo foo
else 10 else
echo foo && 11 echo foo &&
cat <<-\EOF 12 cat <<-\EOF
bar 13 bar
EOF 14 EOF
fi ?!AMP?! 15 fi ?!AMP?!
echo poodle 16 echo poodle
) && 17 ) &&
( 18 (
if test -n ""; then 19 if test -n ""; then
echo very && 20 echo very &&
echo empty 21 echo empty
fi 22 fi
) 23 )

View File

@ -1,10 +1,10 @@
line 1 \ 2 line 1 \
line 2 \ 3 line 2 \
line 3 \ 4 line 3 \
line 4 && 5 line 4 &&
( 6 (
line 5 \ 7 line 5 \
line 6 \ 8 line 6 \
line 7 \ 9 line 7 \
line 8 10 line 8
) 11 )

View File

@ -1,8 +1,8 @@
( 2 (
foobar && # comment 1 3 foobar && # comment 1
barfoo ?!AMP?! # wrong position for && 4 barfoo ?!AMP?! # wrong position for &&
flibble "not a # comment" 5 flibble "not a # comment"
) && 6 ) &&
7
(cd foo && 8 (cd foo &&
flibble "not a # comment") 9 flibble "not a # comment")

View File

@ -1,15 +1,15 @@
git init r1 && 2 git init r1 &&
for n in 1 2 3 4 5 3 for n in 1 2 3 4 5
do 4 do
echo "This is file: $n" > r1/file.$n && 5 echo "This is file: $n" > r1/file.$n &&
git -C r1 add file.$n && 6 git -C r1 add file.$n &&
git -C r1 commit -m "$n" || return 1 7 git -C r1 commit -m "$n" || return 1
done && 8 done &&
9
git init r2 && 10 git init r2 &&
for n in 1000 10000 11 for n in 1000 10000
do 12 do
printf "%"$n"s" X > r2/large.$n && 13 printf "%"$n"s" X > r2/large.$n &&
git -C r2 add large.$n && 14 git -C r2 add large.$n &&
git -C r2 commit -m "$n" ?!LOOP?! 15 git -C r2 commit -m "$n" ?!LOOP?!
done 16 done

View File

@ -1,18 +1,18 @@
(while test $i -le $blobcount 2 (while test $i -le $blobcount
do 3 do
printf "Generating blob $i/$blobcount\r" >&2 && 4 printf "Generating blob $i/$blobcount\r" >&2 &&
printf "blob\nmark :$i\ndata $blobsize\n" && 5 printf "blob\nmark :$i\ndata $blobsize\n" &&
#test-tool genrandom $i $blobsize && 6 #test-tool genrandom $i $blobsize &&
printf "%-${blobsize}s" $i && 7 printf "%-${blobsize}s" $i &&
echo "M 100644 :$i $i" >> commit && 8 echo "M 100644 :$i $i" >> commit &&
i=$(($i+1)) || 9 i=$(($i+1)) ||
echo $? > exit-status 10 echo $? > exit-status
done && 11 done &&
echo "commit refs/heads/main" && 12 echo "commit refs/heads/main" &&
echo "author A U Thor <author@email.com> 123456789 +0000" && 13 echo "author A U Thor <author@email.com> 123456789 +0000" &&
echo "committer C O Mitter <committer@email.com> 123456789 +0000" && 14 echo "committer C O Mitter <committer@email.com> 123456789 +0000" &&
echo "data 5" && 15 echo "data 5" &&
echo ">2gb" && 16 echo ">2gb" &&
cat commit) | 17 cat commit) |
git fast-import --big-file-threshold=2 && 18 git fast-import --big-file-threshold=2 &&
test ! -f exit-status 19 test ! -f exit-status

View File

@ -1,12 +1,12 @@
( 2 (
if true 3 if true
then 4 then
while true 5 while true
do 6 do
echo "pop" ?!AMP?! 7 echo "pop" ?!AMP?!
echo "glup" ?!LOOP?! 8 echo "glup" ?!LOOP?!
done ?!AMP?! 9 done ?!AMP?!
foo 10 foo
fi ?!AMP?! 11 fi ?!AMP?!
bar 12 bar
) 13 )

View File

@ -1,10 +1,10 @@
( 2 (
git rev-list --objects --no-object-names base..loose | 3 git rev-list --objects --no-object-names base..loose |
while read oid 4 while read oid
do 5 do
path="$objdir/$(test_oid_to_path "$oid")" && 6 path="$objdir/$(test_oid_to_path "$oid")" &&
printf "%s %d\n" "$oid" "$(test-tool chmtime --get "$path")" || 7 printf "%s %d\n" "$oid" "$(test-tool chmtime --get "$path")" ||
echo "object list generation failed for $oid" 8 echo "object list generation failed for $oid"
done | 9 done |
sort -k1 10 sort -k1
) >expect && 11 ) >expect &&

View File

@ -1,18 +1,18 @@
( 2 (
foo && 3 foo &&
x=$( 4 x=$(
echo bar | 5 echo bar |
cat 6 cat
) && 7 ) &&
echo ok 8 echo ok
) | 9 ) |
sort && 10 sort &&
( 11 (
bar && 12 bar &&
x=$(echo bar | 13 x=$(echo bar |
cat 14 cat
) && 15 ) &&
y=$(echo baz | 16 y=$(echo baz |
fip) && 17 fip) &&
echo fail 18 echo fail
) 19 )

View File

@ -1,14 +1,14 @@
( 2 (
x="line 1 3 x="line 1
line 2 4 line 2
line 3" && 5 line 3" &&
y="line 1 6 y="line 1
line2" ?!AMP?! 7 line2" ?!AMP?!
foobar 8 foobar
) && 9 ) &&
( 10 (
echo "xyz" "abc 11 echo "xyz" "abc
def 12 def
ghi" && 13 ghi" &&
barfoo 14 barfoo
) 15 )

View File

@ -1,5 +1,5 @@
! (foo && bar) && 2 ! (foo && bar) &&
! (foo && bar) >baz && 3 ! (foo && bar) >baz &&
4
! (foo; ?!AMP?! bar) && 5 ! (foo; ?!AMP?! bar) &&
! (foo; ?!AMP?! bar) >baz 6 ! (foo; ?!AMP?! bar) >baz

View File

@ -1,25 +1,25 @@
( 2 (
(cd foo && 3 (cd foo &&
bar 4 bar
) && 5 ) &&
6
(cd foo && 7 (cd foo &&
bar 8 bar
) ?!AMP?! 9 ) ?!AMP?!
10
( 11 (
cd foo && 12 cd foo &&
bar) && 13 bar) &&
14
( 15 (
cd foo && 16 cd foo &&
bar) ?!AMP?! 17 bar) ?!AMP?!
18
(cd foo && 19 (cd foo &&
bar) && 20 bar) &&
21
(cd foo && 22 (cd foo &&
bar) ?!AMP?! 23 bar) ?!AMP?!
24
foobar 25 foobar
) 26 )

View File

@ -1,30 +1,30 @@
cat <<ARBITRARY >foop && 2 cat <<ARBITRARY >foop &&
naddle 3 naddle
fub <<EOF 4 fub <<EOF
nozzle 5 nozzle
noodle 6 noodle
EOF 7 EOF
formp 8 formp
ARBITRARY 9 ARBITRARY
10
( 11 (
cat <<-\INPUT_END && 12 cat <<-\INPUT_END &&
fish are mice 13 fish are mice
but geese go slow 14 but geese go slow
data <<EOF 15 data <<EOF
perl is lerp 16 perl is lerp
and nothing else 17 and nothing else
EOF 18 EOF
toink 19 toink
INPUT_END 20 INPUT_END
21
cat <<-\EOT ?!AMP?! 22 cat <<-\EOT ?!AMP?!
text goes here 23 text goes here
data <<EOF 24 data <<EOF
data goes here 25 data goes here
EOF 26 EOF
more test here 27 more test here
EOT 28 EOT
29
foobar 30 foobar
) 31 )

View File

@ -1,31 +1,31 @@
for i in 0 1 2 3 4 5 6 7 8 9; 2 for i in 0 1 2 3 4 5 6 7 8 9;
do 3 do
for j in 0 1 2 3 4 5 6 7 8 9; 4 for j in 0 1 2 3 4 5 6 7 8 9;
do 5 do
echo "$i$j" >"path$i$j" ?!LOOP?! 6 echo "$i$j" >"path$i$j" ?!LOOP?!
done ?!LOOP?! 7 done ?!LOOP?!
done && 8 done &&
9
for i in 0 1 2 3 4 5 6 7 8 9; 10 for i in 0 1 2 3 4 5 6 7 8 9;
do 11 do
for j in 0 1 2 3 4 5 6 7 8 9; 12 for j in 0 1 2 3 4 5 6 7 8 9;
do 13 do
echo "$i$j" >"path$i$j" || return 1 14 echo "$i$j" >"path$i$j" || return 1
done 15 done
done && 16 done &&
17
for i in 0 1 2 3 4 5 6 7 8 9; 18 for i in 0 1 2 3 4 5 6 7 8 9;
do 19 do
for j in 0 1 2 3 4 5 6 7 8 9; 20 for j in 0 1 2 3 4 5 6 7 8 9;
do 21 do
echo "$i$j" >"path$i$j" ?!LOOP?! 22 echo "$i$j" >"path$i$j" ?!LOOP?!
done || return 1 23 done || return 1
done && 24 done &&
25
for i in 0 1 2 3 4 5 6 7 8 9; 26 for i in 0 1 2 3 4 5 6 7 8 9;
do 27 do
for j in 0 1 2 3 4 5 6 7 8 9; 28 for j in 0 1 2 3 4 5 6 7 8 9;
do 29 do
echo "$i$j" >"path$i$j" || return 1 30 echo "$i$j" >"path$i$j" || return 1
done || return 1 31 done || return 1
done 32 done

View File

@ -1,11 +1,11 @@
( 2 (
foo && 3 foo &&
( 4 (
bar && 5 bar &&
# bottles wobble while fiddles gobble 6 # bottles wobble while fiddles gobble
# minor numbers of cows (or do they?) 7 # minor numbers of cows (or do they?)
baz && 8 baz &&
snaff 9 snaff
) ?!AMP?! 10 ) ?!AMP?!
fuzzy 11 fuzzy
) 12 )

View File

@ -1,13 +1,13 @@
( 2 (
cd foo && 3 cd foo &&
( 4 (
echo a && 5 echo a &&
echo b 6 echo b
) >file && 7 ) >file &&
8
cd foo && 9 cd foo &&
( 10 (
echo a ?!AMP?! 11 echo a ?!AMP?!
echo b 12 echo b
) >file 13 ) >file
) 14 )

View File

@ -1,14 +1,14 @@
echo "<<<<<<< ours" && 2 echo "<<<<<<< ours" &&
echo ourside && 3 echo ourside &&
echo "=======" && 4 echo "=======" &&
echo theirside && 5 echo theirside &&
echo ">>>>>>> theirs" && 6 echo ">>>>>>> theirs" &&
7
( 8 (
echo "<<<<<<< ours" && 9 echo "<<<<<<< ours" &&
echo ourside && 10 echo ourside &&
echo "=======" && 11 echo "=======" &&
echo theirside && 12 echo theirside &&
echo ">>>>>>> theirs" ?!AMP?! 13 echo ">>>>>>> theirs" ?!AMP?!
poodle 14 poodle
) >merged 15 ) >merged

View File

@ -1,9 +1,9 @@
git init dir-rename-and-content && 2 git init dir-rename-and-content &&
( 3 (
cd dir-rename-and-content && 4 cd dir-rename-and-content &&
test_write_lines 1 2 3 4 5 >foo && 5 test_write_lines 1 2 3 4 5 >foo &&
mkdir olddir && 6 mkdir olddir &&
for i in a b c; do echo $i >olddir/$i; ?!LOOP?! done ?!AMP?! 7 for i in a b c; do echo $i >olddir/$i; ?!LOOP?! done ?!AMP?!
git add foo olddir && 8 git add foo olddir &&
git commit -m "original" && 9 git commit -m "original" &&
) 10 )

View File

@ -1,9 +1,9 @@
(foo && bar) && 2 (foo && bar) &&
(foo && bar) | 3 (foo && bar) |
(foo && bar) >baz && 4 (foo && bar) >baz &&
5
(foo; ?!AMP?! bar) && 6 (foo; ?!AMP?! bar) &&
(foo; ?!AMP?! bar) | 7 (foo; ?!AMP?! bar) |
(foo; ?!AMP?! bar) >baz && 8 (foo; ?!AMP?! bar) >baz &&
9
(foo "bar; baz") 10 (foo "bar; baz")

View File

@ -1,4 +1,4 @@
( 2 (
p4 print -1 //depot/fiddle#42 >file && 3 p4 print -1 //depot/fiddle#42 >file &&
foobar 4 foobar
) 5 )

View File

@ -1,10 +1,10 @@
( 2 (
foo | 3 foo |
bar | 4 bar |
baz && 5 baz &&
6
fish | 7 fish |
cow ?!AMP?! 8 cow ?!AMP?!
9
sunder 10 sunder
) 11 )

View File

@ -1,5 +1,5 @@
while test $i -lt $((num - 5)) 2 while test $i -lt $((num - 5))
do 3 do
git notes add -m "notes for commit$i" HEAD~$i || return 1 4 git notes add -m "notes for commit$i" HEAD~$i || return 1
i=$((i + 1)) 5 i=$((i + 1))
done 6 done

View File

@ -1,19 +1,19 @@
( 2 (
cat foo ; ?!AMP?! echo bar ?!AMP?! 3 cat foo ; ?!AMP?! echo bar ?!AMP?!
cat foo ; ?!AMP?! echo bar 4 cat foo ; ?!AMP?! echo bar
) && 5 ) &&
( 6 (
cat foo ; ?!AMP?! echo bar && 7 cat foo ; ?!AMP?! echo bar &&
cat foo ; ?!AMP?! echo bar 8 cat foo ; ?!AMP?! echo bar
) && 9 ) &&
( 10 (
echo "foo; bar" && 11 echo "foo; bar" &&
cat foo; ?!AMP?! echo bar 12 cat foo; ?!AMP?! echo bar
) && 13 ) &&
( 14 (
foo; 15 foo;
) && 16 ) &&
(cd foo && 17 (cd foo &&
for i in a b c; do 18 for i in a b c; do
echo; ?!LOOP?! 19 echo; ?!LOOP?!
done) 20 done)

View File

@ -1,4 +1,4 @@
perl -e ' 2 perl -e '
defined($_ = -s $_) or die for @ARGV; 3 defined($_ = -s $_) or die for @ARGV;
exit 1 if $ARGV[0] <= $ARGV[1]; 4 exit 1 if $ARGV[0] <= $ARGV[1];
' test-2-$packname_2.pack test-3-$packname_3.pack 5 ' test-2-$packname_2.pack test-3-$packname_3.pack

View File

@ -1,30 +1,30 @@
( 2 (
echo wobba \ 3 echo wobba \
gorgo snoot \ 4 gorgo snoot \
wafta snurb <<-EOF && 5 wafta snurb <<-EOF &&
quoth the raven, 6 quoth the raven,
nevermore... 7 nevermore...
EOF 8 EOF
9
cat <<EOF >bip ?!AMP?! 10 cat <<EOF >bip ?!AMP?!
fish fly high 11 fish fly high
EOF 12 EOF
13
echo <<-\EOF >bop 14 echo <<-\EOF >bop
gomez 15 gomez
morticia 16 morticia
wednesday 17 wednesday
pugsly 18 pugsly
EOF 19 EOF
) && 20 ) &&
( 21 (
cat <<-\ARBITRARY >bup && 22 cat <<-\ARBITRARY >bup &&
glink 23 glink
FIZZ 24 FIZZ
ARBITRARY 25 ARBITRARY
cat <<-"ARBITRARY3" >bup3 && 26 cat <<-"ARBITRARY3" >bup3 &&
glink 27 glink
FIZZ 28 FIZZ
ARBITRARY3 29 ARBITRARY3
meep 30 meep
) 31 )

View File

@ -1,19 +1,19 @@
( 2 (
(foo && bar) && 3 (foo && bar) &&
(foo && bar) | 4 (foo && bar) |
(foo && bar) >baz && 5 (foo && bar) >baz &&
6
(foo; ?!AMP?! bar) && 7 (foo; ?!AMP?! bar) &&
(foo; ?!AMP?! bar) | 8 (foo; ?!AMP?! bar) |
(foo; ?!AMP?! bar) >baz && 9 (foo; ?!AMP?! bar) >baz &&
10
(foo || exit 1) && 11 (foo || exit 1) &&
(foo || exit 1) | 12 (foo || exit 1) |
(foo || exit 1) >baz && 13 (foo || exit 1) >baz &&
14
(foo && bar) ?!AMP?! 15 (foo && bar) ?!AMP?!
16
(foo && bar; ?!AMP?! baz) ?!AMP?! 17 (foo && bar; ?!AMP?! baz) ?!AMP?!
18
foobar 19 foobar
) 20 )

View File

@ -1,22 +1,22 @@
( 2 (
chks="sub1 3 chks="sub1
sub2 4 sub2
sub3 5 sub3
sub4" && 6 sub4" &&
chks_sub=$(cat <<TXT | sed "s,^,sub dir/," 7 chks_sub=$(cat <<TXT | sed "s,^,sub dir/,"
$chks 8 $chks
TXT 9 TXT
) && 10 ) &&
chkms="main-sub1 11 chkms="main-sub1
main-sub2 12 main-sub2
main-sub3 13 main-sub3
main-sub4" && 14 main-sub4" &&
chkms_sub=$(cat <<TXT | sed "s,^,sub dir/," 15 chkms_sub=$(cat <<TXT | sed "s,^,sub dir/,"
$chkms 16 $chkms
TXT 17 TXT
) && 18 ) &&
19
subfiles=$(git ls-files) && 20 subfiles=$(git ls-files) &&
check_equal "$subfiles" "$chkms 21 check_equal "$subfiles" "$chkms
$chks" 22 $chks"
) 23 )

View File

@ -1,27 +1,27 @@
git config filter.rot13.smudge ./rot13.sh && 2 git config filter.rot13.smudge ./rot13.sh &&
git config filter.rot13.clean ./rot13.sh && 3 git config filter.rot13.clean ./rot13.sh &&
4
{ 5 {
echo "*.t filter=rot13" ?!AMP?! 6 echo "*.t filter=rot13" ?!AMP?!
echo "*.i ident" 7 echo "*.i ident"
} >.gitattributes && 8 } >.gitattributes &&
9
{ 10 {
echo a b c d e f g h i j k l m ?!AMP?! 11 echo a b c d e f g h i j k l m ?!AMP?!
echo n o p q r s t u v w x y z ?!AMP?! 12 echo n o p q r s t u v w x y z ?!AMP?!
echo '$Id$' 13 echo '$Id$'
} >test && 14 } >test &&
cat test >test.t && 15 cat test >test.t &&
cat test >test.o && 16 cat test >test.o &&
cat test >test.i && 17 cat test >test.i &&
git add test test.t test.i && 18 git add test test.t test.i &&
rm -f test test.t test.i && 19 rm -f test test.t test.i &&
git checkout -- test test.t test.i && 20 git checkout -- test test.t test.i &&
21
echo "content-test2" >test2.o && 22 echo "content-test2" >test2.o &&
echo "content-test3 - filename with special characters" >"test3 'sq',$x=.o" ?!AMP?! 23 echo "content-test3 - filename with special characters" >"test3 'sq',$x=.o" ?!AMP?!
24
downstream_url_for_sed=$( 25 downstream_url_for_sed=$(
printf "%sn" "$downstream_url" | 26 printf "%sn" "$downstream_url" |
sed -e 's/\/\\/g' -e 's/[[/.*^$]/\&/g' 27 sed -e 's/\/\\/g' -e 's/[[/.*^$]/\&/g'
) 28 )

View File

@ -1,4 +1,4 @@
command_which_is_run && 2 command_which_is_run &&
cat >expect <<-\EOF ?!UNCLOSED-HEREDOC?! && 3 cat >expect <<-\EOF ?!UNCLOSED-HEREDOC?! &&
we forget to end the here-doc 4 we forget to end the here-doc
command_which_is_gobbled 5 command_which_is_gobbled

View File

@ -1,7 +1,7 @@
command_which_is_run && 2 command_which_is_run &&
cat >expect <<\EOF ?!UNCLOSED-HEREDOC?! && 3 cat >expect <<\EOF ?!UNCLOSED-HEREDOC?! &&
we try to end the here-doc below, 4 we try to end the here-doc below,
but the indentation throws us off 5 but the indentation throws us off
since the operator is not "<<-". 6 since the operator is not "<<-".
EOF 7 EOF
command_which_is_gobbled 8 command_which_is_gobbled

View File

@ -1,14 +1,14 @@
( 2 (
while true 3 while true
do 4 do
echo foo ?!AMP?! 5 echo foo ?!AMP?!
cat <<-\EOF ?!LOOP?! 6 cat <<-\EOF ?!LOOP?!
bar 7 bar
EOF 8 EOF
done ?!AMP?! 9 done ?!AMP?!
10
while true; do 11 while true; do
echo foo && 12 echo foo &&
cat bar ?!LOOP?! 13 cat bar ?!LOOP?!
done 14 done
) 15 )