[gjs/wip/3v1n0/toggle-queue-tests: 1/4] tests: Move internal API tests into a different test binary
- From: Marco Trevisan <marcotrevi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs/wip/3v1n0/toggle-queue-tests: 1/4] tests: Move internal API tests into a different test binary
- Date: Sun, 16 May 2021 15:05:07 +0000 (UTC)
commit de94427f630e9f15aedb959fa5c142d0e91b2436
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date: Sun May 16 16:50:18 2021 +0200
tests: Move internal API tests into a different test binary
installed-tests/js/libgjstesttools/meson.build | 3 +++
meson.build | 36 +++++++++++++++-----------
test/gjs-tests-internal.cpp | 25 ++++++++++++++++++
test/gjs-tests.cpp | 3 ---
test/meson.build | 36 +++++++++++++++++++++-----
5 files changed, 78 insertions(+), 25 deletions(-)
---
diff --git a/installed-tests/js/libgjstesttools/meson.build b/installed-tests/js/libgjstesttools/meson.build
index 036d7076..2e57483a 100644
--- a/installed-tests/js/libgjstesttools/meson.build
+++ b/installed-tests/js/libgjstesttools/meson.build
@@ -17,3 +17,6 @@ gjstest_tools_gir = gnome.generate_gir(libgjstesttools,
install: get_option('installed_tests'), install_dir_gir: false,
install_dir_typelib: installed_tests_execdir)
gjstest_tools_typelib = gjstest_tools_gir[1]
+libgjstesttools_dep = declare_dependency(
+ link_with: libgjstesttools,
+ include_directories: include_directories('.'))
diff --git a/meson.build b/meson.build
index 8d11ec84..2f1a03c7 100644
--- a/meson.build
+++ b/meson.build
@@ -496,12 +496,20 @@ if host_machine.system() == 'windows'
libgjs_cpp_args += ['-DWIN32', '-DXP_WIN']
endif
+base_build_dep = declare_dependency(
+ compile_args: libgjs_cpp_args,
+ dependencies: libgjs_dependencies)
+
libgjs_jsapi = static_library(meson.project_name() + '-jsapi',
libgjs_jsapi_sources, probes_header, probes_objfile,
- cpp_args: libgjs_cpp_args,
- dependencies: libgjs_dependencies,
+ dependencies: base_build_dep,
install: false)
+libgjs_internal = static_library(meson.project_name() + '-internal',
+ libgjs_sources, probes_header, probes_objfile,
+ dependencies: base_build_dep,
+ link_with: libgjs_jsapi)
+
link_args = []
symbol_map = files('libgjs.map')
symbol_list = files('libgjs.symbols')
@@ -513,12 +521,10 @@ link_args += cxx.get_supported_link_arguments([
])
libgjs = shared_library(meson.project_name(),
- libgjs_sources, libgjs_private_sources, module_resource_srcs,
- probes_header, probes_objfile,
- cpp_args: libgjs_cpp_args,
+ sources: [ libgjs_private_sources, module_resource_srcs ],
link_args: link_args, link_depends: [symbol_map, symbol_list],
- link_with: libgjs_jsapi,
- dependencies: libgjs_dependencies,
+ link_whole: libgjs_internal,
+ dependencies: base_build_dep,
version: '0.0.0', soversion: '0',
gnu_symbol_visibility: 'hidden',
install: true)
@@ -527,7 +533,7 @@ install_headers(gjs_public_headers, subdir: api_name / 'gjs')
# Allow using libgjs as a subproject
libgjs_dep = declare_dependency(link_with: [libgjs, libgjs_jsapi],
- dependencies: libgjs_dependencies, include_directories: top_include)
+ dependencies: base_build_dep, include_directories: top_include)
### Build GjsPrivate introspection library #####################################
@@ -543,7 +549,6 @@ gjs_private_typelib = gjs_private_gir[1]
gjs_console_srcs = ['gjs/console.cpp']
gjs_console = executable('gjs-console', gjs_console_srcs,
- cpp_args: libgjs_cpp_args,
dependencies: libgjs_dep, install: true)
meson.add_install_script('build/symlink-gjs.py', get_option('bindir'))
@@ -585,6 +590,7 @@ libgjs_test_tools_builddir = js_tests_builddir / 'libgjstesttools'
tests_environment.set('TOP_BUILDDIR', meson.build_root())
tests_environment.set('GJS_USE_UNINSTALLED_FILES', '1')
tests_environment.set('GJS_PATH', '')
+tests_environment.set('GJS_DEBUG_OUTPUT', 'stderr')
tests_environment.prepend('GI_TYPELIB_PATH', meson.current_build_dir(),
js_tests_builddir, libgjs_test_tools_builddir)
tests_environment.prepend('LD_LIBRARY_PATH', meson.current_build_dir(),
@@ -624,18 +630,18 @@ endif
### Tests and test setups ######################################################
-# Note: The test program in test/ needs to be ported
-# to Windows before we can build it on Windows.
-if host_machine.system() != 'windows'
- subdir('test')
-endif
-
if not get_option('skip_gtk_tests')
have_gtk4 = dependency('gtk4', required: false).found()
endif
subdir('installed-tests')
+# Note: The test program in test/ needs to be ported
+# to Windows before we can build it on Windows.
+if host_machine.system() != 'windows'
+ subdir('test')
+endif
+
valgrind_environment = environment()
valgrind_environment.set('G_SLICE', 'always-malloc,debug-blocks')
valgrind_environment.set('G_DEBUG',
diff --git a/test/gjs-tests-internal.cpp b/test/gjs-tests-internal.cpp
new file mode 100644
index 00000000..4f8f74ba
--- /dev/null
+++ b/test/gjs-tests-internal.cpp
@@ -0,0 +1,25 @@
+/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; -*- */
+// SPDX-License-Identifier: MIT OR LGPL-2.0-or-later
+// SPDX-FileCopyrightText: 2021 Canonical, Ltd.
+// SPDX-FileContributor: Marco Trevisan <marco trevisan canonical com>
+
+#include <config.h>
+#include <glib.h>
+
+#include "test/gjs-test-utils.h"
+
+int main(int argc, char** argv) {
+ /* Avoid interference in the tests from stray environment variable */
+ g_unsetenv("GJS_ENABLE_PROFILER");
+ g_unsetenv("GJS_TRACE_FD");
+
+ g_test_init(&argc, &argv, nullptr);
+
+ gjs_test_add_tests_for_rooting();
+ gjs_test_add_tests_for_parse_call_args();
+ gjs_test_add_tests_for_jsapi_utils();
+
+ g_test_run();
+
+ return 0;
+}
diff --git a/test/gjs-tests.cpp b/test/gjs-tests.cpp
index 8eda4e27..9034d879 100644
--- a/test/gjs-tests.cpp
+++ b/test/gjs-tests.cpp
@@ -955,9 +955,6 @@ main(int argc,
#undef ADD_JSAPI_UTIL_TEST
gjs_test_add_tests_for_coverage ();
- gjs_test_add_tests_for_parse_call_args();
- gjs_test_add_tests_for_rooting();
- gjs_test_add_tests_for_jsapi_utils();
g_test_run();
diff --git a/test/meson.build b/test/meson.build
index 83c63067..dd902877 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -7,21 +7,43 @@ mock_js_resources_files = gnome.compile_resources('mock-js-resources',
'mock-js-resources.gresource.xml', c_name: 'mock_js_resources',
source_dir: '..')
+libgjs_tests_common = static_library('libgjs-tests-common',
+ sources: [
+ 'gjs-test-utils.cpp', 'gjs-test-utils.h',
+ 'gjs-test-common.cpp', 'gjs-test-common.h',
+ ],
+ cpp_args: libgjs_cpp_args,
+ include_directories: top_include, dependencies: libgjs_dependencies,
+)
+
gjs_tests_sources = [
'gjs-tests.cpp',
- 'gjs-test-common.cpp', 'gjs-test-common.h',
- 'gjs-test-utils.cpp', 'gjs-test-utils.h',
- 'gjs-test-call-args.cpp',
'gjs-test-coverage.cpp',
- 'gjs-test-rooting.cpp',
- 'gjs-test-jsapi-utils.cpp',
'gjs-test-no-introspection-object.cpp', 'gjs-test-no-introspection-object.h',
]
gjs_tests = executable('gjs-tests', gjs_tests_sources, mock_js_resources_files,
- cpp_args: ['-DGJS_COMPILATION'] + directory_defines,
- include_directories: top_include, dependencies: libgjs_dep)
+ include_directories: top_include, dependencies: libgjs_dep,
+ link_with: libgjs_tests_common)
test('API tests', gjs_tests, args: ['--tap', '--keep-going', '--verbose'],
depends: gjs_private_typelib, env: tests_environment, protocol: 'tap',
suite: 'C', timeout: 60)
+
+gjs_tests_internal = executable('gjs-tests-internal',
+ sources: [
+ 'gjs-tests-internal.cpp',
+ 'gjs-test-call-args.cpp',
+ 'gjs-test-rooting.cpp',
+ 'gjs-test-jsapi-utils.cpp',
+ module_resource_srcs,
+ ],
+ include_directories: top_include,
+ cpp_args: libgjs_cpp_args,
+ dependencies: [libgjs_dependencies, libgjstesttools_dep],
+ link_with: [libgjs_tests_common, libgjs_internal])
+
+test('Internal API tests', gjs_tests_internal,
+ args: ['--tap', '--keep-going', '--verbose'],
+ env: tests_environment, protocol: 'tap',
+ suite: ['C', 'thread-safe'])
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]