[gnome-builder] test-manager: implement test reloading
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] test-manager: implement test reloading
- Date: Sun, 17 Dec 2017 08:33:08 +0000 (UTC)
commit d17f0239d6fa6fe9abe98a4645ea3d04758d2fd7
Author: Christian Hergert <chergert redhat com>
Date: Sun Dec 17 00:31:44 2017 -0800
test-manager: implement test reloading
If for some reason the system gets a bit messed up due to build
failures, this allows the user to reload tests manually.
src/libide/testing/ide-test-manager.c | 12 ++++++++++++
src/libide/testing/ide-test-provider.c | 17 +++++++++++++++++
src/libide/testing/ide-test-provider.h | 3 +++
src/plugins/meson/gbp-meson-test-provider.c | 21 +++++++++++++++++----
4 files changed, 49 insertions(+), 4 deletions(-)
---
diff --git a/src/libide/testing/ide-test-manager.c b/src/libide/testing/ide-test-manager.c
index 51311ac..47d3ff7 100644
--- a/src/libide/testing/ide-test-manager.c
+++ b/src/libide/testing/ide-test-manager.c
@@ -348,6 +348,8 @@ ide_test_manager_provider_items_changed (IdeTestManager *self,
for (guint j = 0; j < removed; j++)
{
IdeTest *test = g_ptr_array_index (info->tests, position);
+
+ g_assert (IDE_IS_TEST (test));
ide_test_manager_remove_test (self, info, test);
}
@@ -357,6 +359,7 @@ ide_test_manager_provider_items_changed (IdeTestManager *self,
g_autoptr(IdeTest) test = NULL;
test = g_list_model_get_item (G_LIST_MODEL (provider), position + j);
+ g_assert (IDE_IS_TEST (test));
ide_test_manager_add_test (self, info, position + j, test);
}
}
@@ -783,6 +786,15 @@ ide_test_manager_actions_reload (IdeTestManager *self,
GVariant *param)
{
g_assert (IDE_IS_TEST_MANAGER (self));
+
+ gtk_tree_store_clear (self->tests_store);
+
+ for (guint i = 0; i < self->tests_by_provider->len; i++)
+ {
+ const TestsByProvider *info = g_ptr_array_index (self->tests_by_provider, i);
+
+ ide_test_provider_reload (info->provider);
+ }
}
GtkTreeModel *
diff --git a/src/libide/testing/ide-test-provider.c b/src/libide/testing/ide-test-provider.c
index 2a5b032..70a1ba8 100644
--- a/src/libide/testing/ide-test-provider.c
+++ b/src/libide/testing/ide-test-provider.c
@@ -316,3 +316,20 @@ ide_test_provider_set_loading (IdeTestProvider *self,
g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_LOADING]);
}
}
+
+/**
+ * ide_test_provider_reload:
+ * @self: a #IdeTestProvider
+ *
+ * Requests the test provider reloads the tests.
+ *
+ * Since: 3.28
+ */
+void
+ide_test_provider_reload (IdeTestProvider *self)
+{
+ g_return_if_fail (IDE_IS_TEST_PROVIDER (self));
+
+ if (IDE_TEST_PROVIDER_GET_CLASS (self)->reload)
+ IDE_TEST_PROVIDER_GET_CLASS (self)->reload (self);
+}
diff --git a/src/libide/testing/ide-test-provider.h b/src/libide/testing/ide-test-provider.h
index 8f613b5..388ebb9 100644
--- a/src/libide/testing/ide-test-provider.h
+++ b/src/libide/testing/ide-test-provider.h
@@ -44,6 +44,7 @@ struct _IdeTestProviderClass
gboolean (*run_finish) (IdeTestProvider *self,
GAsyncResult *result,
GError **error);
+ void (*reload) (IdeTestProvider *self);
/*< private >*/
gpointer _reserved1;
@@ -80,5 +81,7 @@ IDE_AVAILABLE_IN_3_28
gboolean ide_test_provider_run_finish (IdeTestProvider *self,
GAsyncResult *result,
GError **error);
+IDE_AVAILABLE_IN_3_28
+void ide_test_provider_reload (IdeTestProvider *self);
G_END_DECLS
diff --git a/src/plugins/meson/gbp-meson-test-provider.c b/src/plugins/meson/gbp-meson-test-provider.c
index d846b72..67d70f0 100644
--- a/src/plugins/meson/gbp-meson-test-provider.c
+++ b/src/plugins/meson/gbp-meson-test-provider.c
@@ -194,6 +194,8 @@ gbp_meson_test_provider_do_reload (GbpMesonTestProvider *self,
g_assert (GBP_IS_MESON_TEST_PROVIDER (self));
g_assert (IDE_IS_BUILD_PIPELINE (pipeline));
+ ide_test_provider_clear (IDE_TEST_PROVIDER (self));
+
if (NULL == (launcher = ide_build_pipeline_create_launcher (pipeline, &error)))
IDE_GOTO (failure);
@@ -307,12 +309,11 @@ gbp_meson_test_provider_reload (gpointer user_data)
}
static void
-gbp_meson_test_provider_notify_pipeline (GbpMesonTestProvider *self,
- GParamSpec *pspec,
- IdeBuildManager *build_manager)
+gbp_meson_test_provider_queue_reload (IdeTestProvider *provider)
{
+ GbpMesonTestProvider *self = (GbpMesonTestProvider *)provider;
+
g_assert (GBP_IS_MESON_TEST_PROVIDER (self));
- g_assert (IDE_IS_BUILD_MANAGER (build_manager));
dzl_clear_source (&self->reload_source);
self->reload_source = gdk_threads_add_timeout_full (G_PRIORITY_LOW,
@@ -323,6 +324,17 @@ gbp_meson_test_provider_notify_pipeline (GbpMesonTestProvider *self,
}
static void
+gbp_meson_test_provider_notify_pipeline (GbpMesonTestProvider *self,
+ GParamSpec *pspec,
+ IdeBuildManager *build_manager)
+{
+ g_assert (GBP_IS_MESON_TEST_PROVIDER (self));
+ g_assert (IDE_IS_BUILD_MANAGER (build_manager));
+
+ gbp_meson_test_provider_queue_reload (IDE_TEST_PROVIDER (self));
+}
+
+static void
gbp_meson_test_provider_run_cb (GObject *object,
GAsyncResult *result,
gpointer user_data)
@@ -531,6 +543,7 @@ gbp_meson_test_provider_class_init (GbpMesonTestProviderClass *klass)
provider_class->run_async = gbp_meson_test_provider_run_async;
provider_class->run_finish = gbp_meson_test_provider_run_finish;
+ provider_class->reload = gbp_meson_test_provider_queue_reload;
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]