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

Doctest integration doesn't decode or show exceptions #4261

Closed
Di3mex opened this issue May 13, 2022 · 4 comments
Closed

Doctest integration doesn't decode or show exceptions #4261

Di3mex opened this issue May 13, 2022 · 4 comments

Comments

@Di3mex
Copy link

Di3mex commented May 13, 2022


Configuration

Operating system:

Windows 10 64 bit, gcc installed via Cygwin

PlatformIO Version (platformio --version):

PlatformIO Core, version 6.0.0rc1

Description of problem

Steps to Reproduce

Actual Results

ERROR: test case THREW exception: unknown exception

Expected Results

The exception in a readable format.

If problems with PlatformIO Build System:

The content of platformio.ini:

[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino

[env:native]
platform = native
build_type = debug
debug_test = test_native
debug_build_flags = -O0 -g3 -ggdb3
test_framework = doctest
build_flags = 
  -O0
  -Wall 
  -D DOCTEST_CONFIG_NO_POSIX_SIGNALS

Source file to reproduce issue:

#define DOCTEST_CONFIG_IMPLEMENT // REQUIRED: Enable custom main()
#include <doctest.h>

struct my_little_exception {};

TEST_CASE("I'll just throw something") {
    SUBCASE("I hope someone is going to catch it") {
        throw my_little_exception();
    }
}

int main(int argc, char **argv) {
    doctest::Context context;

    // BEGIN:: PLATFORMIO REQUIRED OPTIONS
    context.setOption("success", true);     // Report successful tests
    context.setOption("no-exitcode", true); // Do not return non-zero code on failed test case
    // END:: PLATFORMIO REQUIRED OPTIONS

    // YOUR CUSTOM DOCTEST OPTIONS

    context.applyCommandLine(argc, argv);
    return context.run();
}

Additional info

This is a problem especially when using Mocking frameworks like Fakeit or Google Mock as they throw errors when methods are called which have not been mocked out. Without the actual exception its time-consuming to figure out where the error occured.

@ivankravets ivankravets added this to the 6.0 milestone May 13, 2022
@valeros
Copy link
Member

valeros commented May 13, 2022

Hi @Di3mex ! I'm no expert on Doctest, but I guess PlatformIO is not of any help here. It seems that Doctest itself is not able to recognize the exception and PlatformIO simply parses the Doctest output and passes it to you in a unified format. Is there any way to force Doctest to print any additional info, maybe a specific configuration flag or something?

@Di3mex
Copy link
Author

Di3mex commented May 15, 2022

@valeros I did check the configuration options and tried the ones that had something to do with exception handling. They didn't change anything.

@ivankravets
Copy link
Member

Does it work for you if you use the Doctest WITHOUT PlatformIO? I don't think we can solve this issue on our part.

@ivankravets
Copy link
Member

Please reopen if you still need help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants