From d31eb712ebe828e742d79245586651d142db848d Mon Sep 17 00:00:00 2001 From: Michael Lee Date: Mon, 22 Feb 2016 08:42:18 -0800 Subject: [PATCH] Remove extra `int main`s from unit tests. Summary: test/common/TestMain.cpp should provide the necessary initialization. Reviewed By: yfeldblum Differential Revision: D2947245 fb-gh-sync-id: 75b9d241673667badf4dc8fb81285c60cbb8166a shipit-source-id: 75b9d241673667badf4dc8fb81285c60cbb8166a --- folly/gen/test/FileTest.cpp | 6 ------ folly/gen/test/StringTest.cpp | 6 ------ folly/io/test/IOBufQueueTest.cpp | 7 ------- folly/io/test/IOBufTest.cpp | 7 ------- folly/io/test/ShutdownSocketSetTest.cpp | 6 ------ folly/test/AtomicStructTest.cpp | 7 ------- folly/test/DynamicConverterTest.cpp | 12 ------------ folly/test/DynamicTest.cpp | 7 ------- folly/test/ExceptionTest.cpp | 6 ------ folly/test/FBVectorTest.cpp | 8 -------- folly/test/FileTest.cpp | 1 - folly/test/FileUtilTest.cpp | 8 -------- folly/test/FutexTest.cpp | 7 ------- folly/test/IndexedMemPoolTest.cpp | 7 ------- folly/test/JsonTest.cpp | 7 ------- folly/test/MPMCQueueTest.cpp | 8 -------- folly/test/ScopeGuardTest.cpp | 7 ------- folly/test/SingletonTest.cpp | 12 ------------ folly/test/TraitsTest.cpp | 11 ----------- 19 files changed, 140 deletions(-) diff --git a/folly/gen/test/FileTest.cpp b/folly/gen/test/FileTest.cpp index 5aefacea..a32714e0 100644 --- a/folly/gen/test/FileTest.cpp +++ b/folly/gen/test/FileTest.cpp @@ -93,9 +93,3 @@ INSTANTIATE_TEST_CASE_P( DifferentBufferSizes, FileGenBufferedTest, ::testing::Values(0, 1, 2, 4, 8, 64, 4096)); - -int main(int argc, char *argv[]) { - testing::InitGoogleTest(&argc, argv); - gflags::ParseCommandLineFlags(&argc, &argv, true); - return RUN_ALL_TESTS(); -} diff --git a/folly/gen/test/StringTest.cpp b/folly/gen/test/StringTest.cpp index 15454be6..65c79462 100644 --- a/folly/gen/test/StringTest.cpp +++ b/folly/gen/test/StringTest.cpp @@ -361,9 +361,3 @@ TEST(StringGen, Batch) { EXPECT_EQ(lines, from(chunks) | resplit('\n') | eachTo() | batch(3) | rconcat | as()); } - -int main(int argc, char *argv[]) { - testing::InitGoogleTest(&argc, argv); - gflags::ParseCommandLineFlags(&argc, &argv, true); - return RUN_ALL_TESTS(); -} diff --git a/folly/io/test/IOBufQueueTest.cpp b/folly/io/test/IOBufQueueTest.cpp index f9bc9925..59066228 100644 --- a/folly/io/test/IOBufQueueTest.cpp +++ b/folly/io/test/IOBufQueueTest.cpp @@ -385,10 +385,3 @@ TEST(IOBufQueue, AppendToString) { queue.appendToString(s); EXPECT_EQ("hello world", s); } - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - gflags::ParseCommandLineFlags(&argc, &argv, true); - - return RUN_ALL_TESTS(); -} diff --git a/folly/io/test/IOBufTest.cpp b/folly/io/test/IOBufTest.cpp index db43be6b..ca39013d 100644 --- a/folly/io/test/IOBufTest.cpp +++ b/folly/io/test/IOBufTest.cpp @@ -1233,10 +1233,3 @@ TEST(IOBuf, Managed) { writableStr(*buf2)[0] = 'x'; EXPECT_EQ("jelloxorldhelloxorld", toString(*buf1)); } - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - gflags::ParseCommandLineFlags(&argc, &argv, true); - - return RUN_ALL_TESTS(); -} diff --git a/folly/io/test/ShutdownSocketSetTest.cpp b/folly/io/test/ShutdownSocketSetTest.cpp index 528783c7..88b9e989 100644 --- a/folly/io/test/ShutdownSocketSetTest.cpp +++ b/folly/io/test/ShutdownSocketSetTest.cpp @@ -223,9 +223,3 @@ TEST(ShutdownSocketSetTest, AbortiveKill) { } }} // namespaces - -int main(int argc, char *argv[]) { - testing::InitGoogleTest(&argc, argv); - gflags::ParseCommandLineFlags(&argc, &argv, true); - return RUN_ALL_TESTS(); -} diff --git a/folly/test/AtomicStructTest.cpp b/folly/test/AtomicStructTest.cpp index 3e54b875..b6d0a074 100644 --- a/folly/test/AtomicStructTest.cpp +++ b/folly/test/AtomicStructTest.cpp @@ -16,7 +16,6 @@ #include -#include #include using namespace folly; @@ -68,9 +67,3 @@ TEST(AtomicStruct, size_selection) { EXPECT_EQ(sizeof(AtomicStruct), 8); EXPECT_EQ(sizeof(AtomicStruct), 8); } - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - gflags::ParseCommandLineFlags(&argc, &argv, true); - return RUN_ALL_TESTS(); -} diff --git a/folly/test/DynamicConverterTest.cpp b/folly/test/DynamicConverterTest.cpp index 625aff07..5c10d824 100644 --- a/folly/test/DynamicConverterTest.cpp +++ b/folly/test/DynamicConverterTest.cpp @@ -19,13 +19,10 @@ #include #include -#include #include #include #include -#include - using namespace folly; using namespace folly::dynamicconverter_detail; @@ -364,12 +361,3 @@ TEST(DynamicConverter, errors) { dynamic d2 = floatOver; EXPECT_THROW(convertTo(d2), std::range_error); } - -int main(int argc, char ** argv) { - testing::InitGoogleTest(&argc, argv); - gflags::ParseCommandLineFlags(&argc, &argv, true); - if (FLAGS_benchmark) { - folly::runBenchmarks(); - } - return RUN_ALL_TESTS(); -} diff --git a/folly/test/DynamicTest.cpp b/folly/test/DynamicTest.cpp index 7b85e5c4..93034db8 100644 --- a/folly/test/DynamicTest.cpp +++ b/folly/test/DynamicTest.cpp @@ -17,7 +17,6 @@ #include #include -#include #include using folly::dynamic; @@ -480,9 +479,3 @@ TEST(Dynamic, PrintNull) { ss << folly::dynamic(nullptr); EXPECT_EQ("null", ss.str()); } - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - gflags::ParseCommandLineFlags(&argc, &argv, true); - return RUN_ALL_TESTS(); -} diff --git a/folly/test/ExceptionTest.cpp b/folly/test/ExceptionTest.cpp index ad54cbb2..49232faa 100644 --- a/folly/test/ExceptionTest.cpp +++ b/folly/test/ExceptionTest.cpp @@ -88,9 +88,3 @@ TEST(ExceptionTest, Simple) { } }} // namespaces - -int main(int argc, char *argv[]) { - testing::InitGoogleTest(&argc, argv); - gflags::ParseCommandLineFlags(&argc, &argv, true); - return RUN_ALL_TESTS(); -} diff --git a/folly/test/FBVectorTest.cpp b/folly/test/FBVectorTest.cpp index 4fadf2cd..ce4fa978 100644 --- a/folly/test/FBVectorTest.cpp +++ b/folly/test/FBVectorTest.cpp @@ -23,8 +23,6 @@ #include #include -#include - #include #include #include @@ -282,9 +280,3 @@ TEST(FBVector, shrink_to_fit_after_clear) { EXPECT_EQ(fb1.size(), 0); EXPECT_EQ(fb1.capacity(), 0); } - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - gflags::ParseCommandLineFlags(&argc, &argv, true); - return RUN_ALL_TESTS(); -} diff --git a/folly/test/FileTest.cpp b/folly/test/FileTest.cpp index 2bed3c03..ffe0bc19 100644 --- a/folly/test/FileTest.cpp +++ b/folly/test/FileTest.cpp @@ -22,7 +22,6 @@ #include #include -#include #include #include #include diff --git a/folly/test/FileUtilTest.cpp b/folly/test/FileUtilTest.cpp index adedc522..6a7f5e2e 100644 --- a/folly/test/FileUtilTest.cpp +++ b/folly/test/FileUtilTest.cpp @@ -21,10 +21,8 @@ #include #include -#include #include -#include #include #include @@ -308,9 +306,3 @@ TEST(String, readFile) { } }} // namespaces - -int main(int argc, char *argv[]) { - testing::InitGoogleTest(&argc, argv); - gflags::ParseCommandLineFlags(&argc, &argv, true); - return RUN_ALL_TESTS(); -} diff --git a/folly/test/FutexTest.cpp b/folly/test/FutexTest.cpp index 3348af3a..86682c5e 100644 --- a/folly/test/FutexTest.cpp +++ b/folly/test/FutexTest.cpp @@ -22,7 +22,6 @@ #include #include -#include #include #include #include @@ -207,9 +206,3 @@ TEST(Futex, basic_deterministic) { run_basic_tests(); run_wait_until_tests(); } - -int main(int argc, char ** argv) { - testing::InitGoogleTest(&argc, argv); - gflags::ParseCommandLineFlags(&argc, &argv, true); - return RUN_ALL_TESTS(); -} diff --git a/folly/test/IndexedMemPoolTest.cpp b/folly/test/IndexedMemPoolTest.cpp index 606d9565..5c7a9733 100644 --- a/folly/test/IndexedMemPoolTest.cpp +++ b/folly/test/IndexedMemPoolTest.cpp @@ -20,7 +20,6 @@ #include #include #include -#include #include using namespace folly; @@ -216,9 +215,3 @@ TEST(IndexedMemPool, late_recycle) { } EXPECT_EQ(NonTrivialStruct::count, 0); } - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - gflags::ParseCommandLineFlags(&argc, &argv, true); - return RUN_ALL_TESTS(); -} diff --git a/folly/test/JsonTest.cpp b/folly/test/JsonTest.cpp index ec27a901..18540169 100644 --- a/folly/test/JsonTest.cpp +++ b/folly/test/JsonTest.cpp @@ -18,7 +18,6 @@ #include #include -#include #include using folly::dynamic; @@ -521,9 +520,3 @@ TEST(Json, PrintTo) { PrintTo(value, &oss); EXPECT_EQ(expected, oss.str()); } - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - gflags::ParseCommandLineFlags(&argc, &argv, true); - return RUN_ALL_TESTS(); -} diff --git a/folly/test/MPMCQueueTest.cpp b/folly/test/MPMCQueueTest.cpp index 6c7cf258..394b5838 100644 --- a/folly/test/MPMCQueueTest.cpp +++ b/folly/test/MPMCQueueTest.cpp @@ -28,7 +28,6 @@ #include #include -#include #include FOLLY_ASSUME_FBVECTOR_COMPATIBLE_1(boost::intrusive_ptr); @@ -715,10 +714,3 @@ TEST(MPMCQueue, queue_moving) { TEST(MPMCQueue, explicit_zero_capacity_fail) { ASSERT_THROW(MPMCQueue cq(0), std::invalid_argument); } - - -int main(int argc, char ** argv) { - testing::InitGoogleTest(&argc, argv); - gflags::ParseCommandLineFlags(&argc, &argv, true); - return RUN_ALL_TESTS(); -} diff --git a/folly/test/ScopeGuardTest.cpp b/folly/test/ScopeGuardTest.cpp index 790484f9..5310eff7 100644 --- a/folly/test/ScopeGuardTest.cpp +++ b/folly/test/ScopeGuardTest.cpp @@ -17,7 +17,6 @@ #include #include -#include #include #include @@ -290,9 +289,3 @@ TEST(ScopeGuard, TEST_SCOPE_SUCCESS_THROW) { }; EXPECT_THROW(lambda(), std::runtime_error); } - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - gflags::ParseCommandLineFlags(&argc, &argv, true); - return RUN_ALL_TESTS(); -} diff --git a/folly/test/SingletonTest.cpp b/folly/test/SingletonTest.cpp index 46463554..b36b4709 100644 --- a/folly/test/SingletonTest.cpp +++ b/folly/test/SingletonTest.cpp @@ -580,15 +580,3 @@ TEST(Singleton, MockTest) { // If serial_count value is the same, then singleton was not replaced. EXPECT_NE(serial_count_first, serial_count_mock); } - -int main(int argc, char* argv[]) { - testing::InitGoogleTest(&argc, argv); - google::InitGoogleLogging(argv[0]); - gflags::ParseCommandLineFlags(&argc, &argv, true); - - SingletonVault::singleton()->registrationComplete(); - - auto ret = RUN_ALL_TESTS(); - - return ret; -} diff --git a/folly/test/TraitsTest.cpp b/folly/test/TraitsTest.cpp index 80fb2205..c76f1daa 100644 --- a/folly/test/TraitsTest.cpp +++ b/folly/test/TraitsTest.cpp @@ -14,10 +14,8 @@ * limitations under the License. */ -#include #include -#include #include using namespace folly; @@ -118,12 +116,3 @@ TEST(Traits, has_member_type) { EXPECT_FALSE(bool(has_member_type_x::value)); EXPECT_TRUE(bool(has_member_type_x::value)); } - -int main(int argc, char ** argv) { - testing::InitGoogleTest(&argc, argv); - gflags::ParseCommandLineFlags(&argc, &argv, true); - if (FLAGS_benchmark) { - folly::runBenchmarks(); - } - return RUN_ALL_TESTS(); -} -- 2.34.1