tests: Allow getting data files from the tests/data directory

The units under the conformance test suite should be able to use
external files. Linking the files in tests/conform like the
interactive tests do seems like a hack piled on top of a hack, so
instead we should provide a programmatic way for a conformance
test unit to get the full path of a file, regardless of where the
tests/data directory is.

We can use a define to get the full path of tests/data and then
a function using g_build_filename() to construct the path to the
file we want.
This commit is contained in:
Emmanuele Bassi 2009-11-04 11:47:09 +00:00
parent 3e20468c6b
commit 7d891d9dd4
3 changed files with 17 additions and 6 deletions

View File

@ -71,17 +71,21 @@ clean-wrappers:
# a phony rule that will generate symlink scripts for running individual tests
BUILT_SOURCES = wrappers
test_conformance_CFLAGS = \
INCLUDES = \
-I$(top_srcdir)/ \
-I$(top_srcdir)/clutter \
-I$(top_srcdir)/clutter/cogl \
-I$(top_builddir)/clutter \
-I$(top_builddir)/clutter/cogl \
-DG_DISABLE_SINGLE_INCLUDES \
$(CLUTTER_CFLAGS) \
$(MAINTAINER_CFLAGS)
-I$(top_builddir)/clutter/cogl
test_conformance_LDADD = $(top_builddir)/clutter/libclutter-@CLUTTER_WINSYS@-@CLUTTER_API_VERSION@.la
test_conformance_CPPFLAGS = \
-DG_DISABLE_SINGLE_INCLUDES \
-DCLUTTER_DISABLE_DEPRECATED \
-DTESTS_DATADIR=\""$(top_srcdir)/tests/data"\"
test_conformance_CFLAGS = $(CLUTTER_CFLAGS) $(MAINTAINER_CFLAGS)
test_conformance_LDADD = $(top_builddir)/clutter/libclutter-@CLUTTER_WINSYS@-@CLUTTER_API_VERSION@.la $(CLUTTER_LIBS)
.PHONY: test
.PHONY: test-report test-report-normal test-report-disable-npots

View File

@ -24,3 +24,4 @@ void test_conform_simple_fixture_setup (TestConformSimpleFixture *fixture,
void test_conform_simple_fixture_teardown (TestConformSimpleFixture *fixture,
gconstpointer data);
gchar *clutter_test_get_data_file (const gchar *filename);

View File

@ -59,6 +59,12 @@ static TestConformSharedState *shared_state = NULL;
test_conform_skip_test, \
test_conform_simple_fixture_teardown); } G_STMT_END
gchar *
clutter_test_get_data_file (const gchar *filename)
{
return g_build_filename (TESTS_DATADIR, filename, NULL);
}
static void
clutter_test_init (gint *argc,
gchar ***argv)