Commit 1b51740f authored by Yuval Peress's avatar Yuval Peress Committed by Alberto Escolar
Browse files

twister: Fix gTest harness

The gTest harness asssumed that the lines end with the test name, but
some gTest implementations include the test duration in the line. Update
both the tests and regex to allow this and also avoid capturing
characters into the `test_name` that cannot be valid test name chars.

Fixes #72318

Signed-off-by: default avatarYuval Peress <peress@google.com>
parent 9abca618
Loading
Loading
Loading
Loading
+5 −5
Changes for scripts/pylib/twister/twisterlib/harness.py: 5 added lines, 5 removed lines.
Original line number Diff line number Diff line
@@ -570,11 +570,11 @@ class Pytest(Harness):

class Gtest(Harness):
    ANSI_ESCAPE = re.compile(r'\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])')
    TEST_START_PATTERN = r".*\[ RUN      \] (?P<suite_name>.*)\.(?P<test_name>.*)$"
    TEST_PASS_PATTERN = r".*\[       OK \] (?P<suite_name>.*)\.(?P<test_name>.*)$"
    TEST_SKIP_PATTERN = r".*\[ DISABLED \] (?P<suite_name>.*)\.(?P<test_name>.*)$"
    TEST_FAIL_PATTERN = r".*\[  FAILED  \] (?P<suite_name>.*)\.(?P<test_name>.*)$"
    FINISHED_PATTERN = r".*\[==========\] Done running all tests\.$"
    TEST_START_PATTERN = r".*\[ RUN      \] (?P<suite_name>[a-zA-Z_][a-zA-Z0-9_]*)\.(?P<test_name>[a-zA-Z_][a-zA-Z0-9_]*)"
    TEST_PASS_PATTERN = r".*\[       OK \] (?P<suite_name>[a-zA-Z_][a-zA-Z0-9_]*)\.(?P<test_name>[a-zA-Z_][a-zA-Z0-9_]*)"
    TEST_SKIP_PATTERN = r".*\[ DISABLED \] (?P<suite_name>[a-zA-Z_][a-zA-Z0-9_]*)\.(?P<test_name>[a-zA-Z_][a-zA-Z0-9_]*)"
    TEST_FAIL_PATTERN = r".*\[  FAILED  \] (?P<suite_name>[a-zA-Z_][a-zA-Z0-9_]*)\.(?P<test_name>[a-zA-Z_][a-zA-Z0-9_]*)"
    FINISHED_PATTERN = r".*\[==========\] Done running all tests\."

    def __init__(self):
        super().__init__()
+1 −1
Changes for scripts/tests/twister/test_harness.py: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@ GTEST_FAIL_STATE = " FAILED "
SAMPLE_GTEST_START = (
    "[00:00:00.000,000] <inf> label:  [==========] Running all tests."
)
SAMPLE_GTEST_FMT = "[00:00:00.000,000] <inf> label:  [{state}] {suite}.{test}"
SAMPLE_GTEST_FMT = "[00:00:00.000,000] <inf> label:  [{state}] {suite}.{test} (0ms)"
SAMPLE_GTEST_END = (
    "[00:00:00.000,000] <inf> label:  [==========] Done running all tests."
)