[glib] gtestutils: forbid having two tests with the same full path
- From: Dan Winship <danw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] gtestutils: forbid having two tests with the same full path
- Date: Mon, 31 Aug 2015 18:18:49 +0000 (UTC)
commit 367f36d630afa01b0967547f5a038a1f8f499f45
Author: Dan Winship <danw gnome org>
Date: Fri Dec 12 12:47:00 2014 -0500
gtestutils: forbid having two tests with the same full path
In the same way that gtestutils used to let you create multiple suites
with the same name, it also let you create multiple tests with the
same name. Make that an error instead (and fix glib/tests/base64.c,
which was registering three separate tests named
"/base64/incremental/nobreak/4", and glib/tests/autoptr.c, which was
running test_g_variant_builder() twice).
https://bugzilla.gnome.org/show_bug.cgi?id=754286
glib/gtestutils.c | 16 +++++++++++++++-
glib/tests/autoptr.c | 1 -
glib/tests/base64.c | 6 +++---
3 files changed, 18 insertions(+), 5 deletions(-)
---
diff --git a/glib/gtestutils.c b/glib/gtestutils.c
index 7a483a9..0357ee9 100644
--- a/glib/gtestutils.c
+++ b/glib/gtestutils.c
@@ -1647,6 +1647,15 @@ find_suite (gconstpointer l, gconstpointer s)
return strcmp (suite->name, str);
}
+static gint
+find_case (gconstpointer l, gconstpointer s)
+{
+ const GTestCase *tc = l;
+ const gchar *str = s;
+
+ return strcmp (tc->name, str);
+}
+
/**
* GTestFixtureFunc:
* @fixture: the test fixture
@@ -1712,7 +1721,12 @@ g_test_add_vtable (const char *testpath,
}
else /* islast */
{
- GTestCase *tc = g_test_create_case (seg, data_size, test_data, data_setup, fixture_test_func,
data_teardown);
+ GTestCase *tc;
+
+ if (g_slist_find_custom (suite->cases, seg, find_case))
+ g_error ("duplicate test case path: %s", testpath);
+
+ tc = g_test_create_case (seg, data_size, test_data, data_setup, fixture_test_func, data_teardown);
g_test_suite_add (suite, tc);
}
}
diff --git a/glib/tests/autoptr.c b/glib/tests/autoptr.c
index df9edd8..676ee07 100644
--- a/glib/tests/autoptr.c
+++ b/glib/tests/autoptr.c
@@ -438,7 +438,6 @@ main (int argc, gchar *argv[])
g_test_add_func ("/autoptr/g_tree", test_g_tree);
g_test_add_func ("/autoptr/g_variant", test_g_variant);
g_test_add_func ("/autoptr/g_variant_builder", test_g_variant_builder);
- g_test_add_func ("/autoptr/g_variant_builder", test_g_variant_builder);
g_test_add_func ("/autoptr/g_variant_iter", test_g_variant_iter);
g_test_add_func ("/autoptr/g_variant_dict", test_g_variant_dict);
g_test_add_func ("/autoptr/g_variant_type", test_g_variant_type);
diff --git a/glib/tests/base64.c b/glib/tests/base64.c
index 2d6b3a1..3d3ba60 100644
--- a/glib/tests/base64.c
+++ b/glib/tests/base64.c
@@ -394,9 +394,9 @@ main (int argc, char *argv[])
g_test_add_data_func ("/base64/incremental/nobreak/3", GINT_TO_POINTER (DATA_SIZE - 2),
test_incremental_nobreak);
g_test_add_data_func ("/base64/incremental/break/3", GINT_TO_POINTER (DATA_SIZE - 2),
test_incremental_break);
- g_test_add_data_func ("/base64/incremental/nobreak/4", GINT_TO_POINTER (1), test_incremental_nobreak);
- g_test_add_data_func ("/base64/incremental/nobreak/4", GINT_TO_POINTER (2), test_incremental_nobreak);
- g_test_add_data_func ("/base64/incremental/nobreak/4", GINT_TO_POINTER (3), test_incremental_nobreak);
+ g_test_add_data_func ("/base64/incremental/nobreak/4-a", GINT_TO_POINTER (1), test_incremental_nobreak);
+ g_test_add_data_func ("/base64/incremental/nobreak/4-b", GINT_TO_POINTER (2), test_incremental_nobreak);
+ g_test_add_data_func ("/base64/incremental/nobreak/4-c", GINT_TO_POINTER (3), test_incremental_nobreak);
g_test_add_func ("/base64/encode", test_base64_encode);
g_test_add_func ("/base64/decode", test_base64_decode);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]