[gnome-builder] plugins/testui: insert message when running all tests
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] plugins/testui: insert message when running all tests
- Date: Tue, 19 Jul 2022 22:29:34 +0000 (UTC)
commit 9e361c11fb5d1d494b477261ec71f42ad30d4cf1
Author: Christian Hergert <chergert redhat com>
Date: Tue Jul 19 15:29:23 2022 -0700
plugins/testui: insert message when running all tests
src/plugins/testui/gbp-testui-output-panel.c | 11 ++++
src/plugins/testui/gbp-testui-output-panel.h | 2 +
src/plugins/testui/gbp-testui-workspace-addin.c | 79 +++++++++++++++++++++++++
3 files changed, 92 insertions(+)
---
diff --git a/src/plugins/testui/gbp-testui-output-panel.c b/src/plugins/testui/gbp-testui-output-panel.c
index fb025c673..78eadcf29 100644
--- a/src/plugins/testui/gbp-testui-output-panel.c
+++ b/src/plugins/testui/gbp-testui-output-panel.c
@@ -168,3 +168,14 @@ gbp_testui_output_panel_reset (GbpTestuiOutputPanel *self)
vte_terminal_reset (VTE_TERMINAL (self->terminal), TRUE, TRUE);
}
+
+void
+gbp_testui_output_panel_write (GbpTestuiOutputPanel *self,
+ const char *message)
+{
+ g_return_if_fail (GBP_IS_TESTUI_OUTPUT_PANEL (self));
+ g_return_if_fail (message != NULL);
+
+ vte_terminal_feed (VTE_TERMINAL (self->terminal), message, -1);
+ vte_terminal_feed (VTE_TERMINAL (self->terminal), "\r\n", -1);
+}
diff --git a/src/plugins/testui/gbp-testui-output-panel.h b/src/plugins/testui/gbp-testui-output-panel.h
index bf164de3b..659e39949 100644
--- a/src/plugins/testui/gbp-testui-output-panel.h
+++ b/src/plugins/testui/gbp-testui-output-panel.h
@@ -32,5 +32,7 @@ G_DECLARE_FINAL_TYPE (GbpTestuiOutputPanel, gbp_testui_output_panel, GBP, TESTUI
GbpTestuiOutputPanel *gbp_testui_output_panel_new (VtePty *pty);
void gbp_testui_output_panel_reset (GbpTestuiOutputPanel *self);
+void gbp_testui_output_panel_write (GbpTestuiOutputPanel *self,
+ const char *message);
G_END_DECLS
diff --git a/src/plugins/testui/gbp-testui-workspace-addin.c b/src/plugins/testui/gbp-testui-workspace-addin.c
index 3bfccd004..8eddc50ce 100644
--- a/src/plugins/testui/gbp-testui-workspace-addin.c
+++ b/src/plugins/testui/gbp-testui-workspace-addin.c
@@ -22,6 +22,8 @@
#include "config.h"
+#include <glib/gi18n.h>
+
#include <libide-foundry.h>
#include <libide-gui.h>
@@ -35,6 +37,7 @@ struct _GbpTestuiWorkspaceAddin
IdeWorkspace *workspace;
GbpTestuiPanel *panel;
GbpTestuiOutputPanel *output_panel;
+ GTimer *timer;
};
static void
@@ -54,6 +57,9 @@ on_test_activated_cb (GbpTestuiWorkspaceAddin *self,
panel_widget_raise (PANEL_WIDGET (self->output_panel));
+ gbp_testui_output_panel_write (self->output_panel,
+ ide_test_get_title (test));
+
context = ide_workspace_get_context (self->workspace);
test_manager = ide_test_manager_from_context (context);
ide_test_manager_run_async (test_manager, test, NULL, NULL, NULL);
@@ -61,6 +67,67 @@ on_test_activated_cb (GbpTestuiWorkspaceAddin *self,
IDE_EXIT;
}
+static void
+begin_test_all_cb (GbpTestuiWorkspaceAddin *self,
+ IdeTestManager *test_manager)
+{
+ g_autoptr(GDateTime) now = NULL;
+ g_autofree char *nowstr = NULL;
+ g_autofree char *message = NULL;
+ IDE_ENTRY;
+
+ g_assert (IDE_IS_MAIN_THREAD ());
+ g_assert (GBP_IS_TESTUI_WORKSPACE_ADDIN (self));
+ g_assert (IDE_IS_TEST_MANAGER (test_manager));
+
+ now = g_date_time_new_now_local ();
+ nowstr = g_date_time_format (now, "%X");
+ /* Translators: %s is replaced with the time in the current locale */
+ message = g_strdup_printf (_("Running all unit tests at %s"), nowstr);
+
+ gbp_testui_output_panel_write (self->output_panel, message);
+
+ panel_widget_raise (PANEL_WIDGET (self->panel));
+ panel_widget_raise (PANEL_WIDGET (self->output_panel));
+
+ g_clear_pointer (&self->timer, g_timer_destroy);
+ self->timer = g_timer_new ();
+
+ IDE_EXIT;
+}
+
+static void
+end_test_all_cb (GbpTestuiWorkspaceAddin *self,
+ IdeTestManager *test_manager)
+{
+ g_autofree char *message = NULL;
+ double elapsed = .0;
+
+ IDE_ENTRY;
+
+ g_assert (IDE_IS_MAIN_THREAD ());
+ g_assert (GBP_IS_TESTUI_WORKSPACE_ADDIN (self));
+ g_assert (IDE_IS_TEST_MANAGER (test_manager));
+
+ if (self->timer != NULL)
+ {
+ elapsed = g_timer_elapsed (self->timer, NULL);
+ g_clear_pointer (&self->timer, g_timer_destroy);
+ }
+
+ if (elapsed != .0)
+ message = g_strdup_printf (_("Unit tests completed in %lf seconds"), elapsed);
+ else
+ message = g_strdup (_("Unit tests completed"));
+
+ gbp_testui_output_panel_write (self->output_panel, message);
+
+ panel_widget_raise (PANEL_WIDGET (self->panel));
+ panel_widget_raise (PANEL_WIDGET (self->output_panel));
+
+ IDE_EXIT;
+}
+
static void
gbp_testui_workspace_addin_load (IdeWorkspaceAddin *addin,
IdeWorkspace *workspace)
@@ -84,6 +151,17 @@ gbp_testui_workspace_addin_load (IdeWorkspaceAddin *addin,
test_manager = ide_test_manager_from_context (context);
pty = ide_test_manager_get_pty (test_manager);
+ g_signal_connect_object (test_manager,
+ "begin-test-all",
+ G_CALLBACK (begin_test_all_cb),
+ self,
+ G_CONNECT_SWAPPED);
+ g_signal_connect_object (test_manager,
+ "end-test-all",
+ G_CALLBACK (end_test_all_cb),
+ self,
+ G_CONNECT_SWAPPED);
+
self->panel = gbp_testui_panel_new (test_manager);
g_signal_connect_object (self->panel,
"test-activated",
@@ -118,6 +196,7 @@ gbp_testui_workspace_addin_unload (IdeWorkspaceAddin *addin,
g_clear_pointer ((IdePane **)&self->panel, ide_pane_destroy);
g_clear_pointer ((IdePane **)&self->output_panel, ide_pane_destroy);
+ g_clear_pointer (&self->timer, g_timer_destroy);
self->workspace = NULL;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]