From 662cddcb4b8dd756f9bef3280600bf3c315a15fd Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Tue, 14 May 2019 11:57:11 +0100 Subject: [PATCH 1/3] glib: Deprecate gtester and gtester-report Add warnings about their deprecation everywhere. The tools will continue to work until we break API, but will be less well maintained. You should use TAP for communicating test results to the test harness provided by your build system or CI system instead. Signed-off-by: Philip Withnall Fixes: #1441 --- docs/reference/glib/glib-docs.xml | 4 ++++ docs/reference/glib/gtester-report.xml | 3 +++ docs/reference/glib/gtester.xml | 3 +++ glib/gtester-report.in | 11 +++++++++++ glib/gtester.c | 12 ++++++++++++ glib/gtestutils.c | 5 +++-- glib/tests/meson.build | 2 +- 7 files changed, 37 insertions(+), 3 deletions(-) diff --git a/docs/reference/glib/glib-docs.xml b/docs/reference/glib/glib-docs.xml index 6d5c2ad4f..fa43eaff7 100644 --- a/docs/reference/glib/glib-docs.xml +++ b/docs/reference/glib/glib-docs.xml @@ -136,6 +136,10 @@ GLib Tools + + + + Deprecated Tools diff --git a/docs/reference/glib/gtester-report.xml b/docs/reference/glib/gtester-report.xml index 4fd0685c0..eee933784 100644 --- a/docs/reference/glib/gtester-report.xml +++ b/docs/reference/glib/gtester-report.xml @@ -35,6 +35,9 @@ gtester-report is a script which converts the XML output generated by gtester into HTML. +Since GLib 2.62, gtester-report is deprecated. Use +TAP for reporting test results instead, and feed it to the test harness provided +by your build system. Options diff --git a/docs/reference/glib/gtester.xml b/docs/reference/glib/gtester.xml index b1c126bd9..5626d4df8 100644 --- a/docs/reference/glib/gtester.xml +++ b/docs/reference/glib/gtester.xml @@ -40,6 +40,9 @@ gtester is a utility to run unit tests that have been written using the GLib test framework. +Since GLib 2.62, gtester-report is deprecated. Use +TAP for reporting test results instead, and feed it to the test harness provided +by your build system. When called with the option, gtester writes an XML report of the test results, which can be converted diff --git a/glib/gtester-report.in b/glib/gtester-report.in index 01f6033f7..e5121f709 100644 --- a/glib/gtester-report.in +++ b/glib/gtester-report.in @@ -15,6 +15,10 @@ # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, see . + +# Deprecated: Since GLib 2.62, gtester and gtester-report have been deprecated +# in favour of TAP. + import datetime import optparse import sys, re, xml.dom.minidom @@ -343,6 +347,9 @@ class HTMLReportWriter(ReportWriter): self.oprint ('\n') self.oprint ('

GTester Unit Test Report

\n') self.handle_info () + self.oprint ('

' + 'Deprecated: Since GLib 2.62, gtester and gtester-report are ' + 'deprecated. Port to TAP.

