kunit: tool: Do not error on tests without test plans
The (K)TAP spec encourages test output to begin with a 'test plan': a count of the number of tests being run of the form: 1..n However, some test suites might not know the number of subtests in advance (for example, KUnit's parameterised tests use a generator function). In this case, it's not possible to print the test plan in advance. kunit_tool already parses test output which doesn't contain a plan, but reports an error. Since we want to use nested subtests with KUnit paramterised tests, remove this error. Signed-off-by: David Gow <davidgow@google.com> Reviewed-by: Daniel Latypov <dlatypov@google.com> Reviewed-by: Brendan Higgins <brendanhiggins@google.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
This commit is contained in:
@@ -340,8 +340,8 @@ def parse_test_plan(lines: LineStream, test: Test) -> bool:
|
|||||||
"""
|
"""
|
||||||
Parses test plan line and stores the expected number of subtests in
|
Parses test plan line and stores the expected number of subtests in
|
||||||
test object. Reports an error if expected count is 0.
|
test object. Reports an error if expected count is 0.
|
||||||
Returns False and reports missing test plan error if fails to parse
|
Returns False and sets expected_count to None if there is no valid test
|
||||||
test plan.
|
plan.
|
||||||
|
|
||||||
Accepted format:
|
Accepted format:
|
||||||
- '1..[number of subtests]'
|
- '1..[number of subtests]'
|
||||||
@@ -356,7 +356,6 @@ def parse_test_plan(lines: LineStream, test: Test) -> bool:
|
|||||||
match = TEST_PLAN.match(lines.peek())
|
match = TEST_PLAN.match(lines.peek())
|
||||||
if not match:
|
if not match:
|
||||||
test.expected_count = None
|
test.expected_count = None
|
||||||
test.add_error('missing plan line!')
|
|
||||||
return False
|
return False
|
||||||
test.log.append(lines.pop())
|
test.log.append(lines.pop())
|
||||||
expected_count = int(match.group(1))
|
expected_count = int(match.group(1))
|
||||||
|
|||||||
@@ -191,7 +191,10 @@ class KUnitParserTest(unittest.TestCase):
|
|||||||
result = kunit_parser.parse_run_tests(
|
result = kunit_parser.parse_run_tests(
|
||||||
kunit_parser.extract_tap_lines(
|
kunit_parser.extract_tap_lines(
|
||||||
file.readlines()))
|
file.readlines()))
|
||||||
self.assertEqual(2, result.test.counts.errors)
|
# A missing test plan is not an error.
|
||||||
|
self.assertEqual(0, result.test.counts.errors)
|
||||||
|
# All tests should be accounted for.
|
||||||
|
self.assertEqual(10, result.test.counts.total())
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
kunit_parser.TestStatus.SUCCESS,
|
kunit_parser.TestStatus.SUCCESS,
|
||||||
result.status)
|
result.status)
|
||||||
|
|||||||
Reference in New Issue
Block a user