aboutsummaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2026-01-15 11:12:53 -0800
committerJunio C Hamano <gitster@pobox.com>2026-01-15 13:02:38 -0800
commita3d1f391d35762162356201028fb73774a6c4a8b (patch)
tree4b27ddcff1e2c2a24f34eccd2c50cb0275b39b2f /t
parent7264e61d87e58b9d0f5e6424c47c11e9657dfb75 (diff)
downloadgit-a3d1f391d35762162356201028fb73774a6c4a8b.tar.xz
Revert "Merge branch 'ar/run-command-hook'"
This reverts commit f406b8955295d01089ba2baf35eceadff2d11cae, reversing changes made to 1627809eeff75e6ec936fc609e7be46d5eb2fa9e. It seems to have caused a few regressions, two of the three known ones we have proposed solutions for. Let's give ourselves a bit more room to maneuver during the pre-release freeze period and restart once the 2.53 ships.
Diffstat (limited to 't')
-rw-r--r--t/helper/test-run-command.c67
-rwxr-xr-xt/t0061-run-command.sh38
2 files changed, 2 insertions, 103 deletions
diff --git a/t/helper/test-run-command.c b/t/helper/test-run-command.c
index 49eace8dce..3719f23cc2 100644
--- a/t/helper/test-run-command.c
+++ b/t/helper/test-run-command.c
@@ -23,26 +23,19 @@ static int number_callbacks;
static int parallel_next(struct child_process *cp,
struct strbuf *err,
void *cb,
- void **task_cb)
+ void **task_cb UNUSED)
{
struct child_process *d = cb;
if (number_callbacks >= 4)
return 0;
strvec_pushv(&cp->args, d->args.v);
- cp->in = d->in;
- cp->no_stdin = d->no_stdin;
if (err)
strbuf_addstr(err, "preloaded output of a child\n");
else
fprintf(stderr, "preloaded output of a child\n");
number_callbacks++;
-
- /* test_stdin callback will use this to count remaining lines */
- *task_cb = xmalloc(sizeof(int));
- *(int*)(*task_cb) = 2;
-
return 1;
}
@@ -58,61 +51,18 @@ static int no_job(struct child_process *cp UNUSED,
return 0;
}
-static void test_divert_output(struct strbuf *output, void *cb UNUSED)
-{
- FILE *output_file;
-
- output_file = fopen("./output_file", "a");
-
- strbuf_write(output, output_file);
- fclose(output_file);
-}
-
static int task_finished(int result UNUSED,
struct strbuf *err,
void *pp_cb UNUSED,
- void *pp_task_cb)
+ void *pp_task_cb UNUSED)
{
if (err)
strbuf_addstr(err, "asking for a quick stop\n");
else
fprintf(stderr, "asking for a quick stop\n");
-
- FREE_AND_NULL(pp_task_cb);
-
return 1;
}
-static int task_finished_quiet(int result UNUSED,
- struct strbuf *err UNUSED,
- void *pp_cb UNUSED,
- void *pp_task_cb)
-{
- FREE_AND_NULL(pp_task_cb);
- return 0;
-}
-
-static int test_stdin_pipe_feed(int hook_stdin_fd, void *cb UNUSED, void *task_cb)
-{
- int *lines_remaining = task_cb;
-
- if (*lines_remaining) {
- struct strbuf buf = STRBUF_INIT;
- strbuf_addf(&buf, "sample stdin %d\n", --(*lines_remaining));
- if (write_in_full(hook_stdin_fd, buf.buf, buf.len) < 0) {
- if (errno == EPIPE) {
- /* child closed stdin, nothing more to do */
- strbuf_release(&buf);
- return 1;
- }
- die_errno("write");
- }
- strbuf_release(&buf);
- }
-
- return !(*lines_remaining);
-}
-
struct testsuite {
struct string_list tests, failed;
int next;
@@ -207,8 +157,6 @@ static int testsuite(int argc, const char **argv)
struct run_process_parallel_opts opts = {
.get_next_task = next_test,
.start_failure = test_failed,
- .feed_pipe = test_stdin_pipe_feed,
- .consume_output = test_divert_output,
.task_finished = test_finished,
.data = &suite,
};
@@ -512,23 +460,12 @@ int cmd__run_command(int argc, const char **argv)
if (!strcmp(argv[1], "run-command-parallel")) {
opts.get_next_task = parallel_next;
- opts.task_finished = task_finished_quiet;
} else if (!strcmp(argv[1], "run-command-abort")) {
opts.get_next_task = parallel_next;
opts.task_finished = task_finished;
} else if (!strcmp(argv[1], "run-command-no-jobs")) {
opts.get_next_task = no_job;
opts.task_finished = task_finished;
- } else if (!strcmp(argv[1], "run-command-stdin")) {
- proc.in = -1;
- proc.no_stdin = 0;
- opts.get_next_task = parallel_next;
- opts.task_finished = task_finished_quiet;
- opts.feed_pipe = test_stdin_pipe_feed;
- } else if (!strcmp(argv[1], "run-command-divert-output")) {
- opts.get_next_task = parallel_next;
- opts.consume_output = test_divert_output;
- opts.task_finished = task_finished_quiet;
} else {
ret = 1;
fprintf(stderr, "check usage\n");
diff --git a/t/t0061-run-command.sh b/t/t0061-run-command.sh
index 74529e219e..76d4936a87 100755
--- a/t/t0061-run-command.sh
+++ b/t/t0061-run-command.sh
@@ -164,44 +164,6 @@ test_expect_success 'run_command runs ungrouped in parallel with more tasks than
test_line_count = 4 err
'
-test_expect_success 'run_command can divert output' '
- test_when_finished rm output_file &&
- test-tool run-command run-command-divert-output 3 sh -c "printf \"%s\n%s\n\" Hello World" 2>actual &&
- test_must_be_empty actual &&
- test_cmp expect output_file
-'
-
-test_expect_success 'run_command listens to stdin' '
- cat >expect <<-\EOF &&
- preloaded output of a child
- listening for stdin:
- sample stdin 1
- sample stdin 0
- preloaded output of a child
- listening for stdin:
- sample stdin 1
- sample stdin 0
- preloaded output of a child
- listening for stdin:
- sample stdin 1
- sample stdin 0
- preloaded output of a child
- listening for stdin:
- sample stdin 1
- sample stdin 0
- EOF
-
- write_script stdin-script <<-\EOF &&
- echo "listening for stdin:"
- while read line
- do
- echo "$line"
- done
- EOF
- test-tool run-command run-command-stdin 2 ./stdin-script 2>actual &&
- test_cmp expect actual
-'
-
cat >expect <<-EOF
preloaded output of a child
asking for a quick stop