[gtksourceview] Fix installed tests to look load the right files
- From: Paolo Borelli <pborelli src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview] Fix installed tests to look load the right files
- Date: Sat, 7 Dec 2013 22:04:27 +0000 (UTC)
commit 8780a93009b7c0ec50718b39a089af27ad300c2f
Author: Paolo Borelli <pborelli gnome org>
Date: Sat Dec 7 21:23:11 2013 +0100
Fix installed tests to look load the right files
When running from the source checkout we want to setup the tests
to load the lang and style files from the source data dir, with
installed tests instead we want to use the ones installed in the
real XDG dir.
tests/Makefile.am | 13 ++++++++++++-
tests/test-buffer.c | 28 +++++++++++++++++++++-------
tests/test-language.c | 24 ++++++++++++++++++++----
tests/test-languagemanager.c | 28 +++++++++++++++++++++-------
tests/test-styleschememanager.c | 2 +-
5 files changed, 75 insertions(+), 20 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index f5b52bc..09d99aa 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -11,7 +11,6 @@ AM_CPPFLAGS = \
$(TESTS_CFLAGS)
noinst_PROGRAMS = $(TEST_PROGS) $(UNIT_TEST_PROGS)
-TESTS = $(UNIT_TEST_PROGS)
BUILT_SOURCES = \
test-completion-resources.c \
@@ -159,6 +158,9 @@ python_tests = \
test-completion.py \
test-widget.py
+TESTS_ENVIRONMENT = G_TEST_SRCDDIR="$(top_srcdir)/tests"
+TESTS = $(UNIT_TEST_PROGS)
+
EXTRA_DIST = \
language-specs/test-empty.lang \
language-specs/test-full.lang \
@@ -173,6 +175,15 @@ if INSTALLED_TESTS
insttestdir = ${libexecdir}/installed-tests/$(PACKAGE)
insttest_PROGRAMS = $(UNIT_TEST_PROGS)
+instteslangdir = ${libexecdir}/installed-tests/$(PACKAGE)/language-specs
+instteslang_DATA = \
+ language-specs/test-empty.lang \
+ language-specs/test-full.lang
+
+insttesstyledir = ${libexecdir}/installed-tests/$(PACKAGE)/styles
+insttesstyle_DATA = \
+ styles/classic.xml
+
%.test: %$(EXEEXT) Makefile
$(AM_V_GEN) (echo '[Test]' > $ tmp; \
echo 'Type=session' >> $ tmp; \
diff --git a/tests/test-buffer.c b/tests/test-buffer.c
index a0b7c6c..b2d34fc 100644
--- a/tests/test-buffer.c
+++ b/tests/test-buffer.c
@@ -11,19 +11,33 @@ static const char *c_snippet =
"int main() {\n"
"}\n";
+/* If we are running from the source dir (e.g. during make check)
+ * we override the path to read from the data dir
+ */
static void
init_default_manager (void)
{
- GtkSourceLanguageManager *lm;
- gchar **lang_dirs;
+ gchar *dir;
- lm = gtk_source_language_manager_get_default ();
+ dir = g_build_filename (TOP_SRCDIR, "data", "language-specs", NULL);
+
+ if (g_file_test (dir, G_FILE_TEST_IS_DIR))
+ {
+ GtkSourceLanguageManager *lm;
+ gchar **lang_dirs;
- lang_dirs = g_new0 (gchar *, 2);
- lang_dirs[0] = g_build_filename (TOP_SRCDIR, "data", "language-specs", NULL);
+ lm = gtk_source_language_manager_get_default ();
- gtk_source_language_manager_set_search_path (lm, lang_dirs);
- g_strfreev (lang_dirs);
+ lang_dirs = g_new0 (gchar *, 2);
+ lang_dirs[0] = dir;
+
+ gtk_source_language_manager_set_search_path (lm, lang_dirs);
+ g_strfreev (lang_dirs);
+ }
+ else
+ {
+ g_free (dir);
+ }
}
static void
diff --git a/tests/test-language.c b/tests/test-language.c
index be412e7..9266f9c 100644
--- a/tests/test-language.c
+++ b/tests/test-language.c
@@ -12,17 +12,33 @@ struct _TestFixture {
GtkSourceLanguageManager *manager;
};
+/* If we are running from the source dir (e.g. during make check)
+ * we override the path to read from the data dir
+ */
static void
test_fixture_setup (TestFixture *fixture,
gconstpointer data)
{
+ gchar *dir;
gchar **lang_dirs;
+ dir = g_build_filename (TOP_SRCDIR, "data", "language-specs", NULL);
+
fixture->manager = gtk_source_language_manager_get_default ();
- lang_dirs = g_new0 (gchar *, 3);
- lang_dirs[0] = g_build_filename (TOP_SRCDIR, "tests", "language-specs", NULL);
- lang_dirs[1] = g_build_filename (TOP_SRCDIR, "data", "language-specs", NULL);
+ if (g_file_test (dir, G_FILE_TEST_IS_DIR))
+ {
+ lang_dirs = g_new0 (gchar *, 3);
+ lang_dirs[0] = dir;
+ lang_dirs[1] = g_test_build_filename (G_TEST_DIST, "language-specs", NULL);
+ }
+ else
+ {
+ g_free (dir);
+
+ lang_dirs = g_new0 (gchar *, 2);
+ lang_dirs[0] = g_test_build_filename (G_TEST_DIST, "language-specs", NULL);
+ }
gtk_source_language_manager_set_search_path (fixture->manager, lang_dirs);
g_strfreev (lang_dirs);
@@ -64,7 +80,7 @@ check_language (GtkSourceLanguage *language,
gchar **expected_mime,
gchar **expected_glob,
gchar **expected_styles,
- const char *style_id,
+ const char *style_id,
const char *expected_style_name)
{
gchar **mime;
diff --git a/tests/test-languagemanager.c b/tests/test-languagemanager.c
index 2515fc4..7744b9c 100644
--- a/tests/test-languagemanager.c
+++ b/tests/test-languagemanager.c
@@ -1,19 +1,33 @@
#include <gtk/gtk.h>
#include <gtksourceview/gtksource.h>
+/* If we are running from the source dir (e.g. during make check)
+ * we override the path to read from the data dir
+ */
static void
init_default_manager (void)
{
- GtkSourceLanguageManager *lm;
- gchar **lang_dirs;
+ gchar *dir;
- lm = gtk_source_language_manager_get_default ();
+ dir = g_build_filename (TOP_SRCDIR, "data", "language-specs", NULL);
+
+ if (g_file_test (dir, G_FILE_TEST_IS_DIR))
+ {
+ GtkSourceLanguageManager *lm;
+ gchar **lang_dirs;
- lang_dirs = g_new0 (gchar *, 2);
- lang_dirs[0] = g_build_filename (TOP_SRCDIR, "data", "language-specs", NULL);
+ lm = gtk_source_language_manager_get_default ();
- gtk_source_language_manager_set_search_path (lm, lang_dirs);
- g_strfreev (lang_dirs);
+ lang_dirs = g_new0 (gchar *, 2);
+ lang_dirs[0] = dir;
+
+ gtk_source_language_manager_set_search_path (lm, lang_dirs);
+ g_strfreev (lang_dirs);
+ }
+ else
+ {
+ g_free (dir);
+ }
}
static void
diff --git a/tests/test-styleschememanager.c b/tests/test-styleschememanager.c
index 7fdccac..9f56e2a 100644
--- a/tests/test-styleschememanager.c
+++ b/tests/test-styleschememanager.c
@@ -22,7 +22,7 @@ test_prepend_search_path (void)
sm = gtk_source_style_scheme_manager_get_default ();
- style_dir = g_build_filename (TOP_SRCDIR, "tests", "styles", NULL);
+ style_dir = g_test_build_filename (G_TEST_DIST, "styles", NULL);
gtk_source_style_scheme_manager_prepend_search_path (sm, style_dir);
scheme = gtk_source_style_scheme_manager_get_scheme (sm, "classic");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]