Can now give a matching criteria for tests to run by their names.

master
Zed A. Shaw 1 month ago
parent bb5a9c6549
commit be0dbc9255
  1. 9
      src/run.cpp
  2. 2
      tests/sample1.cpp
  3. 2
      tests/sample_failing.cpp

@ -8,7 +8,7 @@ namespace fuc2 {
Options result; Options result;
int opt = 0; int opt = 0;
while((opt = getopt(argc, argv, "fvn:")) != -1) { while((opt = getopt(argc, argv, "fvm:")) != -1) {
switch(opt) { switch(opt) {
case 'f': case 'f':
result.fail_fast = true; result.fail_fast = true;
@ -16,7 +16,7 @@ namespace fuc2 {
case 'v': case 'v':
result.verbose = true; result.verbose = true;
break; break;
case 'n': case 'm':
result.matching = std::string(optarg); result.matching = std::string(optarg);
break; break;
} }
@ -86,6 +86,11 @@ namespace fuc2 {
auto opts = parse_options(argc, argv); auto opts = parse_options(argc, argv);
for(auto& test : tests) { for(auto& test : tests) {
// skip everything except ones matching the name
if(!test.name.contains(opts.matching)) {
continue;
}
fail_count += run(test, opts, argc > 1); fail_count += run(test, opts, argc > 1);
if(opts.fail_fast && fail_count > 0) { if(opts.fail_fast && fail_count > 0) {

@ -56,7 +56,7 @@ namespace sample1 {
} }
fuc2::Set TESTS{ fuc2::Set TESTS{
.name="std::deque basic operations", .name="deque_basic",
.options={ .fail_fast=false }, .options={ .fail_fast=false },
.tests={ .tests={
TEST(test_push_pop_back), TEST(test_push_pop_back),

@ -36,7 +36,7 @@ namespace sample_failing {
} }
fuc2::Set TESTS{ fuc2::Set TESTS{
.name="std::deque failing ops", .name="deque_failing",
.options={ .fail_fast=false }, .options={ .fail_fast=false },
.tests={ .tests={
TEST(fail_push_pop_back), TEST(fail_push_pop_back),

Loading…
Cancel
Save