Skip to content

Commit 22f0df7

Browse files
steadmongitster
authored andcommitted
test-tool run-command testsuite: get shell from env
When running tests through `test-tool run-command testsuite`, we currently hardcode `sh` as the command interpreter. As discussed in [1], this is incorrect, and we should be using the shell set in TEST_SHELL_PATH instead. Add a shell_path field in struct testsuite so that we can pass this to the task runner callback. If this is non-null, we'll use it as the argv[0] of the subprocess. Otherwise, we'll just execute the test program directly. We will use this feature in a later commit to enable running binary executable unit tests. However, for now when setting up the struct testsuite in testsuite(), use the value of TEST_SHELL_PATH if it's set, otherwise keep the original behavior by defaulting to `sh`. [1] https://lore.kernel.org/git/[email protected]/ Signed-off-by: Josh Steadmon <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 80bb227 commit 22f0df7

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

t/helper/test-run-command.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ struct testsuite {
6565
struct string_list tests, failed;
6666
int next;
6767
int quiet, immediate, verbose, verbose_log, trace, write_junit_xml;
68+
const char *shell_path;
6869
};
6970
#define TESTSUITE_INIT { \
7071
.tests = STRING_LIST_INIT_DUP, \
@@ -80,7 +81,9 @@ static int next_test(struct child_process *cp, struct strbuf *err, void *cb,
8081
return 0;
8182

8283
test = suite->tests.items[suite->next++].string;
83-
strvec_pushl(&cp->args, "sh", test, NULL);
84+
if (suite->shell_path)
85+
strvec_push(&cp->args, suite->shell_path);
86+
strvec_push(&cp->args, test);
8487
if (suite->quiet)
8588
strvec_push(&cp->args, "--quiet");
8689
if (suite->immediate)
@@ -162,6 +165,10 @@ static int testsuite(int argc, const char **argv)
162165
if (max_jobs <= 0)
163166
max_jobs = online_cpus();
164167

168+
suite.shell_path = getenv("TEST_SHELL_PATH");
169+
if (!suite.shell_path)
170+
suite.shell_path = "sh";
171+
165172
dir = opendir(".");
166173
if (!dir)
167174
die("Could not open the current directory");

0 commit comments

Comments
 (0)