From 185238fdb479e2f7007ccda47e59b65557b7ee4b Mon Sep 17 00:00:00 2001 From: Christoph Weiss Date: Fri, 12 Jul 2019 10:01:36 +0200 Subject: [PATCH] Change meson test's build failure exit code to 125 --- man/meson.1 | 16 ++++++++++++++++ mesonbuild/mtest.py | 5 ++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/man/meson.1 b/man/meson.1 index e7c1ecb4ea9d..5b0dc3092ff3 100644 --- a/man/meson.1 +++ b/man/meson.1 @@ -124,6 +124,18 @@ The default way of running tests is to invoke the default build command: .B meson test provides a richer set of tools for invoking tests. +.B meson test +automatically rebuilds the necessary targets to run tests when used with the Ninja backend. +Upon build failure, +.B meson test +will return an exit code of 125. +This return code tells +.B git bisect run +to skip the current commit. +Thus bisecting using git can be done conveniently like this. + +.B git bisect run meson test -C build_dir + .SS "options:" .TP \fB\-\-repeat\fR @@ -214,6 +226,10 @@ Usage error, or an error parsing or executing meson.build. .B 2 Internal error. .TP +.B 125 +.B meson test +could not rebuild the required targets. +.TP .SH SEE ALSO diff --git a/mesonbuild/mtest.py b/mesonbuild/mtest.py index 1dca07596f51..253f4abeac50 100644 --- a/mesonbuild/mtest.py +++ b/mesonbuild/mtest.py @@ -1021,7 +1021,10 @@ def run(options: argparse.Namespace) -> int: if not options.list and not options.no_rebuild: if not rebuild_all(options.wd): - return 1 + # We return 125 here in case the build failed. + # The reason is that exit code 125 tells `git bisect run` that the current commit should be skipped. + # Thus users can directly use `meson test` to bisect without needing to handle the does-not-build case separately in a wrapper script. + return 125 with TestHarness(options) as th: try: