diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2024-10-02 15:00:12 -0400 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2024-10-02 15:00:12 -0400 |
commit | 6fe8c2572fbf73cee3936ab241fcbfbdd54fe633 (patch) | |
tree | f7a96614aa54bc75512b52a9d8df2f035ca51b40 | |
parent | 9028e5ef90c1b7f5a42c6bf969ac3c838b570a7e (diff) | |
download | stasis-6fe8c2572fbf73cee3936ab241fcbfbdd54fe633.tar.gz |
Allow user to disable parallel mode (shortcut for --cpu-limit=1)
-rw-r--r-- | include/core.h | 5 | ||||
-rw-r--r-- | src/delivery_test.c | 2 | ||||
-rw-r--r-- | src/globals.c | 1 | ||||
-rw-r--r-- | src/stasis_main.c | 12 |
4 files changed, 15 insertions, 5 deletions
diff --git a/include/core.h b/include/core.h index ae0e8fe..e09b212 100644 --- a/include/core.h +++ b/include/core.h @@ -63,8 +63,9 @@ struct STASIS_GLOBAL { bool enable_testing; //!< Enable package testing bool enable_overwrite; //!< Enable release file clobbering bool enable_rewrite_spec_stage_2; //!< Enable automatic @STR@ replacement in output files - long cpu_limit; - long parallel_fail_fast; + bool enable_parallel; //!< Enable testing in parallel + long cpu_limit; //!< Limit parallel processing to n cores (default: max - 1) + long parallel_fail_fast; //!< Fail immediately on error int pool_status_interval; //!< Report "Task is running" every n seconds struct StrList *conda_packages; //!< Conda packages to install after initial activation struct StrList *pip_packages; //!< Pip packages to install after initial activation diff --git a/src/delivery_test.c b/src/delivery_test.c index d79e088..8ff08cc 100644 --- a/src/delivery_test.c +++ b/src/delivery_test.c @@ -130,7 +130,7 @@ void delivery_tests_run(struct Delivery *ctx) { char pool_name[100] = "parallel"; struct MultiProcessingTask *task = NULL; int selected = PARALLEL; - if (!test->parallel) { + if (!globals.enable_parallel || !test->parallel) { selected = SERIAL; memset(pool_name, 0, sizeof(pool_name)); strcpy(pool_name, "serial"); diff --git a/src/globals.c b/src/globals.c index b93566a..1b682cb 100644 --- a/src/globals.c +++ b/src/globals.c @@ -38,6 +38,7 @@ struct STASIS_GLOBAL globals = { .enable_artifactory_build_info = true, ///< Toggle build-info uploads .enable_testing = true, ///< Toggle [test] block "script" execution. "script_setup" always executes. .enable_rewrite_spec_stage_2 = true, ///< Leave template stings in output files + .enable_parallel = true, ///< Toggle testing in parallel .parallel_fail_fast = false, ///< Kill ALL multiprocessing tasks immediately on error .pool_status_interval = 30, ///< Report "Task is running" }; diff --git a/src/stasis_main.c b/src/stasis_main.c index 8f14e5f..2fcfcaf 100644 --- a/src/stasis_main.c +++ b/src/stasis_main.c @@ -13,7 +13,9 @@ #define OPT_OVERWRITE 1005 #define OPT_NO_REWRITE_SPEC_STAGE_2 1006 #define OPT_PARALLEL_FAIL_FAST 1007 +#define OPT_NO_PARALLEL 1008 #define OPT_POOL_STATUS_INTERVAL 1009 + static struct option long_options[] = { {"help", no_argument, 0, 'h'}, {"version", no_argument, 0, 'V'}, @@ -31,6 +33,7 @@ static struct option long_options[] = { {"no-artifactory", no_argument, 0, OPT_NO_ARTIFACTORY}, {"no-artifactory-build-info", no_argument, 0, OPT_NO_ARTIFACTORY_BUILD_INFO}, {"no-testing", no_argument, 0, OPT_NO_TESTING}, + {"no-parallel", no_argument, 0, OPT_NO_PARALLEL}, {"no-rewrite", no_argument, 0, OPT_NO_REWRITE_SPEC_STAGE_2}, {0, 0, 0, 0}, }; @@ -52,6 +55,7 @@ const char *long_options_help[] = { "Do not upload artifacts to Artifactory", "Do not upload build info objects to Artifactory", "Do not execute test scripts", + "Do not execute tests in parallel", "Do not rewrite paths and URLs in output files", NULL, }; @@ -224,7 +228,7 @@ int main(int argc, char *argv[]) { int user_disabled_docker = false; globals.cpu_limit = get_cpu_count(); if (globals.cpu_limit > 1) { - globals.cpu_limit--; + globals.cpu_limit--; // max - 1 } memset(env_name, 0, sizeof(env_name)); @@ -255,8 +259,9 @@ int main(int argc, char *argv[]) { break; case 'l': globals.cpu_limit = strtol(optarg, NULL, 10); - if (globals.cpu_limit < 1) { + if (globals.cpu_limit <= 1) { globals.cpu_limit = 1; + globals.enable_parallel = false; // No point } break; case OPT_ALWAYS_UPDATE_BASE: @@ -304,6 +309,9 @@ int main(int argc, char *argv[]) { case OPT_NO_REWRITE_SPEC_STAGE_2: globals.enable_rewrite_spec_stage_2 = false; break; + case OPT_NO_PARALLEL: + globals.enable_parallel = false; + break; case '?': default: exit(1); |