mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-12 23:46:17 +01:00
gtester: Add command line option to skip tests
https://bugzilla.gnome.org/show_bug.cgi?id=664809
This commit is contained in:
parent
e4b7cfcb03
commit
4ce5a11daf
@ -81,6 +81,13 @@ only run test cases matching <replaceable>TESTPATH</replaceable>
|
||||
</para></listitem>
|
||||
</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>
|
||||
|
@ -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;
|
||||
|
@ -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++)
|
||||
|
Loading…
Reference in New Issue
Block a user