aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTor Brede Vekterli <vekterli@verizonmedia.com>2019-02-22 16:36:31 +0100
committerGitHub <noreply@github.com>2019-02-22 16:36:31 +0100
commit9cc6f15ec3c3fc2a96996d62548b0526149e5d5d (patch)
tree047e0b5f391988c814ad1abf5ddca5c2230fb330
parenta56fbe36bd898a24c8e5a30b6988a8e76192bf91 (diff)
parent218640e48925608f019bc10bc17a52b6fe56ec47 (diff)
Merge pull request #8587 from vespa-engine/geirst/simplify-gtest-runners
Reduce code duplication in gtest runners.
-rw-r--r--document/src/tests/gtest_runner.cpp10
-rw-r--r--metrics/src/tests/gtest_runner.cpp10
-rw-r--r--staging_vespalib/src/vespa/vespalib/gtest/gtest.h14
-rw-r--r--storage/src/tests/gtest_runner.cpp10
-rw-r--r--storageapi/src/tests/gtest_runner.cpp10
-rw-r--r--storageframework/src/tests/gtest_runner.cpp10
-rw-r--r--vdslib/src/tests/gtest_runner.cpp10
7 files changed, 26 insertions, 48 deletions
diff --git a/document/src/tests/gtest_runner.cpp b/document/src/tests/gtest_runner.cpp
index efe108c2042..fed042acceb 100644
--- a/document/src/tests/gtest_runner.cpp
+++ b/document/src/tests/gtest_runner.cpp
@@ -1,14 +1,8 @@
// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <gtest/gtest.h>
+#include <vespa/vespalib/gtest/gtest.h>
#include <vespa/log/log.h>
LOG_SETUP("document_gtest_runner");
-int
-main(int argc, char* argv[])
-{
- ::testing::InitGoogleTest(&argc, argv);
- return RUN_ALL_TESTS();
-}
-
+GTEST_MAIN_RUN_ALL_TESTS
diff --git a/metrics/src/tests/gtest_runner.cpp b/metrics/src/tests/gtest_runner.cpp
index 35475ba19a9..2f0e0705792 100644
--- a/metrics/src/tests/gtest_runner.cpp
+++ b/metrics/src/tests/gtest_runner.cpp
@@ -1,14 +1,8 @@
// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <gtest/gtest.h>
+#include <vespa/vespalib/gtest/gtest.h>
#include <vespa/log/log.h>
LOG_SETUP("metrics_gtest_runner");
-int
-main(int argc, char* argv[])
-{
- ::testing::InitGoogleTest(&argc, argv);
- return RUN_ALL_TESTS();
-}
-
+GTEST_MAIN_RUN_ALL_TESTS
diff --git a/staging_vespalib/src/vespa/vespalib/gtest/gtest.h b/staging_vespalib/src/vespa/vespalib/gtest/gtest.h
new file mode 100644
index 00000000000..ed4e65b71cb
--- /dev/null
+++ b/staging_vespalib/src/vespa/vespalib/gtest/gtest.h
@@ -0,0 +1,14 @@
+// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+#include <gtest/gtest.h>
+
+/**
+ * Macro for creating a main function that runs all gtests.
+ */
+#define GTEST_MAIN_RUN_ALL_TESTS \
+int \
+main(int argc, char* argv[]) \
+{ \
+ ::testing::InitGoogleTest(&argc, argv); \
+ return RUN_ALL_TESTS(); \
+}
diff --git a/storage/src/tests/gtest_runner.cpp b/storage/src/tests/gtest_runner.cpp
index f3400187ff4..762f6dba6db 100644
--- a/storage/src/tests/gtest_runner.cpp
+++ b/storage/src/tests/gtest_runner.cpp
@@ -1,14 +1,8 @@
// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <gtest/gtest.h>
+#include <vespa/vespalib/gtest/gtest.h>
#include <vespa/log/log.h>
LOG_SETUP("storage_gtest_runner");
-int
-main(int argc, char* argv[])
-{
- ::testing::InitGoogleTest(&argc, argv);
- return RUN_ALL_TESTS();
-}
-
+GTEST_MAIN_RUN_ALL_TESTS
diff --git a/storageapi/src/tests/gtest_runner.cpp b/storageapi/src/tests/gtest_runner.cpp
index c37be7231ac..d499a54af50 100644
--- a/storageapi/src/tests/gtest_runner.cpp
+++ b/storageapi/src/tests/gtest_runner.cpp
@@ -1,14 +1,8 @@
// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <gtest/gtest.h>
+#include <vespa/vespalib/gtest/gtest.h>
#include <vespa/log/log.h>
LOG_SETUP("storageapi_gtest_runner");
-int
-main(int argc, char* argv[])
-{
- ::testing::InitGoogleTest(&argc, argv);
- return RUN_ALL_TESTS();
-}
-
+GTEST_MAIN_RUN_ALL_TESTS
diff --git a/storageframework/src/tests/gtest_runner.cpp b/storageframework/src/tests/gtest_runner.cpp
index ce0310d7fa1..e9a1c9b1ed8 100644
--- a/storageframework/src/tests/gtest_runner.cpp
+++ b/storageframework/src/tests/gtest_runner.cpp
@@ -1,14 +1,8 @@
// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <gtest/gtest.h>
+#include <vespa/vespalib/gtest/gtest.h>
#include <vespa/log/log.h>
LOG_SETUP("storageframework_gtest_runner");
-int
-main(int argc, char* argv[])
-{
- ::testing::InitGoogleTest(&argc, argv);
- return RUN_ALL_TESTS();
-}
-
+GTEST_MAIN_RUN_ALL_TESTS
diff --git a/vdslib/src/tests/gtest_runner.cpp b/vdslib/src/tests/gtest_runner.cpp
index d10f7182c07..e200813ef61 100644
--- a/vdslib/src/tests/gtest_runner.cpp
+++ b/vdslib/src/tests/gtest_runner.cpp
@@ -1,14 +1,8 @@
// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <gtest/gtest.h>
+#include <vespa/vespalib/gtest/gtest.h>
#include <vespa/log/log.h>
LOG_SETUP("vdslib_gtest_runner");
-int
-main(int argc, char* argv[])
-{
- ::testing::InitGoogleTest(&argc, argv);
- return RUN_ALL_TESTS();
-}
-
+GTEST_MAIN_RUN_ALL_TESTS