[gtksourceview] testsuite: add test to load all language specs
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview] testsuite: add test to load all language specs
- Date: Thu, 15 Jul 2021 23:19:05 +0000 (UTC)
commit 45bd8197c5f1e63e6441a1b53fefb5f70a4d3868
Author: Christian Hergert <chergert redhat com>
Date: Thu Jul 15 16:15:22 2021 -0700
testsuite: add test to load all language specs
testsuite/meson.build | 1 +
testsuite/test-language-specs.c | 97 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 98 insertions(+)
---
diff --git a/testsuite/meson.build b/testsuite/meson.build
index bc00a4c3..4bd0f6ea 100644
--- a/testsuite/meson.build
+++ b/testsuite/meson.build
@@ -25,6 +25,7 @@ testsuite_sources = [
['test-iter'],
['test-language'],
['test-languagemanager'],
+ ['test-language-specs'],
['test-mark'],
['test-printcompositor'],
['test-regex'],
diff --git a/testsuite/test-language-specs.c b/testsuite/test-language-specs.c
new file mode 100644
index 00000000..f1f54e90
--- /dev/null
+++ b/testsuite/test-language-specs.c
@@ -0,0 +1,97 @@
+#include <gtksourceview/gtksource.h>
+
+static GHashTable *skipped;
+
+static void
+test_func (gconstpointer data)
+{
+ GtkSourceLanguageManager *lm = gtk_source_language_manager_get_default ();
+ const char *language_id = data;
+ GtkSourceLanguage *l;
+ GtkSourceBuffer *buffer;
+
+ g_assert (GTK_SOURCE_IS_LANGUAGE_MANAGER (lm));
+ g_assert (data != NULL);
+
+ if (g_hash_table_contains (skipped, language_id))
+ {
+ char *message = g_strdup_printf ("skipping known failure for %s", language_id);
+ g_test_skip (message);
+ g_free (message);
+ return;
+ }
+
+ l = gtk_source_language_manager_get_language (lm, language_id);
+ g_assert_nonnull (l);
+
+ buffer = g_object_new (GTK_SOURCE_TYPE_BUFFER,
+ "language", l,
+ "highlight-syntax", TRUE,
+ NULL);
+
+ g_object_unref (buffer);
+}
+
+int
+main (int argc,
+ char *argv[])
+{
+ GtkSourceLanguageManager *lm;
+ const char * const *ids;
+ char *language_specs;
+ char *search_path[2];
+ const char *srcdir = g_getenv ("G_TEST_SRCDIR");
+ GPtrArray *strings;
+ int ret;
+
+ g_assert_nonnull (srcdir);
+
+ language_specs = g_build_filename (srcdir, "..", "data", "language-specs", NULL);
+ search_path[0] = language_specs;
+ search_path[1] = 0;
+
+ g_test_init (&argc, &argv, NULL);
+ gtk_source_init ();
+
+ skipped = g_hash_table_new (g_str_hash, g_str_equal);
+
+ g_hash_table_add (skipped, (char *)"gdb-log");
+ g_hash_table_add (skipped, (char *)"jsdoc");
+ g_hash_table_add (skipped, (char *)"js-expr");
+ g_hash_table_add (skipped, (char *)"js-fn");
+ g_hash_table_add (skipped, (char *)"js-lit");
+ g_hash_table_add (skipped, (char *)"js-mod");
+ g_hash_table_add (skipped, (char *)"js-st");
+ g_hash_table_add (skipped, (char *)"js-val");
+ g_hash_table_add (skipped, (char *)"typescript-js-expr");
+ g_hash_table_add (skipped, (char *)"typescript-js-fn");
+ g_hash_table_add (skipped, (char *)"typescript-js-lit");
+ g_hash_table_add (skipped, (char *)"typescript-js-mod");
+ g_hash_table_add (skipped, (char *)"typescript-js-st");
+ g_hash_table_add (skipped, (char *)"typescript-type-expr");
+ g_hash_table_add (skipped, (char *)"typescript-type-gen");
+ g_hash_table_add (skipped, (char *)"typescript-type-lit");
+ g_hash_table_add (skipped, (char *)"gtk-doc");
+ g_hash_table_add (skipped, (char *)"testv1");
+
+ strings = g_ptr_array_new_with_free_func (g_free);
+ lm = gtk_source_language_manager_get_default ();
+ gtk_source_language_manager_set_search_path (lm, (const char * const *)search_path);
+
+ ids = gtk_source_language_manager_get_language_ids (lm);
+
+ for (guint i = 0; ids[i]; i++)
+ {
+ char *path = g_strdup_printf ("/Language/%s/load", ids[i]);
+ g_ptr_array_add (strings, path);
+ g_test_add_data_func (path, ids[i], test_func);
+ }
+
+ ret = g_test_run ();
+
+ g_ptr_array_unref (strings);
+ g_hash_table_unref (skipped);
+ g_free (language_specs);
+
+ return ret;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]