Skip to content

Make exit codes available to users #2955

@Laguna1989

Description

@Laguna1989

Description
Currently (catch2 v3.8.0) the exit codes are defined in an anonymous namespace inside catch_session.cpp. permalink to github code

namespace Catch {

    namespace {
        static constexpr int TestFailureExitCode = 42;
        static constexpr int UnspecifiedErrorExitCode = 1;
        static constexpr int AllTestsSkippedExitCode = 4;
        static constexpr int NoTestsRunExitCode = 2;
        static constexpr int UnmatchedTestSpecExitCode = 3;
        static constexpr int InvalidTestSpecExitCode = 5;
// more code
    }
}

When writing a user-defined main function that calls auto const result = Catch::Session().run(argc, argv), it would be helpful to be able compare the returned result to the defined values.
Currently this is not possible as they are only inside the anonymous namespace, leading to internal linkage. Redefining the exit values in user code is not optimal.

My suggestion would be to define the exit codes in the catch_session.hpp header, so they are available to end-users.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions