mirror of
https://github.com/catchorg/Catch2.git
synced 2025-04-29 04:03:51 +00:00
Add return code constants to API
This commit is contained in:
parent
dde8220613
commit
6244a357ea
@ -63,11 +63,12 @@ int main( int argc, char* argv[] ) {
|
|||||||
// overrides command line args
|
// overrides command line args
|
||||||
// only do this if you know you need to
|
// only do this if you know you need to
|
||||||
|
|
||||||
int numFailed = session.run();
|
returnCode = session.run();
|
||||||
|
|
||||||
|
// returnCode encodes the type of error that occured. See the
|
||||||
|
// integer constants in catch_session.hpp for more information
|
||||||
|
// on what each return code means.
|
||||||
|
|
||||||
// numFailed is clamped to 255 as some unices only use the lower 8 bits.
|
|
||||||
// This clamping has already been applied, so just return it here
|
|
||||||
// You can also do any post run clean-up here
|
|
||||||
return numFailed;
|
return numFailed;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
@ -33,14 +33,6 @@
|
|||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
namespace {
|
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;
|
|
||||||
|
|
||||||
|
|
||||||
IEventListenerPtr createReporter(std::string const& reporterName, ReporterConfig&& config) {
|
IEventListenerPtr createReporter(std::string const& reporterName, ReporterConfig&& config) {
|
||||||
auto reporter = Catch::getRegistryHub().getReporterRegistry().create(reporterName, CATCH_MOVE(config));
|
auto reporter = Catch::getRegistryHub().getReporterRegistry().create(reporterName, CATCH_MOVE(config));
|
||||||
CATCH_ENFORCE(reporter, "No reporter registered with name: '" << reporterName << '\'');
|
CATCH_ENFORCE(reporter, "No reporter registered with name: '" << reporterName << '\'');
|
||||||
|
@ -16,6 +16,14 @@
|
|||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
|
// TODO: Use C++17 `inline` variables
|
||||||
|
constexpr int UnspecifiedErrorExitCode = 1;
|
||||||
|
constexpr int NoTestsRunExitCode = 2;
|
||||||
|
constexpr int UnmatchedTestSpecExitCode = 3;
|
||||||
|
constexpr int AllTestsSkippedExitCode = 4;
|
||||||
|
constexpr int InvalidTestSpecExitCode = 5;
|
||||||
|
constexpr int TestFailureExitCode = 42;
|
||||||
|
|
||||||
class Session : Detail::NonCopyable {
|
class Session : Detail::NonCopyable {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user