Skip to content

Commit

Permalink
Merge pull request #1520 from Expensify/main
Browse files Browse the repository at this point in the history
Update expensify_prod branch
  • Loading branch information
rafecolton authored Jun 8, 2023
2 parents 352fa59 + d079096 commit fa8a598
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 9 deletions.
34 changes: 25 additions & 9 deletions test/lib/tpunit++.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,27 @@ int tpunit::TestFixture::tpunit_detail_do_run(int threads, std::function<void()>
return tpunit_detail_do_run(include, exclude, before, after, threads, threadInitFunction);
}

void tpunit::TestFixture::tpunit_run_test_class(TestFixture* f) {
f->_stats._assertions = 0;
f->_stats._exceptions = 0;
tpunit_detail_do_methods(f->_before_classes);
if (f->_stats._assertions || f->_stats._exceptions) {
tpunit_detail_stats()._failures++;
tpunit_detail_stats()._failureNames.emplace(f->_name + "::BEFORE_CLASS"s);
cout << "\xE2\x9D\x8C !FAILED! \xE2\x9D\x8C initializing " << f->_name << ". Skipping tests." << endl;
} else {
tpunit_detail_do_tests(f);
}
f->_stats._assertions = 0;
f->_stats._exceptions = 0;
tpunit_detail_do_methods(f->_after_classes);
if (f->_stats._assertions || f->_stats._exceptions) {
tpunit_detail_stats()._failures++;
tpunit_detail_stats()._failureNames.emplace(f->_name + "::AFTER_CLASS"s);
cout << "\xE2\x9D\x8C !FAILED! \xE2\x9D\x8C cleaning up " << f->_name << "." << endl;
}
}

int tpunit::TestFixture::tpunit_detail_do_run(const set<string>& include, const set<string>& exclude,
const list<string>& before, const list<string>& after, int threads,
std::function<void()> threadInitFunction) {
Expand Down Expand Up @@ -131,9 +152,7 @@ int tpunit::TestFixture::tpunit_detail_do_run(const set<string>& include, const

// Run the test.
printf("--------------\n");
tpunit_detail_do_methods(fixture->_before_classes);
tpunit_detail_do_tests(fixture);
tpunit_detail_do_methods(fixture->_after_classes);
tpunit_run_test_class(fixture);

continue; // Don't bother checking the rest of the tests.
}
Expand Down Expand Up @@ -227,9 +246,8 @@ int tpunit::TestFixture::tpunit_detail_do_run(const set<string>& include, const
currentTestName = "UNSPECIFIED";
}
}
tpunit_detail_do_methods(f->_before_classes);
tpunit_detail_do_tests(f);
tpunit_detail_do_methods(f->_after_classes);

tpunit_run_test_class(f);
}
} catch (ShutdownException se) {
// This will have broken us out of our main loop, so we'll just exit. We also set the exit flag to let
Expand Down Expand Up @@ -258,9 +276,7 @@ int tpunit::TestFixture::tpunit_detail_do_run(const set<string>& include, const

// Run the test.
printf("--------------\n");
tpunit_detail_do_methods(fixture->_before_classes);
tpunit_detail_do_tests(fixture);
tpunit_detail_do_methods(fixture->_after_classes);
tpunit_run_test_class(fixture);

continue; // Don't bother checking the rest of the tests.
}
Expand Down
2 changes: 2 additions & 0 deletions test/lib/tpunit++.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,8 @@ namespace tpunit {

private:

static void tpunit_run_test_class(TestFixture*);

static void tpunit_detail_do_method(method* m);

static void tpunit_detail_do_methods(method* m);
Expand Down

0 comments on commit fa8a598

Please sign in to comment.