]> git.ipfire.org Git - thirdparty/git.git/commit
t1092: allow run_on_* functions to use standard input
authorKevin Lyles <klyles@epic.com>
Tue, 3 Sep 2024 22:06:46 +0000 (22:06 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 4 Sep 2024 16:19:04 +0000 (09:19 -0700)
commit68c57590d36a47eee57d9d2e73de213f74c044c9
tree14ab3dea8c56f5dc95d1bd4bfa6033d6dec010a4
parent2e7b89e038c0c888acf61f1b4ee5a43d4dd5e94c
t1092: allow run_on_* functions to use standard input

The 'run_on_sparse' and 'run_on_all' functions do not work correctly for
commands accepting standard input, because they run the same command
multiple times and the first instance consumes it. This also indirectly
affects 'test_all_match' and 'test_sparse_match'.

To allow these functions to work with commands accepting standard input,
first slurp standard input to a temporary file, and then run the command
with its standard input redirected from the temporary file. This ensures
that each command sees the same contents from its standard input.

Note that this does not impact commands that do not read from standard
input; they continue to ignore it. Additionally, existing uses of the
run_on_* functions do not need to do anything differently, as the
standard input of the test environment is already connected to
/dev/null.

We do not explicitly clean up the input files because they are cleaned
up with the rest of the test repositories and their contents may be
useful for figuring out which command failed when a test case fails.

Signed-off-by: Kevin Lyles <klyles@epic.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t1092-sparse-checkout-compatibility.sh