aboutsummaryrefslogtreecommitdiff
path: root/src/template_func_proto.c
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2024-09-13 09:58:17 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2024-09-18 23:06:08 -0400
commit8f17199d16bcdb29516d34514f95d1a117f6bd26 (patch)
tree15b96d2d2ab577472fcf392aea7cc4f15f8de360 /src/template_func_proto.c
parentb7251ce3bf65bcbec7ecbb98a0eb0b3c9abde507 (diff)
downloadstasis-8f17199d16bcdb29516d34514f95d1a117f6bd26.tar.gz
Implement multiprocessing pool(s)
* Adds --cpu-limit and --parallel-fail-fast arguments * Adds disable, parallel, and setup_script keys to [test] blocks
Diffstat (limited to 'src/template_func_proto.c')
-rw-r--r--src/template_func_proto.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/template_func_proto.c b/src/template_func_proto.c
index 3cf66e4..ebb595e 100644
--- a/src/template_func_proto.c
+++ b/src/template_func_proto.c
@@ -109,4 +109,41 @@ int get_basetemp_dir_entrypoint(void *frame, void *data_out) {
sprintf(*output, "%s/truth-%s-%s", ctx->storage.tmpdir, name, ctx->info.release_name);
return result;
+}
+
+int tox_run_entrypoint(void *frame, void *data_out) {
+ char **output = (char **) data_out;
+ struct tplfunc_frame *f = (struct tplfunc_frame *) frame;
+ const struct Delivery *ctx = (const struct Delivery *) f->data_in;
+
+ // Apply workaround for tox positional arguments
+ char *toxconf = NULL;
+ if (!access("tox.ini", F_OK)) {
+ if (!fix_tox_conf("tox.ini", &toxconf)) {
+ msg(STASIS_MSG_L3, "Fixing tox positional arguments\n");
+ *output = calloc(STASIS_BUFSIZ, sizeof(**output));
+ if (!*output) {
+ return -1;
+ }
+ char *basetemp_path = NULL;
+ if (get_basetemp_dir_entrypoint(f, &basetemp_path)) {
+ return -2;
+ }
+ char *jxml_path = NULL;
+ if (get_junitxml_file_entrypoint(f, &jxml_path)) {
+ return -3;
+ }
+ const char *tox_target = f->argv[0].t_char_ptr;
+ const char *pytest_args = f->argv[1].t_char_ptr;
+ if (isempty(toxconf) || !strcmp(toxconf, "/")) {
+ SYSERROR("Unsafe toxconf path: '%s'", toxconf);
+ return -4;
+ }
+ snprintf(*output, STASIS_BUFSIZ - 1, "\npip install tox && (tox -e py%s%s -c %s --root . -- --basetemp=\"%s\" --junitxml=\"%s\" %s ; rm -f '%s')\n", ctx->meta.python_compact, tox_target, toxconf, basetemp_path, jxml_path, pytest_args ? pytest_args : "", toxconf);
+
+ guard_free(jxml_path);
+ guard_free(basetemp_path);
+ }
+ }
+ return 0;
} \ No newline at end of file