From a31a9b7ef81f47d6972a2a74fe9c660c4d250d55 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Thu, 14 Mar 2024 16:04:09 -0400 Subject: Add fix_tox_conf function * If the user calls tox in a test script like so: tox {{ workaround.tox_posargs }}, then a temporary tox configuration will be generated and the appropriate arguments to use it will be injected into tox's command line arguments --- src/deliverable.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/deliverable.c') diff --git a/src/deliverable.c b/src/deliverable.c index 0ddf17a..0b166d9 100644 --- a/src/deliverable.c +++ b/src/deliverable.c @@ -1393,6 +1393,20 @@ void delivery_tests_run(struct Delivery *ctx) { msg(OMC_MSG_L3, "Testing %s\n", ctx->tests[i].name); memset(&proc, 0, sizeof(proc)); + // Apply workaround for tox positional arguments + char *toxconf = NULL; + if (!access("tox.ini", F_OK)) { + msg(OMC_MSG_L3, "Fixing tox positional arguments\n"); + + fix_tox_conf("tox.ini", &toxconf); + if (!globals.workaround.tox_posargs) { + globals.workaround.tox_posargs = calloc(PATH_MAX, sizeof(*globals.workaround.tox_posargs)); + } else { + memset(globals.workaround.tox_posargs, 0, PATH_MAX); + } + snprintf(globals.workaround.tox_posargs, PATH_MAX - 1, "-c %s --root .", toxconf); + } + // enable trace mode before executing each test script memset(cmd, 0, sizeof(cmd)); sprintf(cmd, "set -x ; %s", ctx->tests[i].script); @@ -1410,6 +1424,11 @@ void delivery_tests_run(struct Delivery *ctx) { msg(OMC_MSG_ERROR, "Script failure: %s\n%s\n\nExit code: %d\n", ctx->tests[i].name, ctx->tests[i].script, status); COE_CHECK_ABORT(!globals.continue_on_error, "Test failure") } + + if (toxconf) { + remove(toxconf); + guard_free(toxconf); + } popd(); #else msg(OMC_MSG_WARNING | OMC_MSG_L3, "TESTING DISABLED BY CODE!\n"); -- cgit