Skip to content

Commit 1cef399

Browse files
committed
Add --abort-on-first-fail to tests
1 parent 1eb3ac6 commit 1cef399

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

FlashMQTests/main.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ int main(int argc, char *argv[])
1313
{
1414
bool skip_tests_with_internet = false;
1515
bool skip_server_tests = false;
16+
bool abort_on_first_fail = false;
1617
std::vector<std::string> tests;
1718
bool option_list_terminated = false;
1819

@@ -33,6 +34,8 @@ int main(int argc, char *argv[])
3334
skip_tests_with_internet = true;
3435
else if (name == "--skip-server-tests")
3536
skip_server_tests = true;
37+
else if (name == "--abort-on-first-fail")
38+
abort_on_first_fail = true;
3639
else if (name.find("--") == 0)
3740
{
3841
std::cerr << "Unknown argument " << name << std::endl;
@@ -44,7 +47,7 @@ int main(int argc, char *argv[])
4447
}
4548

4649
MainTests maintests;
47-
if (!maintests.test(skip_tests_with_internet, skip_server_tests, tests))
50+
if (!maintests.test(skip_tests_with_internet, skip_server_tests, abort_on_first_fail, tests))
4851
return 1;
4952

5053
return 0;

FlashMQTests/maintests.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ MainTests::MainTests()
343343
REGISTER_FUNCTION(testSubscriptionIdOverlappingSubscriptions);
344344
}
345345

346-
bool MainTests::test(bool skip_tests_with_internet, bool skip_server_tests, const std::vector<std::string> &tests)
346+
bool MainTests::test(bool skip_tests_with_internet, bool skip_server_tests, bool abort_on_first_fail, const std::vector<std::string> &tests)
347347
{
348348
int testCount = 0;
349349
int testPassCount = 0;
@@ -375,6 +375,9 @@ bool MainTests::test(bool skip_tests_with_internet, bool skip_server_tests, cons
375375

376376
for (const auto &pair : *selectedTests)
377377
{
378+
if (abort_on_first_fail && testFailCount > 0)
379+
break;
380+
378381
const TestFunction &tf = pair.second;
379382

380383
if (skip_tests_with_internet && tf.requiresInternet)

FlashMQTests/maintests.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ class MainTests
267267
public:
268268
MainTests();
269269

270-
bool test(bool skip_tests_with_internet, bool skip_server_tests, const std::vector<std::string> &tests);
270+
bool test(bool skip_tests_with_internet, bool skip_server_tests, bool abort_on_first_fail, const std::vector<std::string> &tests);
271271
};
272272

273273
#endif // MAINTESTS_H

0 commit comments

Comments
 (0)