Skip to content

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

@adomasbaliuka

Description

@adomasbaliuka

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".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions