summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Garcia Campos <cgarcia@igalia.com>2011-11-25 15:39:31 +0100
committerCarlos Garcia Campos <carlosgc@gnome.org>2011-11-27 14:33:47 +0100
commit4ce5a11dafb0999aa26b36b32df18124e8ebd51d (patch)
treeb5715ff75e8c579bd421fd1c956bd3efe0ac5df8
parente4b7cfcb038c4e19d23fae19e0d68705dfef2d63 (diff)
gtester: Add command line option to skip tests
https://bugzilla.gnome.org/show_bug.cgi?id=664809
-rw-r--r--docs/reference/glib/gtester.xml7
-rw-r--r--glib/gtester.c18
-rw-r--r--glib/gtestutils.c17
3 files changed, 42 insertions, 0 deletions
diff --git a/docs/reference/glib/gtester.xml b/docs/reference/glib/gtester.xml
index 0ac13d322..dcaae7df9 100644
--- a/docs/reference/glib/gtester.xml
+++ b/docs/reference/glib/gtester.xml
@@ -82,6 +82,13 @@ only run test cases matching <replaceable>TESTPATH</replaceable>
</varlistentry>
<varlistentry>
+<term><option>-s=<replaceable>TESTPATH</replaceable></option></term>
+<listitem><para>
+skip test cases matching <replaceable>TESTPATH</replaceable>
+</para></listitem>
+</varlistentry>
+
+<varlistentry>
<term><option>--seed=<replaceable>SEEDSTRING</replaceable></option></term>
<listitem><para>
run all test cases with random number seed <replaceable>SEEDSTRING</replaceable>
diff --git a/glib/gtester.c b/glib/gtester.c
index b56708d66..df9d665ae 100644
--- a/glib/gtester.c
+++ b/glib/gtester.c
@@ -53,6 +53,7 @@ static gboolean subtest_mode_quick = TRUE;
static const gchar *subtest_seedstr = NULL;
static gchar *subtest_last_seed = NULL;
static GSList *subtest_paths = NULL;
+static GSList *skipped_paths = NULL;
static GSList *subtest_args = NULL;
static gboolean testcase_open = FALSE;
static guint testcase_count = 0;
@@ -315,6 +316,8 @@ launch_test_binary (const char *binary,
argc++;
for (slist = subtest_paths; slist; slist = slist->next)
argc++;
+ for (slist = skipped_paths; slist; slist = slist->next)
+ argc++;
/* setup argv */
argv = g_malloc ((argc + 2) * sizeof(gchar *));
@@ -343,6 +346,8 @@ launch_test_binary (const char *binary,
argv[i++] = queue_gfree (&free_list, g_strdup_printf ("--GTestSkipCount=%u", skip_tests));
for (slist = subtest_paths; slist; slist = slist->next)
argv[i++] = queue_gfree (&free_list, g_strdup_printf ("-p=%s", (gchar*) slist->data));
+ for (slist = skipped_paths; slist; slist = slist->next)
+ argv[i++] = queue_gfree (&free_list, g_strdup_printf ("-s=%s", (gchar*) slist->data));
argv[i++] = NULL;
g_spawn_async_with_pipes (NULL, /* g_get_current_dir() */
@@ -475,6 +480,7 @@ usage (gboolean just_version)
g_print (" -m=perf, -m=slow, -m=quick -m=thorough\n");
g_print (" run test cases in mode perf, slow/thorough or quick (default)\n");
g_print (" -p=TESTPATH only start test cases matching TESTPATH\n");
+ g_print (" -s=TESTPATH skip test cases matching TESTPATH\n");
g_print (" --seed=SEEDSTRING start all tests with random number seed SEEDSTRING\n");
g_print (" -o=LOGFILE write the test log to LOGFILE\n");
g_print (" -q, --quiet suppress per test binary output\n");
@@ -534,6 +540,18 @@ parse_args (gint *argc_p,
}
argv[i] = NULL;
}
+ else if (strcmp ("-s", argv[i]) == 0 || strncmp ("-s=", argv[i], 3) == 0)
+ {
+ gchar *equal = argv[i] + 2;
+ if (*equal == '=')
+ skipped_paths = g_slist_prepend (skipped_paths, equal + 1);
+ else if (i + 1 < argc)
+ {
+ argv[i++] = NULL;
+ skipped_paths = g_slist_prepend (skipped_paths, argv[i]);
+ }
+ argv[i] = NULL;
+ }
else if (strcmp ("--test-arg", argv[i]) == 0 || strncmp ("--test-arg=", argv[i], 11) == 0)
{
gchar *equal = argv[i] + 10;
diff --git a/glib/gtestutils.c b/glib/gtestutils.c
index d75198dde..d2bf68280 100644
--- a/glib/gtestutils.c
+++ b/glib/gtestutils.c
@@ -474,6 +474,7 @@ static guint test_skip_count = 0;
static GTimer *test_user_timer = NULL;
static double test_user_stamp = 0;
static GSList *test_paths = NULL;
+static GSList *test_paths_skipped = NULL;
static GTestSuite *test_suite_root = NULL;
static int test_trap_last_status = 0;
static int test_trap_last_pid = 0;
@@ -680,6 +681,18 @@ parse_args (gint *argc_p,
}
argv[i] = NULL;
}
+ else if (strcmp ("-s", argv[i]) == 0 || strncmp ("-s=", argv[i], 3) == 0)
+ {
+ gchar *equal = argv[i] + 2;
+ if (*equal == '=')
+ test_paths_skipped = g_slist_prepend (test_paths_skipped, equal + 1);
+ else if (i + 1 < argc)
+ {
+ argv[i++] = NULL;
+ test_paths_skipped = g_slist_prepend (test_paths_skipped, argv[i]);
+ }
+ argv[i] = NULL;
+ }
else if (strcmp ("-m", argv[i]) == 0 || strncmp ("-m=", argv[i], 3) == 0)
{
gchar *equal = argv[i] + 2;
@@ -748,6 +761,7 @@ parse_args (gint *argc_p,
" --verbose Run tests verbosely\n"
" -q, --quiet Run tests quietly\n"
" -p TESTPATH execute all tests matching TESTPATH\n"
+ " -s TESTPATH skip all tests matching TESTPATH\n"
" -m {perf|slow|thorough|quick} Execute tests according modes\n"
" --debug-log debug test logging output\n"
" -k, --keep-going gtester-specific argument\n"
@@ -1343,6 +1357,9 @@ g_test_add_vtable (const char *testpath,
g_return_if_fail (testpath[0] == '/');
g_return_if_fail (fixture_test_func != NULL);
+ if (g_slist_find_custom (test_paths_skipped, testpath, (GCompareFunc)g_strcmp0))
+ return;
+
suite = g_test_get_root();
segments = g_strsplit (testpath, "/", -1);
for (ui = 0; segments[ui] != NULL; ui++)