[TAP] Fix TAP parser when test exits with status

Some time between 0.56 and 0.57 the TAP parser broke when a test exits
with a nonzero status.
The TAP protocol does not specify this behaviour - giving latitude to
implementers, and meson's previous behaviour was to report the exit
status gracefully.

This patch restores the old behaviour and adds a regression test
pull/8390/head
Luke Drummond 4 years ago committed by Jussi Pakkanen
parent 90a7de3f2b
commit 79f7328d6a
  1. 1
      mesonbuild/mtest.py
  2. 4
      test cases/failing test/5 tap tests/meson.build
  3. 8
      test cases/failing test/5 tap tests/tester_with_status.c

@ -1004,6 +1004,7 @@ class TestRunTAP(TestRun):
stdo: str, stde: str) -> None: stdo: str, stde: str) -> None:
if returncode != 0 and not res.was_killed(): if returncode != 0 and not res.was_killed():
res = TestResult.ERROR res = TestResult.ERROR
stde = stde or ''
stde += '\n(test program exited with status code {})'.format(returncode,) stde += '\n(test program exited with status code {})'.format(returncode,)
super().complete(returncode, res, stdo, stde) super().complete(returncode, res, stdo, stde)

@ -1,7 +1,9 @@
project('test features', 'c') project('test features', 'c')
tester = executable('tester', 'tester.c') tester = executable('tester', 'tester.c')
test('nonzero return code', tester, args : [], protocol: 'tap') test_with_status = executable('test-with-status', 'tester_with_status.c')
test('nonzero return code no tests', tester, args : [], protocol: 'tap')
test('nonzero return code with tests', test_with_status, protocol: 'tap')
test('missing test', tester, args : ['1..1'], protocol: 'tap') test('missing test', tester, args : ['1..1'], protocol: 'tap')
test('incorrect skip', tester, args : ['1..1 # skip\nok 1'], protocol: 'tap') test('incorrect skip', tester, args : ['1..1 # skip\nok 1'], protocol: 'tap')
test('partially skipped', tester, args : ['not ok 1\nok 2 # skip'], protocol: 'tap') test('partially skipped', tester, args : ['not ok 1\nok 2 # skip'], protocol: 'tap')

@ -0,0 +1,8 @@
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv) {
puts("1..1");
puts("not ok 1 - some test");
return 2;
}
Loading…
Cancel
Save