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;
int opt = 0;
while((opt = getopt(argc, argv, "fvn:")) != -1) {
while((opt = getopt(argc, argv, "fvm:")) != -1) {
switch(opt) {
case 'f':
result.fail_fast = true;
@ -16,7 +16,7 @@ namespace fuc2 {
case 'v':
result.verbose = true;
break;
case 'n':
case 'm':
result.matching = std::string(optarg);
break;
}
@ -86,6 +86,11 @@ namespace fuc2 {
auto opts = parse_options(argc, argv);
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);
if(opts.fail_fast && fail_count > 0) {

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

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

Loading…
Cancel
Save