[gnome-builder/wip/gtk4-port] plugins/maven: port test provider to run context
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/gtk4-port] plugins/maven: port test provider to run context
- Date: Tue, 28 Jun 2022 10:44:26 +0000 (UTC)
commit c96f1a3f292d9556a49ff486012c57f1058d3f76
Author: Christian Hergert <chergert redhat com>
Date: Tue Jun 28 03:44:19 2022 -0700
plugins/maven: port test provider to run context
src/plugins/maven/gbp-maven-test-provider.c | 53 +++++++++++++++++------------
1 file changed, 31 insertions(+), 22 deletions(-)
---
diff --git a/src/plugins/maven/gbp-maven-test-provider.c b/src/plugins/maven/gbp-maven-test-provider.c
index 399f518b8..511a9aab1 100644
--- a/src/plugins/maven/gbp-maven-test-provider.c
+++ b/src/plugins/maven/gbp-maven-test-provider.c
@@ -174,20 +174,20 @@ gbp_maven_test_provider_run_cb (GObject *object,
GAsyncResult *result,
gpointer user_data)
{
- IdeRunner *runner = (IdeRunner *)object;
+ IdeSubprocess *subprocess = (IdeSubprocess *)object;
g_autoptr(IdeTask) task = user_data;
g_autoptr(GError) error = NULL;
IdeTest *test;
IDE_ENTRY;
- g_assert (IDE_IS_RUNNER (runner));
+ g_assert (IDE_IS_SUBPROCESS (subprocess));
g_assert (G_IS_ASYNC_RESULT (result));
g_assert (IDE_IS_TASK (task));
test = ide_task_get_task_data (task);
- if (!ide_runner_run_finish (runner, result, &error))
+ if (!ide_subprocess_wait_check_finish (subprocess, result, &error))
{
ide_test_set_status (test, IDE_TEST_STATUS_FAILED);
ide_task_return_error (task, g_steal_pointer (&error));
@@ -210,7 +210,9 @@ gbp_maven_test_provider_run_async (IdeTestProvider *provider,
GAsyncReadyCallback callback,
gpointer user_data)
{
- g_autoptr(IdeRunner) runner = NULL;
+ g_autoptr(IdeRunContext) run_context = NULL;
+ g_autoptr(IdeSubprocess) subprocess = NULL;
+ g_autoptr(GError) error = NULL;
g_autoptr(IdeTask) task = NULL;
g_autofree char *d_test = NULL;
const char *suite_name;
@@ -230,36 +232,43 @@ gbp_maven_test_provider_run_async (IdeTestProvider *provider,
suite_name = gbp_maven_test_get_suite_name (GBP_MAVEN_TEST (test));
- if (!(runtime = ide_pipeline_get_runtime (pipeline)) ||
- !(runner = ide_runtime_create_runner (runtime, NULL)))
- IDE_GOTO (failure);
+ if (!(runtime = ide_pipeline_get_runtime (pipeline)))
+ {
+ ide_task_return_new_error (task,
+ G_IO_ERROR,
+ G_IO_ERROR_FAILED,
+ "Failed to run test: %s",
+ gbp_maven_test_get_suite_name (GBP_MAVEN_TEST (test)));
+ IDE_EXIT;
+ }
+
+ run_context = ide_run_context_new ();
+ ide_runtime_prepare_to_run (runtime, pipeline, run_context);
if (pty != NULL)
- ide_runner_set_pty (runner, pty);
+ ide_run_context_set_pty (run_context, pty);
- ide_runner_set_cwd (runner, ide_pipeline_get_srcdir (pipeline));
+ ide_run_context_set_cwd (run_context, ide_pipeline_get_srcdir (pipeline));
/*
* http://maven.apache.org/surefire/maven-surefire-plugin/examples/single-test.html
* it has to be junit 4.x
*/
d_test = g_strconcat ("-Dtest=", suite_name, NULL);
- ide_runner_push_args (runner, IDE_STRV_INIT ("mvn", d_test, "test"));
+ ide_run_context_append_args (run_context, IDE_STRV_INIT ("mvn", d_test, "test"));
- ide_test_set_status (test, IDE_TEST_STATUS_RUNNING);
- ide_runner_run_async (runner,
- cancellable,
- gbp_maven_test_provider_run_cb,
- g_steal_pointer (&task));
+ if (!(subprocess = ide_run_context_spawn (run_context, &error)))
+ {
+ ide_task_return_error (task, g_steal_pointer (&error));
+ IDE_EXIT;
+ }
- IDE_EXIT;
+ ide_test_set_status (test, IDE_TEST_STATUS_RUNNING);
-failure:
- ide_task_return_new_error (task,
- G_IO_ERROR,
- G_IO_ERROR_FAILED,
- "Failed to run test: %s",
- gbp_maven_test_get_suite_name (GBP_MAVEN_TEST (test)));
+ ide_subprocess_wait_check_async (subprocess,
+ cancellable,
+ gbp_maven_test_provider_run_cb,
+ g_steal_pointer (&task));
IDE_EXIT;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]