[gdk-pixbuf/wip/otte/tga] Add a helper to run tests over directories
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gdk-pixbuf/wip/otte/tga] Add a helper to run tests over directories
- Date: Thu, 24 Sep 2015 02:58:29 +0000 (UTC)
commit b743abae702aa7ab7deb51d37a2e169d5f8d5980
Author: Matthias Clasen <mclasen redhat com>
Date: Wed Sep 23 22:55:26 2015 -0400
Add a helper to run tests over directories
This helper function recursively runs over a directory
and adds a test function for each file in the tree.
tests/test-common.c | 26 ++++++++++++++++++++++++++
tests/test-common.h | 4 ++++
2 files changed, 30 insertions(+), 0 deletions(-)
---
diff --git a/tests/test-common.c b/tests/test-common.c
index 7071d4c..dcaad65 100644
--- a/tests/test-common.c
+++ b/tests/test-common.c
@@ -99,3 +99,29 @@ pixdata_equal (GdkPixbuf *p1, GdkPixbuf *p2, GError **error)
return TRUE;
}
+
+void
+add_test_for_all_images (const gchar *prefix,
+ const gchar *path,
+ GTestDataFunc test_func)
+{
+ GDir *dir;
+ const gchar *name;
+
+ dir = g_dir_open (path, 0, NULL);
+ while ((name = g_dir_read_name (dir)) != NULL)
+ {
+ gchar *test_path;
+ gchar *dir_path;
+
+ test_path = g_strconcat (prefix, "/", name, NULL);
+ dir_path = g_strconcat (path, "/", name, NULL);
+ if (g_file_test (dir_path, G_FILE_TEST_IS_DIR))
+ add_test_for_all_images (test_path, dir_path, test_func);
+ else
+ g_test_add_data_func_full (test_path, g_strdup (dir_path), test_func, g_free);
+ g_free (test_path);
+ g_free (dir_path);
+ }
+ g_dir_close (dir);
+}
diff --git a/tests/test-common.h b/tests/test-common.h
index 56e4418..6fc9507 100644
--- a/tests/test-common.h
+++ b/tests/test-common.h
@@ -29,6 +29,10 @@ G_BEGIN_DECLS
gboolean format_supported (const gchar *filename);
gboolean pixdata_equal (GdkPixbuf *p1, GdkPixbuf *p2, GError **error);
+void add_test_for_all_images (const gchar *prefix,
+ const gchar *dir,
+ GTestDataFunc test_func);
+
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]