Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
724cbd3
Change all TEST(xxx, yyy) to TEST_F(TestBase, xxx_yyy)
jmarantz Feb 4, 2019
64bba6a
Move the 'DISABLED_' prefix back to the beginning of test-names.
jmarantz Feb 4, 2019
cd608f9
Taste test on pattern for test that does not change its name.
jmarantz Feb 5, 2019
5c21bad
Merge branch 'master' into all-tests-use-test-base
jmarantz Feb 5, 2019
0de32bd
format
jmarantz Feb 5, 2019
459949a
Merge branch 'master' into all-tests-use-test-base
jmarantz Feb 5, 2019
bf666e9
prototype a different way to handle TEST() macros.
jmarantz Feb 5, 2019
35a9e7f
more hacking
jmarantz Feb 5, 2019
fe43b26
Merge branch 'master' into all-tests-use-test-base
jmarantz Feb 7, 2019
2470e0e
backout previous hacks.
jmarantz Feb 7, 2019
ebc0819
Use Alyssa's pattern for making a class for TEST_F with 'using'. Fix …
jmarantz Feb 7, 2019
c2762db
Merge branch 'master' into all-tests-use-test-base
jmarantz Feb 7, 2019
57421dd
Move a base-class definition outside of ASAN ifdefs, as the tests tha…
jmarantz Feb 8, 2019
06df0dd
Add tests for the new TEST macro format-checkers.
jmarantz Feb 8, 2019
fd530dc
Format the formatter.
jmarantz Feb 8, 2019
d10c34a
Merge branch 'master' into all-tests-use-test-base
jmarantz Feb 8, 2019
7f0f5f8
Merge branch 'master' into all-tests-use-test-base
jmarantz Feb 9, 2019
2ff3458
Merge branch 'master' into all-tests-use-test-base
jmarantz Feb 10, 2019
7bf4886
Merge branch 'master' into all-tests-use-test-base
jmarantz Feb 11, 2019
dbe65a2
Merge branch 'master' into all-tests-use-test-base
jmarantz Feb 12, 2019
b0cd75c
Merge branch 'master' into all-tests-use-test-base
jmarantz Feb 13, 2019
f93bf12
Back out the TEST( -> TEST_F( changes in favor of establishing a gtes…
jmarantz Feb 13, 2019
2e8a6c5
Merge branch 'master' into all-tests-use-test-base
jmarantz Feb 13, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions test/test_common/test_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@

namespace Envoy {

void TestBase::checkSingletonQuiescensce() {
void TestListener::OnTestEnd(const ::testing::TestInfo& test_info) {
// Check that all singletons have been destroyed.
std::string active_singletons = Envoy::Test::Globals::describeActiveSingletons();
RELEASE_ASSERT(active_singletons.empty(),
absl::StrCat("FAIL: Active singletons exist:\n", active_singletons));
absl::StrCat("FAIL [", test_info.test_suite_name(), ".", test_info.name(),
"]: Active singletons exist:\n", active_singletons));
}

TestBase::~TestBase() { checkSingletonQuiescensce(); }

} // namespace Envoy
20 changes: 9 additions & 11 deletions test/test_common/test_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Envoy {

// Provides a common test-base class for all tests in Envoy to use. This offers
// Provides a test listener to be called after each test method. This offers
// a place to put hooks we'd like to run on every test. There's currently a
// check that all test-scoped singletons have been destroyed. A test-scoped
// singleton might remain at the end of a test if it's transitively referenced
Expand All @@ -17,18 +17,16 @@ namespace Envoy {
// than there were at the start of it. This is likely to fail in a few
// places when introduced, but we could add known test overrides for this.
//
// Note: nothing compute-intensive should be put in this test-class, as it will
// Note: nothing compute-intensive should be put in this class, as it will
// be a tax paid by every test method in the codebase.
class TestBase : public ::testing::Test {
public:
static void checkSingletonQuiescensce();
~TestBase() override;
class TestListener : public ::testing::EmptyTestEventListener {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bonus points if you can think of a more descriptive name - I currently can't :-P

void OnTestEnd(const ::testing::TestInfo& test_info) override;
};

// Templatized version of TestBase. See above notes.
template <class T> class TestBaseWithParam : public ::testing::TestWithParam<T> {
public:
~TestBaseWithParam() { TestBase::checkSingletonQuiescensce(); }
};
// TODO(jmarantz): Before Alyssa found this TestListener hook for me, we had
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional: think it's worth removing the check_format checks in this PR, just so folks can create new testing::Test classes while we get around to clean up?

// merged a PR that added the same functionality via common TestBase classes.
// These should be removed.
using TestBase = ::testing::Test;
template <class T> using TestBaseWithParam = ::testing::TestWithParam<T>;

} // namespace Envoy
14 changes: 8 additions & 6 deletions test/test_runner.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ class TestRunner {
::testing::InitGoogleMock(&argc, argv);
Event::Libevent::Global::initialize();

// Add a test-listener so we can call a hook where we can do a quiescence
// check after each method. See
// https://github.com/google/googletest/blob/master/googletest/docs/advanced.md
// for details.
::testing::TestEventListeners& listeners = ::testing::UnitTest::GetInstance()->listeners();
listeners.Append(new TestListener);

// Use the recommended, but not default, "threadsafe" style for the Death Tests.
// See: https://github.com/google/googletest/commit/84ec2e0365d791e4ebc7ec249f09078fb5ab6caa
::testing::FLAGS_gtest_death_test_style = "threadsafe";
Expand Down Expand Up @@ -45,12 +52,7 @@ class TestRunner {
file_logger = std::make_unique<Logger::FileSinkDelegate>(
TestEnvironment::getOptions().logPath(), access_log_manager, Logger::Registry::getSink());
}
int exit_status = RUN_ALL_TESTS();

// Check that all singletons have been destroyed.
TestBase::checkSingletonQuiescensce();

return exit_status;
return RUN_ALL_TESTS();
}
};
} // namespace Envoy