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

Tests broken: first TEST_CASE("Parse help", "[help]") calls exit(0). #29

Open
adomasbaliuka opened this issue Dec 16, 2021 · 0 comments

Comments

@adomasbaliuka
Copy link

adomasbaliuka commented Dec 16, 2021

Currently, the tests cannot be run by invoking the test-executable.

This is because the very first test ( "Parse help", "[help]" ) leads to exit(0) being called inside a callback created in void enable_help(). After that, the test executable exits. The checks contained in that test are never executed. Also, no further tests are executed. This means that whenever ( "Parse help", "[help]" ) is included in the list of tests to be run, some or all of the tests will not be run at all, depending on the order of tests.

The callback looks like this:

void enable_help() {
    set_callback("h", "help", std::function<bool(CallbackArgs & )>([this](CallbackArgs &args) {
        args.output << this->usage();
#pragma warning(push)
#pragma warning(disable: 4702)
        exit(0);
        return false;
#pragma warning(pop)
    }), "", true);
}

It seems that this callback really should quit the program when used in user code. Hence, I don't know how to best solve this problem for the unit tests. Perhaps the problematic test case should be removed, especially since it doesn't actually test anything?

As an aside, perhaps the pragma warning modification (which are specific to MSVS compiler) to really be specific to that compiler, e.g., like this:

#if defined(_MSC_VER)
// pragma ...
#endif

Other compilers don't support this and the pragma sometimes becomes a warning in itself, as in "unknown pragma".

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

No branches or pull requests

1 participant