aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2024-10-21 12:11:05 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2024-10-21 12:11:05 -0400
commit5d21c2c6eab632cc519eb23e529c2d985ac04921 (patch)
tree1d6675040d6ff6ade3457e6133b38a36694eba47
parentf954efd16b99520720d05abde5ec8ff741faa2dd (diff)
downloadstasis-5d21c2c6eab632cc519eb23e529c2d985ac04921.tar.gz
Change signature:
* delivery_gather_tool_versions now returns non-zero if unable to determine a tool's version
-rw-r--r--include/delivery.h2
-rw-r--r--src/cli/stasis/stasis_main.c17
-rw-r--r--src/lib/core/delivery.c14
-rw-r--r--tests/test_conda.c7
4 files changed, 27 insertions, 13 deletions
diff --git a/include/delivery.h b/include/delivery.h
index bd5137c..345cd13 100644
--- a/include/delivery.h
+++ b/include/delivery.h
@@ -385,7 +385,7 @@ void delivery_install_conda(char *install_script, char *conda_install_dir);
int delivery_format_str(struct Delivery *ctx, char **dest, const char *fmt);
// helper function
-void delivery_gather_tool_versions(struct Delivery *ctx);
+int delivery_gather_tool_versions(struct Delivery *ctx);
// helper function
int delivery_init_tmpdir(struct Delivery *ctx);
diff --git a/src/cli/stasis/stasis_main.c b/src/cli/stasis/stasis_main.c
index 5325892..c2443d7 100644
--- a/src/cli/stasis/stasis_main.c
+++ b/src/cli/stasis/stasis_main.c
@@ -332,14 +332,15 @@ int main(int argc, char *argv[]) {
exit(1);
}
- delivery_gather_tool_versions(&ctx);
- if (!ctx.conda.tool_version) {
- msg(STASIS_MSG_ERROR | STASIS_MSG_L2, "Could not determine conda version\n");
- exit(1);
- }
- if (!ctx.conda.tool_build_version) {
- msg(STASIS_MSG_ERROR | STASIS_MSG_L2, "Could not determine conda-build version\n");
- exit(1);
+ if (delivery_gather_tool_versions(&ctx)) {
+ if (!ctx.conda.tool_version) {
+ msg(STASIS_MSG_ERROR | STASIS_MSG_L2, "Could not determine conda version\n");
+ exit(1);
+ }
+ if (!ctx.conda.tool_build_version) {
+ msg(STASIS_MSG_ERROR | STASIS_MSG_L2, "Could not determine conda-build version\n");
+ exit(1);
+ }
}
if (pip_exec("install build")) {
diff --git a/src/lib/core/delivery.c b/src/lib/core/delivery.c
index e32ed4c..5645dcc 100644
--- a/src/lib/core/delivery.c
+++ b/src/lib/core/delivery.c
@@ -302,16 +302,22 @@ void delivery_defer_packages(struct Delivery *ctx, int type) {
}
}
-void delivery_gather_tool_versions(struct Delivery *ctx) {
- int status = 0;
+int delivery_gather_tool_versions(struct Delivery *ctx) {
+ int status_tool_version = 0;
+ int status_tool_build_version = 0;
// Extract version from tool output
- ctx->conda.tool_version = shell_output("conda --version", &status);
+ ctx->conda.tool_version = shell_output("conda --version", &status_tool_version);
if (ctx->conda.tool_version)
strip(ctx->conda.tool_version);
- ctx->conda.tool_build_version = shell_output("conda build --version", &status);
+ ctx->conda.tool_build_version = shell_output("conda build --version", &status_tool_build_version);
if (ctx->conda.tool_build_version)
strip(ctx->conda.tool_version);
+
+ if (status_tool_version || status_tool_build_version) {
+ return 1;
+ }
+ return 0;
}
diff --git a/tests/test_conda.c b/tests/test_conda.c
index 2ed869a..c379216 100644
--- a/tests/test_conda.c
+++ b/tests/test_conda.c
@@ -126,6 +126,13 @@ void test_conda_index() {
STASIS_ASSERT(conda_index("channel") == 0, "cannot index a simple conda channel");
}
+void test_delivery_gather_tool_versions() {
+ int status = delivery_gather_tool_versions(&ctx);
+ STASIS_ASSERT(status == 0, "Failed to gather tool versions");
+ STASIS_ASSERT(!isempty(ctx.conda.tool_version), "conda version is empty");
+ STASIS_ASSERT(!isempty(ctx.conda.tool_build_version), "conda_build version is empty");
+}
+
int main(int argc, char *argv[]) {
STASIS_TEST_BEGIN_MAIN();
STASIS_TEST_FUNC *tests[] = {