\n'); self.oprint ('\n\n') self.oprint ('\n') self.oprint ('\n') @@ -474,6 +481,10 @@ def main(): options, files = parse_opts() if options is None: return 0 + + print("Deprecated: Since GLib 2.62, gtester and gtester-report are " + "deprecated. Port to TAP.", file=sys.stderr) + xd = xml.dom.minidom.parse (files[0]) rr = ReportReader() rr.trampoline (xd) diff --git a/glib/gtester.c b/glib/gtester.c index 368fa8f3d..fdcdaca10 100644 --- a/glib/gtester.c +++ b/glib/gtester.c @@ -43,6 +43,7 @@ static gboolean gtester_quiet = FALSE; static gboolean gtester_verbose = FALSE; static gboolean gtester_list_tests = FALSE; static gboolean gtester_selftest = FALSE; +static gboolean gtester_ignore_deprecation = FALSE; static gboolean subtest_running = FALSE; static gint subtest_exitstatus = 0; static gboolean subtest_io_pending = FALSE; @@ -660,6 +661,11 @@ parse_args (gint *argc_p, } argv[i] = NULL; } + else if (strcmp ("--i-know-this-is-deprecated", argv[i]) == 0) + { + gtester_ignore_deprecation = TRUE; + argv[i] = NULL; + } } /* collapse argv */ e = 1; @@ -690,6 +696,10 @@ main (int argc, return 1; } + if (!gtester_ignore_deprecation) + g_warning ("Deprecated: Since GLib 2.62, gtester and gtester-report are " + "deprecated. Port to TAP."); + if (output_filename) { int errsv; @@ -700,6 +710,8 @@ main (int argc, } test_log_printfe ("\n"); + test_log_printfe ("\n"); test_log_printfe ("%s\n", sindent (log_indent)); log_indent += 2; for (ui = 1; ui < argc; ui++) diff --git a/glib/gtestutils.c b/glib/gtestutils.c index d129b8742..3eca0a4d3 100644 --- a/glib/gtestutils.c +++ b/glib/gtestutils.c @@ -60,7 +60,6 @@ * SECTION:testing * @title: Testing * @short_description: a test framework - * @see_also: [gtester][gtester], [gtester-report][gtester-report] * * GLib provides a framework for writing and maintaining unit tests * in parallel to the code they are testing. The API is designed according @@ -235,7 +234,9 @@ * If you don't have access to the Autotools TAP harness, you can use the * [gtester][gtester] and [gtester-report][gtester-report] tools, and use * the [glib.mk](https://gitlab.gnome.org/GNOME/glib/blob/glib-2-58/glib.mk) - * Automake template provided by GLib. + * Automake template provided by GLib. Note, however, that since GLib 2.62, + * [gtester][gtester] and [gtester-report][gtester-report] have been deprecated + * in favour of using TAP. */ /** diff --git a/glib/tests/meson.build b/glib/tests/meson.build index e6c5cbd22..7aa16d279 100644 --- a/glib/tests/meson.build +++ b/glib/tests/meson.build @@ -229,7 +229,7 @@ if not meson.is_cross_build() and host_system != 'windows' if xmllint.found() tmpsample_xml = custom_target('tmpsample.xml', output : 'tmpsample.xml', - command : [ gtester, '-k', '--quiet', '-o', '@OUTPUT@', + command : [ gtester, '-k', '--quiet', '--i-know-this-is-deprecated', '-o', '@OUTPUT@', '--test-arg=--gtester-selftest', gtester]) test('gtester-xmllint-check', xmllint, From ad175766575b23be920f41cdb1c350447c743347 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Tue, 14 May 2019 12:04:21 +0100 Subject: [PATCH 2/3] gtestutils: Output in TAP format by default MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Only disable TAP output if the `--GTestLogFD` argument is passed to the test, which is passed in by the (deprecated) gtester harness, and shouldn’t ever have been passed in by anything else. Also disable it when running a subprocess, using `--GTestSubprocess`, since users commonly strictly check the stdout and stderr of test subprocesses. Signed-off-by: Philip Withnall Fixes: #1619 --- glib/gtestutils.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/glib/gtestutils.c b/glib/gtestutils.c index 3eca0a4d3..2ec1398ec 100644 --- a/glib/gtestutils.c +++ b/glib/gtestutils.c @@ -236,7 +236,8 @@ * the [glib.mk](https://gitlab.gnome.org/GNOME/glib/blob/glib-2-58/glib.mk) * Automake template provided by GLib. Note, however, that since GLib 2.62, * [gtester][gtester] and [gtester-report][gtester-report] have been deprecated - * in favour of using TAP. + * in favour of using TAP. The `--tap` argument to tests is enabled by default + * as of GLib 2.62. */ /** @@ -833,7 +834,7 @@ static char *test_trap_last_stdout = NULL; static char *test_trap_last_stderr = NULL; static char *test_uri_base = NULL; static gboolean test_debug_log = FALSE; -static gboolean test_tap_log = FALSE; +static gboolean test_tap_log = TRUE; /* default to TAP as of GLib 2.62; see #1619; the non-TAP output mode is deprecated */ static gboolean test_nonfatal_assertions = FALSE; static DestroyEntry *test_destroy_queue = NULL; static char *test_argv0 = NULL; @@ -1109,6 +1110,9 @@ parse_args (gint *argc_p, test_log_fd = g_ascii_strtoull (argv[i], NULL, 0); } argv[i] = NULL; + + /* Force non-TAP output when using gtester */ + test_tap_log = FALSE; } else if (strcmp ("--GTestSkipCount", argv[i]) == 0 || strncmp ("--GTestSkipCount=", argv[i], 17) == 0) { @@ -1136,6 +1140,10 @@ parse_args (gint *argc_p, } #endif argv[i] = NULL; + + /* Force non-TAP output when spawning a subprocess, since people often + * test the stdout/stderr of the subprocess strictly */ + test_tap_log = FALSE; } else if (strcmp ("-p", argv[i]) == 0 || strncmp ("-p=", argv[i], 3) == 0) { From 505f45ef95e62fb28a7aa7e3777fd3b53512c05c Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Tue, 14 May 2019 12:41:30 +0100 Subject: [PATCH 3/3] tests: Remove redundant --tap options Now that TAP output is used by default, passing `--tap` is unnecessary. Signed-off-by: Philip Withnall Helps: #1619 --- gio/tests/meson.build | 1 - glib/tests/meson.build | 3 +-- gobject/tests/meson.build | 3 +-- template-tap.test.in | 2 +- tests/gobject/meson.build | 4 +--- tests/meson.build | 4 +--- 6 files changed, 5 insertions(+), 12 deletions(-) diff --git a/gio/tests/meson.build b/gio/tests/meson.build index 98e802ac6..a0c09444b 100644 --- a/gio/tests/meson.build +++ b/gio/tests/meson.build @@ -678,7 +678,6 @@ foreach test_name, extra_args : gio_tests env : local_test_env, timeout : timeout, suite : suite, - args : ['--tap'], is_parallel : extra_args.get('is_parallel', true), depends : extra_args.get('depends', []), ) diff --git a/glib/tests/meson.build b/glib/tests/meson.build index 7aa16d279..c47133f24 100644 --- a/glib/tests/meson.build +++ b/glib/tests/meson.build @@ -204,8 +204,7 @@ foreach test_name, extra_args : glib_tests suite = ['glib'] + extra_args.get('suite', []) timeout = suite.contains('slow') ? test_timeout_slow : test_timeout - test(test_name, exe, env : test_env, timeout : timeout, suite : suite, - args : ['--tap']) + test(test_name, exe, env : test_env, timeout : timeout, suite : suite) endforeach # test-spawn-echo helper binary required by the spawn tests above diff --git a/gobject/tests/meson.build b/gobject/tests/meson.build index 9d08d0a34..7c3e5cd9d 100644 --- a/gobject/tests/meson.build +++ b/gobject/tests/meson.build @@ -103,8 +103,7 @@ foreach test_name, extra_args : gobject_tests timeout = timeout * 10 endif - test(test_name, exe, env : test_env, timeout : timeout, suite : suite, - args: ['--tap']) + test(test_name, exe, env : test_env, timeout : timeout, suite : suite) endforeach test( diff --git a/template-tap.test.in b/template-tap.test.in index 30cd16686..c7d50dcf0 100644 --- a/template-tap.test.in +++ b/template-tap.test.in @@ -1,4 +1,4 @@ [Test] Type=session -Exec=@env@@installed_tests_dir@/@program@ --tap +Exec=@env@@installed_tests_dir@/@program@ Output=TAP diff --git a/tests/gobject/meson.build b/tests/gobject/meson.build index eabaea5b2..24ceda0d3 100644 --- a/tests/gobject/meson.build +++ b/tests/gobject/meson.build @@ -60,7 +60,6 @@ foreach test_name, extra_args : gobject_tests extra_sources = extra_args.get('extra_sources', []) install = installed_tests_enabled and extra_args.get('install', true) template = extra_args.get('tap', false) ? installed_tests_template_tap : installed_tests_template - test_command_args = extra_args.get('tap', false) ? ['--tap'] : [] if install test_conf = configuration_data() @@ -86,8 +85,7 @@ foreach test_name, extra_args : gobject_tests suite = ['gobject'] + extra_args.get('suite', []) timeout = suite.contains('slow') ? test_timeout_slow : test_timeout # FIXME? TESTS_ENVIRONMENT = LIBCHARSET_ALIAS_DIR=$(top_builddir)/glib/libcharset - test(test_name, exe, env : test_env, timeout : timeout, suite : suite, - args : test_command_args) + test(test_name, exe, env : test_env, timeout : timeout, suite : suite) endforeach # Don't install these ones, and keep them out of 'make check' because they take too long... diff --git a/tests/meson.build b/tests/meson.build index 288c5b847..ce3044258 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -103,7 +103,6 @@ foreach test_name, extra_args : tests extra_sources = extra_args.get('extra_sources', []) install = installed_tests_enabled and extra_args.get('install', true) template = extra_args.get('tap', false) ? installed_tests_template_tap : installed_tests_template - test_command_args = extra_args.get('tap', false) ? ['--tap'] : [] if install test_conf = configuration_data() @@ -131,8 +130,7 @@ foreach test_name, extra_args : tests suite = ['glib'] + extra_args.get('suite', []) timeout = suite.contains('slow') ? test_timeout_slow : test_timeout # FIXME? TESTS_ENVIRONMENT = LIBCHARSET_ALIAS_DIR=$(top_builddir)/glib/libcharset - test(test_name, exe, env : test_env, timeout : timeout, suite : suite, - args : test_command_args) + test(test_name, exe, env : test_env, timeout : timeout, suite : suite) endforeach foreach program_name, extra_args : test_extra_programs
Program / Testcase Duration (sec)