[jsonrpc-glib] build: actually build unit tests
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [jsonrpc-glib] build: actually build unit tests
- Date: Mon, 5 Jun 2017 10:19:11 +0000 (UTC)
commit 733d70509f3f61ff1075170c12a110ef3d778cef
Author: Christian Hergert <chergert redhat com>
Date: Mon Jun 5 03:16:28 2017 -0700
build: actually build unit tests
These require gio-unix-2.0, which should probably make optional with
an option at some point.
tests/meson.build | 47 +++++++++++++++++++++++++++++++++++++++++++++++
tests/test-client.c | 21 +++++++++++----------
2 files changed, 58 insertions(+), 10 deletions(-)
---
diff --git a/tests/meson.build b/tests/meson.build
index e69de29..a5e2e6f 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -0,0 +1,47 @@
+test_env = [
+ 'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()),
+ 'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir()),
+ 'G_DEBUG=gc-friendly',
+ 'GSETTINGS_BACKEND=memory',
+ 'PYTHONDONTWRITEBYTECODE=yes',
+ 'MALLOC_CHECK_=2',
+# 'MALLOC_PERTURB_=$((${RANDOM:-256} % 256))',
+]
+
+test_cflags = [
+ '-fPIE',
+ '-DTEST_DATA_DIR="@0@/data"'.format(meson.current_source_dir()),
+]
+
+test_link_args = [
+ '-fPIC',
+]
+
+test_deps = libjsonrpc_glib_deps + [
+ libjsonrpc_glib_dep,
+ dependency('gio-unix-2.0'),
+]
+
+test_client = executable('test-client', 'test-client.c',
+ c_args: test_cflags,
+ link_args: test_link_args,
+ dependencies: test_deps,
+)
+
+test_message = executable('test-message', 'test-message.c',
+ c_args: test_cflags,
+ link_args: test_link_args,
+ dependencies: test_deps,
+)
+
+test_server = executable('test-server', 'test-server.c',
+ c_args: test_cflags,
+ link_args: test_link_args,
+ dependencies: test_deps,
+)
+
+test_stress = executable('test-stress', 'test-stress.c',
+ c_args: test_cflags,
+ link_args: test_link_args,
+ dependencies: test_deps,
+)
diff --git a/tests/test-client.c b/tests/test-client.c
index a163043..f4a056d 100644
--- a/tests/test-client.c
+++ b/tests/test-client.c
@@ -3,7 +3,7 @@
#include "jsonrpc-client.h"
-static JsonrpcClient *client;
+static JsonrpcClient *gClient;
static GMainLoop *main_loop;
static void
@@ -17,7 +17,7 @@ close_cb (GObject *object,
static gboolean
timeout_cb (gpointer data)
{
- jsonrpc_client_close_async (client, NULL, close_cb, NULL);
+ jsonrpc_client_close_async (gClient, NULL, close_cb, NULL);
return G_SOURCE_REMOVE;
}
@@ -73,6 +73,7 @@ main (gint argc,
g_autoptr(GError) error = NULL;
g_autoptr(GSubprocess) subprocess = NULL;
g_auto(GVariantDict) params = { 0 };
+ g_autofree gchar *path = NULL;
GInputStream *stdout_pipe;
GOutputStream *stdin_pipe;
@@ -100,27 +101,27 @@ main (gint argc,
"output-stream", stdin_pipe,
NULL);
- client = jsonrpc_client_new (io_stream);
+ gClient = jsonrpc_client_new (io_stream);
- g_signal_connect (client,
+ g_signal_connect (gClient,
"notification",
G_CALLBACK (notification_cb),
NULL);
g_subprocess_wait_async (subprocess, NULL, wait_cb, NULL);
- g_autofree gchar *path = g_build_filename (g_get_home_dir (),
- "Projects",
- "rustls",
- "sample_project",
- NULL);
+ path = g_build_filename (g_get_home_dir (),
+ "Projects",
+ "rustls",
+ "sample_project",
+ NULL);
g_variant_dict_init (¶ms, NULL);
g_variant_dict_insert (¶ms, "processId", "i", getpid ());
g_variant_dict_insert (¶ms, "rootPath", "s", path);
g_variant_dict_insert_value (¶ms, "capabilities", g_variant_new ("a{sv}", NULL, NULL, NULL));
- jsonrpc_client_call_async (client, "initialize", g_variant_dict_end (¶ms), NULL, call_cb, NULL);
+ jsonrpc_client_call_async (gClient, "initialize", g_variant_dict_end (¶ms), NULL, call_cb, NULL);
g_timeout_add_seconds (5, timeout_cb, NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]