aboutsummaryrefslogtreecommitdiff
path: root/src/template_func_proto.c
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@users.noreply.github.com>2024-08-15 15:27:45 -0400
committerGitHub <noreply@github.com>2024-08-15 15:27:45 -0400
commitc069d0da7645eb1e596a53178960149224af8d48 (patch)
tree4f69e4ec146bbbae85f64207fac795b03060cd59 /src/template_func_proto.c
parentcc5fa8b386200cce03ef8a081acccc92dc44ddfb (diff)
downloadstasis-c069d0da7645eb1e596a53178960149224af8d48.tar.gz
Add template convience functions (and bug fixes) (#29)
* Die when render variable is NULL * This was caught when a call to {{ func:xyz() }} lacked opening/closing parenthesis * Scripts in tests should only render template strings right before execution * Remove conda version pin * This avoids updating conda in the base environment * This also avoids pitfalls associated with newly released (always broken) versions of conda * Add two template convenience functions * get_junitxml_result_auto() * get_basetemp_result_auto() * Handle rendering error for test script * Rename functions * get_junitxml_result_auto -> junitxml_file * get_basetemp_result_auto -> basetemp_dir * Thank you, @zacharyburnett
Diffstat (limited to 'src/template_func_proto.c')
-rw-r--r--src/template_func_proto.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/template_func_proto.c b/src/template_func_proto.c
index 92ae355..3cf66e4 100644
--- a/src/template_func_proto.c
+++ b/src/template_func_proto.c
@@ -66,3 +66,47 @@ int get_github_release_notes_auto_tplfunc_entrypoint(void *frame, void *data_out
return result;
}
+
+int get_junitxml_file_entrypoint(void *frame, void *data_out) {
+ int result = 0;
+ char **output = (char **) data_out;
+ struct tplfunc_frame *f = (struct tplfunc_frame *) frame;
+ const struct Delivery *ctx = (const struct Delivery *) f->data_in;
+
+ char cwd[PATH_MAX] = {0};
+ getcwd(cwd, PATH_MAX - 1);
+ char nametmp[PATH_MAX] = {0};
+ strcpy(nametmp, cwd);
+ char *name = path_basename(nametmp);
+
+ *output = calloc(PATH_MAX, sizeof(**output));
+ if (!*output) {
+ SYSERROR("failed to allocate output string: %s", strerror(errno));
+ return -1;
+ }
+ sprintf(*output, "%s/results-%s-%s.xml", ctx->storage.results_dir, name, ctx->info.release_name);
+
+ return result;
+}
+
+int get_basetemp_dir_entrypoint(void *frame, void *data_out) {
+ int result = 0;
+ char **output = (char **) data_out;
+ struct tplfunc_frame *f = (struct tplfunc_frame *) frame;
+ const struct Delivery *ctx = (const struct Delivery *) f->data_in;
+
+ char cwd[PATH_MAX] = {0};
+ getcwd(cwd, PATH_MAX - 1);
+ char nametmp[PATH_MAX] = {0};
+ strcpy(nametmp, cwd);
+ char *name = path_basename(nametmp);
+
+ *output = calloc(PATH_MAX, sizeof(**output));
+ if (!*output) {
+ SYSERROR("failed to allocate output string: %s", strerror(errno));
+ return -1;
+ }
+ sprintf(*output, "%s/truth-%s-%s", ctx->storage.tmpdir, name, ctx->info.release_name);
+
+ return result;
+} \ No newline at end of file