[gnome-desktop-testing/optional-parallel-argument: 2/2] Allow --parallel to mean 'dynamic'
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-desktop-testing/optional-parallel-argument: 2/2] Allow --parallel to mean 'dynamic'
- Date: Fri, 17 Sep 2021 16:09:48 +0000 (UTC)
commit 1f8dc393ccaacdaf86be7e103c93afea27e0fa8e
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Sep 17 12:08:19 2021 -0400
Allow --parallel to mean 'dynamic'
Having to specify --parallel=0 for 'maximum parallel'
is unintuitive, so allos --parallel without argument
to mean the same.
Fixes: #2
gnome-desktop-testing-runner.1 | 4 ++--
src/gnome-desktop-testing-runner.c | 25 ++++++++++++++++++++++++-
2 files changed, 26 insertions(+), 3 deletions(-)
---
diff --git a/gnome-desktop-testing-runner.1 b/gnome-desktop-testing-runner.1
index 358ba62..728dc89 100644
--- a/gnome-desktop-testing-runner.1
+++ b/gnome-desktop-testing-runner.1
@@ -72,8 +72,8 @@ access to the Journal is awkward, such as shell script or JavaScript.
.TP
\fB--parallel=\fIPROC\fR, \fB-p\fR \fIPROC\fR
Run up to \fIPROC\fR tests in parallel. The default is 1, meaning do not
-run tests in parallel. If \fIPROC\fR is 0, detect the number of CPUs and
-run that many tests in parallel.
+run tests in parallel. If \fIPROC\fR is 0 or omitted, detect the number of
+CPUs and run that many tests in parallel.
.TP
\fB--quiet\fR
diff --git a/src/gnome-desktop-testing-runner.c b/src/gnome-desktop-testing-runner.c
index da49e14..c63afb4 100644
--- a/src/gnome-desktop-testing-runner.c
+++ b/src/gnome-desktop-testing-runner.c
@@ -393,10 +393,33 @@ static char **opt_dirs;
static char *opt_status;
static char *opt_log_msgid;
+static gboolean
+parse_parallel (const char *option_name,
+ const char *value,
+ gpointer data,
+ GError **error)
+{
+ if (value == NULL)
+ {
+ opt_parallel = 0;
+ }
+ else
+ {
+ guint64 num;
+
+ if (!g_ascii_string_to_unsigned (value, 10, 0, 65536, &num, error))
+ return FALSE;
+
+ opt_parallel = (int) num;
+ }
+
+ return TRUE;
+}
+
static GOptionEntry options[] = {
{ "dir", 'd', 0, G_OPTION_ARG_STRING_ARRAY, &opt_dirs, "Only run tests from these dirs (default: all
system data dirs)", "DIR" },
{ "list", 'l', 0, G_OPTION_ARG_NONE, &opt_list, "List matching tests", NULL },
- { "parallel", 'p', 0, G_OPTION_ARG_INT, &opt_parallel, "Specify parallelization to PROC processors; 0 will
be dynamic)", "PROC" },
+ { "parallel", 'p', 0, G_OPTION_ARG_CALLBACK, &parse_parallel, "Specify parallelization to PROC processors;
omit the argument for dynamic)", "PROC" },
{ "first-root", 0, 0, G_OPTION_ARG_NONE, &opt_firstroot, "Only use first entry in XDG_DATA_DIRS", NULL },
{ "log-directory", 'L', 0, G_OPTION_ARG_FILENAME, &opt_log_directory, "Create a subdirectory with test
logs", "DIR" },
{ "report-directory", 0, 0, G_OPTION_ARG_FILENAME, &opt_report_directory, "Create a subdirectory per
failing test in DIR", "DIR" },
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]