Add --offset parameter to TestRunner.

This commit is contained in:
levlam 2023-05-18 12:52:30 +03:00
parent fe4b1a16ef
commit 3d06cdd94e
3 changed files with 13 additions and 1 deletions

View File

@ -182,6 +182,10 @@ void TestsRunner::add_substr_filter(string str) {
substr_filters_.push_back(std::move(str)); substr_filters_.push_back(std::move(str));
} }
void TestsRunner::set_offset(string str) {
offset_ = std::move(str);
}
void TestsRunner::set_regression_tester(unique_ptr<RegressionTester> regression_tester) { void TestsRunner::set_regression_tester(unique_ptr<RegressionTester> regression_tester) {
regression_tester_ = std::move(regression_tester); regression_tester_ = std::move(regression_tester);
} }
@ -202,6 +206,7 @@ bool TestsRunner::run_all_step() {
state_.it = 0; state_.it = 0;
} }
bool skip_tests = true;
while (state_.it != state_.end) { while (state_.it != state_.end) {
auto &name = tests_[state_.it].first; auto &name = tests_[state_.it].first;
auto &test = tests_[state_.it].second.test; auto &test = tests_[state_.it].second.test;
@ -214,7 +219,10 @@ bool TestsRunner::run_all_step() {
break; break;
} }
} }
if (!ok) { if (name.find(offset_) != string::npos) {
skip_tests = false;
}
if (!ok || skip_tests) {
++state_.it; ++state_.it;
continue; continue;
} }

View File

@ -94,6 +94,7 @@ class TestsRunner final : public TestContext {
void add_test(string name, std::function<unique_ptr<Test>()> test); void add_test(string name, std::function<unique_ptr<Test>()> test);
void add_substr_filter(string str); void add_substr_filter(string str);
void set_offset(string str);
void set_stress_flag(bool flag); void set_stress_flag(bool flag);
void run_all(); void run_all();
bool run_all_step(); bool run_all_step();
@ -109,6 +110,7 @@ class TestsRunner final : public TestContext {
}; };
bool stress_flag_{false}; bool stress_flag_{false};
vector<string> substr_filters_; vector<string> substr_filters_;
string offset_;
struct TestInfo { struct TestInfo {
std::function<unique_ptr<Test>()> creator; std::function<unique_ptr<Test>()> creator;
unique_ptr<Test> test; unique_ptr<Test> test;

View File

@ -32,6 +32,8 @@ int main(int argc, char **argv) {
td::OptionParser options; td::OptionParser options;
options.add_option('f', "filter", "run only specified tests", options.add_option('f', "filter", "run only specified tests",
[&](td::Slice filter) { runner.add_substr_filter(filter.str()); }); [&](td::Slice filter) { runner.add_substr_filter(filter.str()); });
options.add_option('o', "offset", "run tests from the specified test",
[&](td::Slice offset) { runner.set_offset(offset.str()); });
options.add_option('s', "stress", "run tests infinitely", [&] { runner.set_stress_flag(true); }); options.add_option('s', "stress", "run tests infinitely", [&] { runner.set_stress_flag(true); });
options.add_checked_option('v', "verbosity", "log verbosity level", options.add_checked_option('v', "verbosity", "log verbosity level",
td::OptionParser::parse_integer(default_verbosity_level)); td::OptionParser::parse_integer(default_verbosity_level));