Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crashed tests are not reported as failures #47

Closed
rjra100 opened this issue Jan 14, 2022 · 5 comments
Closed

Crashed tests are not reported as failures #47

rjra100 opened this issue Jan 14, 2022 · 5 comments
Labels
bug Something isn't working

Comments

@rjra100
Copy link

rjra100 commented Jan 14, 2022

If a test process crashes altogether (for example, segfaults) the explorer appears to ignore it rather than marking it as failed. The test retains the "not run" icon, and if viewing the tests as a tree view, the icon on the containing suite ignores the result (so if all the other tests succeed and the tree is collapsed, there may be no visual indication that any test has failed).

In case it matters, our tests are mostly C++ using GTest and registered via cmake's gtest_discover_tests function, but I think it'd happen regardless of the test framework.
With a test suite like

TEST(TestSuite, TestCrashingFunction)
{
    int x = *(reinterpret_cast<int*>(0));
    (void)x;
    GTEST_SUCCEED();
}
TEST(TestSuite, TestAllIsWell)
{
    GTEST_SUCCEED();
}

CTest itself reports something like

Test project /build/Debug
    Start 125: TestSuite.TestCrashingFunction
1/2 Test #125: TestSuite.TestCrashingFunction ...***Exception: SegFault  0.00 sec
    Start 126: TestSuite.TestAllIsWell
2/2 Test #126: TestSuite.TestAllIsWell ..........   Passed    0.00 sec

50% tests passed, 1 tests failed out of 2

Total Test time (real) =   0.02 sec

The following tests FAILED:
        125 - TestSuite.TestCrashingFunction (SEGFAULT)
Errors while running CTest

But the test explorer shows
image

EDIT:
Sorry, forgot to mention the environment. I reproduced this in VSCode 1.63.2 on Windows, CMake Test Explorer 0.15.1 (with Test Explorer UI 2.21.1) and developing in either a WSL2+Docker environment via Remote-Containers 0.209.6 or a remote server via Remote-SSH 0.70.0). I'm told the behaviour is the same on a Mac + Docker Desktop setup. The actual dev environment is Linux (RHEL7) in all cases. I've seen the same behaviour for some time, though, so I don't think this is new or version-specific.

@fredericbonnet fredericbonnet added the bug Something isn't working label Jan 18, 2022
@fredericbonnet
Copy link
Owner

Thanks for reporting! I've found and fixed the error, it will be part of the next patch release.

The error lies in the file src\cmake-runner.ts at line 32:

/** Regexp for test failed line */
const CTEST_FAILED_RE =
  /^\s*\d+\/\d+ Test\s+#(\d+): (\S+).*\.\.\.+\*\*\*Failed/;

The regexp only matches regular failures and not exceptions, the fix is to simply remove the trailing Failed so as to match all causes of failures.

@rjra100
Copy link
Author

rjra100 commented Jan 19, 2022

That's great; thanks!

fredericbonnet added a commit that referenced this issue Jan 20, 2022
@fredericbonnet
Copy link
Owner

Latest version 0.15.2 should fix the issue, can you confirm it works on your side?

@rjra100
Copy link
Author

rjra100 commented Jan 24, 2022

Looks good to me. Thanks very much for the quick turnaround (and sorry it took me a few days to check!)

@fredericbonnet
Copy link
Owner

No worries!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants