diff options
-rw-r--r-- | docs/markdown/snippets/xfail.md | 15 | ||||
-rw-r--r-- | mesonbuild/mtest.py | 8 | ||||
-rw-r--r-- | test cases/failing test/6 xpass/meson.build | 4 | ||||
-rw-r--r-- | test cases/failing test/6 xpass/xpass.c | 1 | ||||
-rw-r--r-- | test cases/linuxlike/14 static dynamic linkage/meson.build | 8 | ||||
-rwxr-xr-x | test cases/linuxlike/14 static dynamic linkage/verify_static.py | 25 |
6 files changed, 49 insertions, 12 deletions
diff --git a/docs/markdown/snippets/xfail.md b/docs/markdown/snippets/xfail.md new file mode 100644 index 0000000..5392fa9 --- /dev/null +++ b/docs/markdown/snippets/xfail.md @@ -0,0 +1,15 @@ +## Tests that should fail but did not are now errors + +You can tag a test as needing to fail like this: + +```meson +test('shoulfail', exe, should_fail: true) +``` + +If the test passes the problem is reported in the error logs but due +to a bug it was not reported in the test runner's exit code. Starting +from this release the unexpected passes are properly reported in the +test runner's exit code. This means that test runs that were passing +in earlier versions of Meson will report failures with the current +version. This is a good thing, though, since it reveals an error in +your test suite that has, until now, gone unnoticed. diff --git a/mesonbuild/mtest.py b/mesonbuild/mtest.py index 0f15690..17af4df 100644 --- a/mesonbuild/mtest.py +++ b/mesonbuild/mtest.py @@ -664,7 +664,6 @@ class TestHarness: def process_test_result(self, result): if result.res is TestResult.TIMEOUT: self.timeout_count += 1 - self.fail_count += 1 elif result.res is TestResult.SKIP: self.skip_count += 1 elif result.res is TestResult.OK: @@ -746,6 +745,9 @@ Timeout: %4d line = line.encode('ascii', errors='replace').decode() print(line) + def total_failure_count(self): + return self.fail_count + self.unexpectedpass_count + self.timeout_count + def doit(self): if self.is_run: raise RuntimeError('Test harness object can only be used once.') @@ -754,7 +756,7 @@ Timeout: %4d if not tests: return 0 self.run_tests(tests) - return self.fail_count + return self.total_failure_count() @staticmethod def split_suite_string(suite): @@ -939,7 +941,7 @@ Timeout: %4d if not tests: return 0 self.run_tests(tests) - return self.fail_count + return self.total_failure_count() def list_tests(th): diff --git a/test cases/failing test/6 xpass/meson.build b/test cases/failing test/6 xpass/meson.build new file mode 100644 index 0000000..7649dde --- /dev/null +++ b/test cases/failing test/6 xpass/meson.build @@ -0,0 +1,4 @@ +project('unexpected pass', 'c') + +test('should_fail_but_does_not', executable('xpass', 'xpass.c'), + should_fail: true) diff --git a/test cases/failing test/6 xpass/xpass.c b/test cases/failing test/6 xpass/xpass.c new file mode 100644 index 0000000..0314ff1 --- /dev/null +++ b/test cases/failing test/6 xpass/xpass.c @@ -0,0 +1 @@ +int main(int argc, char **argv) { return 0; } diff --git a/test cases/linuxlike/14 static dynamic linkage/meson.build b/test cases/linuxlike/14 static dynamic linkage/meson.build index fc3c38a..a529f33 100644 --- a/test cases/linuxlike/14 static dynamic linkage/meson.build +++ b/test cases/linuxlike/14 static dynamic linkage/meson.build @@ -15,6 +15,8 @@ test('test default', exe_default) test('test static', exe_static) test('test dynamic', exe_dynamic) -test('verify static linking', find_program('verify_static.py'), args:exe_static.full_path()) -test('verify dynamic linking', find_program('verify_static.py'), args:exe_dynamic.full_path(), - should_fail: true) +test('verify static linking', find_program('verify_static.py'), + args: ['--platform=' + host_machine.system(), exe_static.full_path()]) +test('verify dynamic linking', find_program('verify_static.py'), + args: ['--platform=' + host_machine.system(), exe_dynamic.full_path()], + should_fail: true) diff --git a/test cases/linuxlike/14 static dynamic linkage/verify_static.py b/test cases/linuxlike/14 static dynamic linkage/verify_static.py index 92cc308..66bf08b 100755 --- a/test cases/linuxlike/14 static dynamic linkage/verify_static.py +++ b/test cases/linuxlike/14 static dynamic linkage/verify_static.py @@ -3,14 +3,27 @@ import subprocess import sys +def handle_common(path): + """Handle the common case.""" + output = subprocess.check_output(['nm', path]).decode('utf-8') + if 'T zlibVersion' in output: + return 0 + return 1 + +def handle_cygwin(path): + """Handle the Cygwin case.""" + output = subprocess.check_output(['nm', path]).decode('utf-8') + if 'I __imp_zlibVersion' in output: + return 1 + return 0 + def main(): """Main function""" - output = subprocess.check_output(['nm', sys.argv[1]]).decode('utf-8') - - if 'T zlibVersion' in output: - sys.exit(0) + if len(sys.argv) > 2 and sys.argv[1] == '--platform=cygwin': + return handle_cygwin(sys.argv[2]) + else: + return handle_common(sys.argv[2]) - sys.exit(1) if __name__ == '__main__': - main() + sys.exit(main()) |