run-command tests: use strvec_pushv(), not argv assignment

As in the preceding commit change this API user to use strvec_pushv() instead of assigning to the "argv" member directly. This leaves us without test coverage of how the "argv" assignment in this API works, but we'll be removing it in a subsequent commit. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ævar Arnfjörð Bjarmason committed Nov 25, 2021 at 23:52 UTC 87ee87dd6bb633cd5171e244fb69cd4b66d294aa
1 file changed +5 -4
t/helper/test-run-command.c
+5 -4
@@ -31,7 +31,7 @@ static int parallel_next(struct child_process *cp,
31 if (number_callbacks >= 4)
32 return 0;
33
34 - strvec_pushv(&cp->args, d->argv);
34 + strvec_pushv(&cp->args, d->args.v);
35 strbuf_addstr(err, "preloaded output of a child\n");
36 number_callbacks++;
37 return 1;
@@ -274,7 +274,7 @@ static int quote_stress_test(int argc, const char **argv)
274 if (i < skip)
275 continue;
276
277 - cp.argv = args.v;
277 + strvec_pushv(&cp.args, args.v);
278 strbuf_reset(&out);
279 if (pipe_command(&cp, NULL, 0, &out, 0, NULL, 0) < 0)
280 return error("Failed to spawn child process");
@@ -396,7 +396,7 @@ int cmd__run_command(int argc, const char **argv)
396 }
397 if (argc < 3)
398 return 1;
399 - proc.argv = (const char **)argv + 2;
399 + strvec_pushv(&proc.args, (const char **)argv + 2);
400
401 if (!strcmp(argv[1], "start-command-ENOENT")) {
402 if (start_command(&proc) < 0 && errno == ENOENT)
@@ -408,7 +408,8 @@ int cmd__run_command(int argc, const char **argv)
408 exit(run_command(&proc));
409
410 jobs = atoi(argv[2]);
411 - proc.argv = (const char **)argv + 3;
411 + strvec_clear(&proc.args);
412 + strvec_pushv(&proc.args, (const char **)argv + 3);
413
414 if (!strcmp(argv[1], "run-command-parallel"))
415 exit(run_processes_parallel(jobs, parallel_next,