Skip to content

Commit c2720fc

Browse files
committed
only run enabled tests
1 parent 291ff20 commit c2720fc

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

test-suite/paralleltestrunner.hpp

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#include <boost/interprocess/sync/named_mutex.hpp>
4242
#include <boost/interprocess/sync/scoped_lock.hpp>
4343
#include <boost/thread/thread.hpp>
44+
#include <boost/timer/timer.hpp>
4445

4546
#define BOOST_TEST_NO_MAIN 1
4647
#include <boost/algorithm/string.hpp>
@@ -80,7 +81,9 @@ namespace {
8081
bool visit(test_unit const& tu) override {
8182
if (tu.p_parent_id == framework::master_test_suite().p_id) {
8283
testSuiteId_ = tu.p_id;
83-
} else if (tu.p_type == test_unit_type::TUT_SUITE && tu.p_parent_id == testSuiteId_) {
84+
} else if (tu.p_type == test_unit_type::TUT_SUITE && tu.p_parent_id == testSuiteId_ &&
85+
tu.is_enabled()) {
86+
std::cout << "TestSuite: " << tu.p_name << ", id=" << tu.p_id << " and parent=" << tu.p_parent_id << std::endl;
8487
idMap_[tu.p_parent_id].push_back(tu.p_id);
8588
}
8689
return test_tree_visitor::visit(tu);
@@ -128,6 +131,7 @@ test_suite* init_unit_test_suite(int, char*[]);
128131

129132
int main(int argc, char* argv[]) {
130133
typedef QuantLib::Time Time;
134+
boost::timer::cpu_timer testTimer;
131135

132136
std::string moduleName = BOOST_TEST_MODULE;
133137
std::string profileFileNameStr = moduleName + "_unit_test_profile.txt";
@@ -303,6 +307,19 @@ int main(int argc, char* argv[]) {
303307
thread.join();
304308
}
305309

310+
testTimer.stop();
311+
double seconds = testTimer.elapsed().wall * 1e-9;
312+
int hours = int(seconds / 3600);
313+
seconds -= hours * 3600;
314+
int minutes = int(seconds / 60);
315+
seconds -= minutes * 60;
316+
std::cout << std::endl << BOOST_TEST_MODULE << " tests completed in ";
317+
if (hours > 0)
318+
std::cout << hours << " h ";
319+
if (hours > 0 || minutes > 0)
320+
std::cout << minutes << " m ";
321+
std::cout << std::fixed << std::setprecision(0) << seconds << " s" << std::endl;
322+
306323
} else {
307324
framework::init(init_unit_test_suite, argc - 1, argv);
308325
framework::finalize_setup_phase();
@@ -333,7 +350,9 @@ int main(int argc, char* argv[]) {
333350
to->test_finish();
334351
#else
335352
// works for BOOST_VERSION > 106100, needed for >106500
353+
std::cout << "running id: " << id.id << std::endl;
336354
framework::run(id.id, false);
355+
std::cout << "finished running id: " << id.id << std::endl;
337356
#endif
338357

339358
auto stopTime = std::chrono::steady_clock::now();

0 commit comments

Comments
 (0)