Commit 7876269f authored by Mirko Bonadei's avatar Mirko Bonadei Committed by Commit Bot

Enabling Abseil types pretty-printing in gtest.

If Abseil is not built with Chromium, this CL defines GTEST_HAS_ABSL=1
which enables pretty printers for Abseil types.

At the moment only absl:optional and absl::string_view are supported.

If a new printer will be added to gtest/gtest-printers.h, the deps list
in third_party/googletest/BUILD.gn will have to be updated.

Bug: None
Change-Id: Ib3cf0eacc286367be2cba0d7b0d3dd9598147bc7
Reviewed-on: https://chromium-review.googlesource.com/1027711Reviewed-by: default avatarNico Weber <thakis@chromium.org>
Commit-Queue: Mirko Bonadei <mbonadei@chromium.org>
Cr-Commit-Position: refs/heads/master@{#569993}
parent 026a3e67
...@@ -8,6 +8,7 @@ if (build_with_chromium) { ...@@ -8,6 +8,7 @@ if (build_with_chromium) {
visibility = [ visibility = [
"//third_party/webrtc/*", "//third_party/webrtc/*",
"//third_party/abseil-cpp/*", "//third_party/abseil-cpp/*",
"//third_party/googletest:gtest",
] ]
} else { } else {
visibility = [ "*" ] visibility = [ "*" ]
......
...@@ -8,6 +8,7 @@ if (build_with_chromium) { ...@@ -8,6 +8,7 @@ if (build_with_chromium) {
visibility = [ visibility = [
"//third_party/webrtc/*", "//third_party/webrtc/*",
"//third_party/abseil-cpp/*", "//third_party/abseil-cpp/*",
"//third_party/googletest:gtest",
] ]
} else { } else {
visibility = [ "*" ] visibility = [ "*" ]
......
...@@ -8,6 +8,7 @@ if (build_with_chromium) { ...@@ -8,6 +8,7 @@ if (build_with_chromium) {
visibility = [ visibility = [
"//third_party/webrtc/*", "//third_party/webrtc/*",
"//third_party/abseil-cpp/*", "//third_party/abseil-cpp/*",
"//third_party/googletest:gtest",
] ]
} else { } else {
visibility = [ "*" ] visibility = [ "*" ]
......
...@@ -9,6 +9,7 @@ if (build_with_chromium) { ...@@ -9,6 +9,7 @@ if (build_with_chromium) {
visibility = [ visibility = [
"//third_party/webrtc/*", "//third_party/webrtc/*",
"//third_party/abseil-cpp/*", "//third_party/abseil-cpp/*",
"//third_party/googletest:gtest",
] ]
} else { } else {
visibility = [ "*" ] visibility = [ "*" ]
......
...@@ -8,6 +8,7 @@ if (build_with_chromium) { ...@@ -8,6 +8,7 @@ if (build_with_chromium) {
visibility = [ visibility = [
"//third_party/webrtc/*", "//third_party/webrtc/*",
"//third_party/abseil-cpp/*", "//third_party/abseil-cpp/*",
"//third_party/googletest:gtest",
] ]
} else { } else {
visibility = [ "*" ] visibility = [ "*" ]
......
...@@ -8,6 +8,7 @@ if (build_with_chromium) { ...@@ -8,6 +8,7 @@ if (build_with_chromium) {
visibility = [ visibility = [
"//third_party/webrtc/*", "//third_party/webrtc/*",
"//third_party/abseil-cpp/*", "//third_party/abseil-cpp/*",
"//third_party/googletest:gtest",
] ]
} else { } else {
visibility = [ "*" ] visibility = [ "*" ]
......
...@@ -8,6 +8,7 @@ if (build_with_chromium) { ...@@ -8,6 +8,7 @@ if (build_with_chromium) {
visibility = [ visibility = [
"//third_party/webrtc/*", "//third_party/webrtc/*",
"//third_party/abseil-cpp/*", "//third_party/abseil-cpp/*",
"//third_party/googletest:gtest",
] ]
} else { } else {
visibility = [ "*" ] visibility = [ "*" ]
......
...@@ -8,6 +8,7 @@ if (build_with_chromium) { ...@@ -8,6 +8,7 @@ if (build_with_chromium) {
visibility = [ visibility = [
"//third_party/webrtc/*", "//third_party/webrtc/*",
"//third_party/abseil-cpp/*", "//third_party/abseil-cpp/*",
"//third_party/googletest:gtest",
] ]
} else { } else {
visibility = [ "*" ] visibility = [ "*" ]
......
...@@ -8,6 +8,7 @@ if (build_with_chromium) { ...@@ -8,6 +8,7 @@ if (build_with_chromium) {
visibility = [ visibility = [
"//third_party/webrtc/*", "//third_party/webrtc/*",
"//third_party/abseil-cpp/*", "//third_party/abseil-cpp/*",
"//third_party/googletest:gtest",
] ]
} else { } else {
visibility = [ "*" ] visibility = [ "*" ]
......
...@@ -8,6 +8,7 @@ if (build_with_chromium) { ...@@ -8,6 +8,7 @@ if (build_with_chromium) {
visibility = [ visibility = [
"//third_party/webrtc/*", "//third_party/webrtc/*",
"//third_party/abseil-cpp/*", "//third_party/abseil-cpp/*",
"//third_party/googletest:gtest",
] ]
} else { } else {
visibility = [ "*" ] visibility = [ "*" ]
......
...@@ -8,6 +8,7 @@ if (build_with_chromium) { ...@@ -8,6 +8,7 @@ if (build_with_chromium) {
visibility = [ visibility = [
"//third_party/webrtc/*", "//third_party/webrtc/*",
"//third_party/abseil-cpp/*", "//third_party/abseil-cpp/*",
"//third_party/googletest:gtest",
] ]
} else { } else {
visibility = [ "*" ] visibility = [ "*" ]
......
...@@ -8,6 +8,7 @@ if (build_with_chromium) { ...@@ -8,6 +8,7 @@ if (build_with_chromium) {
visibility = [ visibility = [
"//third_party/webrtc/*", "//third_party/webrtc/*",
"//third_party/abseil-cpp/*", "//third_party/abseil-cpp/*",
"//third_party/googletest:gtest",
] ]
} else { } else {
visibility = [ "*" ] visibility = [ "*" ]
......
...@@ -8,6 +8,7 @@ if (build_with_chromium) { ...@@ -8,6 +8,7 @@ if (build_with_chromium) {
visibility = [ visibility = [
"//third_party/webrtc/*", "//third_party/webrtc/*",
"//third_party/abseil-cpp/*", "//third_party/abseil-cpp/*",
"//third_party/googletest:gtest",
] ]
} else { } else {
visibility = [ "*" ] visibility = [ "*" ]
......
...@@ -4,6 +4,11 @@ ...@@ -4,6 +4,11 @@
import("//build_overrides/build.gni") import("//build_overrides/build.gni")
declare_args() {
# If true, it assumes that //third_party/abseil-cpp is an available dependency.
gtest_enable_absl_printers = false
}
config("gtest_config") { config("gtest_config") {
visibility = [ ":*" ] # gmock also shares this config. visibility = [ ":*" ] # gmock also shares this config.
...@@ -33,6 +38,10 @@ config("gtest_config") { ...@@ -33,6 +38,10 @@ config("gtest_config") {
if (is_win) { if (is_win) {
cflags = [ "/wd4800" ] # Unused variable warning. cflags = [ "/wd4800" ] # Unused variable warning.
} }
if (!build_with_chromium && gtest_enable_absl_printers) {
defines += [ "GTEST_HAS_ABSL=1" ]
}
} }
config("gmock_config") { config("gmock_config") {
...@@ -98,12 +107,19 @@ source_set("gtest") { ...@@ -98,12 +107,19 @@ source_set("gtest") {
defines = [] defines = []
deps = [] deps = []
public_deps = []
if (is_nacl || !build_with_chromium) { if (is_nacl || !build_with_chromium) {
defines += [ "GTEST_DISABLE_PRINT_STACK_TRACE" ] defines += [ "GTEST_DISABLE_PRINT_STACK_TRACE" ]
sources -= [ sources -= [
"custom/gtest/internal/custom/stack_trace_getter.cc", "custom/gtest/internal/custom/stack_trace_getter.cc",
"custom/gtest/internal/custom/stack_trace_getter.h", "custom/gtest/internal/custom/stack_trace_getter.h",
] ]
if (gtest_enable_absl_printers) {
public_deps += [
"//third_party/abseil-cpp/absl/strings",
"//third_party/abseil-cpp/absl/types:optional",
]
}
} else { } else {
deps += [ "//base" ] deps += [ "//base" ]
} }
...@@ -156,9 +172,10 @@ source_set("gmock") { ...@@ -156,9 +172,10 @@ source_set("gmock") {
"src/googlemock/src/gmock.cc", "src/googlemock/src/gmock.cc",
] ]
public_deps = [ ":gtest" ]
public_configs = [ public_configs = [
":gmock_config", ":gmock_config",
":gtest_config",
] ]
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment