Skip to content

Commit 4054607

Browse files
committed
cleanup Application
1 parent 50a2bce commit 4054607

File tree

2 files changed

+5
-38
lines changed

2 files changed

+5
-38
lines changed

cucumber_cpp/library/Application.cpp

Lines changed: 3 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#include "cucumber_cpp/library/cucumber_expression/Errors.hpp"
1010
#include "cucumber_cpp/library/cucumber_expression/Matcher.hpp"
1111
#include "cucumber_cpp/library/cucumber_expression/ParameterRegistry.hpp"
12-
#include "cucumber_cpp/library/engine/NewRuntime.hpp"
1312
#include "cucumber_cpp/library/formatter/SummaryFormatter.hpp"
1413
#include "cucumber_cpp/library/support/Types.hpp"
1514
#include "cucumber_cpp/library/util/Broadcaster.hpp"
@@ -174,33 +173,10 @@ namespace cucumber_cpp::library
174173

175174
void Application::RunFeatures()
176175
{
177-
struct BroadcastListener
178-
{
179-
explicit BroadcastListener(util::Broadcaster& broadcaster)
180-
: listener(broadcaster, [this](const cucumber::messages::envelope& envelope)
181-
{
182-
OnEvent(envelope);
183-
})
184-
{}
185-
186-
void OnEvent(const cucumber::messages::envelope& envelope)
187-
{
188-
std::cout << envelope.to_json() << "\n";
189-
}
190-
191-
private:
192-
util::Listener listener;
193-
};
194-
195-
// BroadcastListener broadcastListener{ broadcaster };
196-
197-
// for (const auto& selectedReporter : options.reporters)
198-
// reporters.Use(selectedReporter);
199-
200176
const auto tagExpression = Join(options.tags, " ");
201177
const auto featureFiles = GetFeatureFiles(options);
202178

203-
support::RunOptions runOptions{
179+
const auto runOptions = support::RunOptions{
204180
.sources = {
205181
.paths = featureFiles,
206182
.tagExpression = tagExpression,
@@ -213,15 +189,12 @@ namespace cucumber_cpp::library
213189
auto& listeners = testing::UnitTest::GetInstance()->listeners();
214190
auto* defaultEventListener = listeners.Release(listeners.default_result_printer());
215191

216-
api::RunCucumber(runOptions, parameterRegistry, *programContext, broadcaster);
192+
runPassed = api::RunCucumber(runOptions, parameterRegistry, *programContext, broadcaster);
217193

218194
listeners.Append(defaultEventListener);
219195

220196
// if (options.printStepsNotUsed)
221197
// PrintStepsNotUsed(stepRegistry);
222-
223-
std::cout << '\n'
224-
<< std::flush;
225198
}
226199

227200
void Application::PrintStepsNotUsed(const StepRegistry& stepRegistry) const
@@ -245,14 +218,6 @@ namespace cucumber_cpp::library
245218

246219
int Application::GetExitCode() const
247220
{
248-
return 0;
249-
// if (testing::UnitTest::GetInstance()->Failed())
250-
// return GetExitCode(engine::Result::failed);
251-
// return GetExitCode(engine::Result::passed);
221+
return runPassed ? 0 : 1;
252222
}
253-
254-
// int Application::GetExitCode(engine::Result result) const
255-
// {
256-
// return static_cast<std::underlying_type_t<engine::Result>>(result) - static_cast<std::underlying_type_t<engine::Result>>(engine::Result::passed);
257-
// }
258223
}

cucumber_cpp/library/Application.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ namespace cucumber_cpp::library
7272
bool removeDefaultGoogleTestListener;
7373
support::StopWatchHighResolutionClock stopwatchHighResolutionClock;
7474
support::TimestampGeneratorSystemClock timestampGeneratorSystemClock;
75+
76+
bool runPassed{ false };
7577
};
7678
}
7779

0 commit comments

Comments
 (0)