diff options
Diffstat (limited to 'framework')
-rw-r--r-- | framework/Framework.cpp | 21 | ||||
-rw-r--r-- | framework/Framework.h | 13 |
2 files changed, 32 insertions, 2 deletions
diff --git a/framework/Framework.cpp b/framework/Framework.cpp index 056ee59860..ac7248c43c 100644 --- a/framework/Framework.cpp +++ b/framework/Framework.cpp @@ -198,6 +198,16 @@ bool Framework::throw_errors() const return _throw_errors; } +void Framework::set_stop_on_error(bool stop_on_error) +{ + _stop_on_error = stop_on_error; +} + +bool Framework::stop_on_error() const +{ + return _stop_on_error; +} + bool Framework::is_selected(const TestInfo &info) const { if((info.mode & _dataset_mode) == DatasetMode::DISABLED) @@ -345,9 +355,16 @@ void Framework::run_test(const TestInfo &info, TestCaseFactory &test_factory) _current_test_result = nullptr; - if(test_factory.status() == TestCaseFactory::Status::EXPECTED_FAILURE && result.status == TestResult::Status::FAILED) + if(result.status == TestResult::Status::FAILED) { - result.status = TestResult::Status::EXPECTED_FAILURE; + if(info.status == TestCaseFactory::Status::EXPECTED_FAILURE) + { + result.status = TestResult::Status::EXPECTED_FAILURE; + } + else if(_stop_on_error) + { + throw std::runtime_error("Abort on first error."); + } } result.measurements = profiler.measurements(); diff --git a/framework/Framework.h b/framework/Framework.h index 0929b4ab20..671e4e435f 100644 --- a/framework/Framework.h +++ b/framework/Framework.h @@ -213,6 +213,18 @@ public: */ void set_throw_errors(bool throw_errors); + /** Indicates if test execution is stopped after the first failed test. + * + * @return True if the execution is going to be aborted after the first failed test. + */ + bool stop_on_error() const; + + /** Set whether to abort execution after the first failed test. + * + * @param[in] stop_on_error True if execution is going to be aborted after first failed test. + */ + void set_stop_on_error(bool stop_on_error); + /** Check if a test case is selected to be executed. * * @param[in] info Test case info. @@ -289,6 +301,7 @@ private: std::map<TestInfo, TestResult> _test_results{}; int _num_iterations{ 1 }; bool _throw_errors{ false }; + bool _stop_on_error{ false }; Printer *_printer{ nullptr }; using create_function = std::unique_ptr<Instrument>(); |