| 4 | #include <iostream> |
| 5 | |
| 6 | int main(int argc, char** argv) { |
| 7 | bool verbose = argc > 1 && std::string(argv[1]) == "-v"; |
| 8 | int failures = 0; |
| 9 | |
| 10 | for (const auto& test : SpacetimeDB::UnitTests::all_tests()) { |
| 11 | try { |
| 12 | test.func(); |
| 13 | if (verbose) { |
| 14 | std::cout << "[PASS] " << test.name << '\n'; |
| 15 | } |
| 16 | } catch (const std::exception& ex) { |
| 17 | ++failures; |
| 18 | std::cerr << "[FAIL] " << test.name << ": " << ex.what() << '\n'; |
| 19 | } catch (...) { |
| 20 | ++failures; |
| 21 | std::cerr << "[FAIL] " << test.name << ": unknown exception\n"; |
| 22 | } |
| 23 | } |
| 24 | |
| 25 | if (!verbose) { |
| 26 | if (failures == 0) { |
| 27 | std::cout << "Passed " << SpacetimeDB::UnitTests::all_tests().size() << " unit tests\n"; |
| 28 | } else { |
| 29 | std::cerr << failures << " unit test(s) failed\n"; |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | return failures == 0 ? 0 : 1; |
| 34 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…