blob: c72f74b44cf4101d33d8a58395a9aaef548c51a3 [file] [log] [blame]
# Copyright 2020 The Fuchsia Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/components.gni")
import("//build/test.gni")
stdcompat_cxx_versions = [
17,
20,
23,
]
stdcompat_tests = [
"stdcompat-polyfills",
"stdcompat-polyfills-no-inline-variables",
]
foreach(cxx_version, stdcompat_cxx_versions) {
stdcompat_tests += [ "stdcompat-$cxx_version" ]
}
group("tests") {
testonly = true
# All the Fuchsia tests are collected into a single package.
deps = [ ":stdcompat-tests" ]
# Add each individual test's host build.
foreach(test, stdcompat_tests) {
deps += [ ":$test-unit-test($host_toolchain)" ]
}
}
stdcompat_test_sources = [
"algorithm_test.cc",
"array_test.cc",
"atomic_test.cc",
"bit_test.cc",
"constructors_internal_test.cc",
"cstddef_test.cc",
"functional_test.cc",
"iterator_test.cc",
"memory_test.cc",
"optional_test.cc",
"queue_test.cc",
"source_location_test.cc",
"span_test.cc",
"string_view_test.cc",
"traits_test.cc",
"tuple_test.cc",
"utility_internal_test.cc",
"utility_test.cc",
"variant_test.cc",
"vector_test.cc",
"version_test.cc",
]
group("stdcompat-test-deps") {
testonly = true
visibility = [ ":*" ]
public_deps = [
"//sdk/lib/stdcompat",
"//src/lib/fxl/test:gtest_main",
"//src/sys/test_runners/gtest:death_test",
"//third_party/googletest:gmock",
"//third_party/googletest:gtest",
]
}
# This target will be forced to compile using stdcompat provided polyfills and no inline variables.
test("stdcompat-polyfills-no-inline-variables-unit-test") {
sources = stdcompat_test_sources
deps = [ ":stdcompat-test-deps" ]
configs += [
":stdcompat-select-polyfills",
":stdcompat-no-inline-variables",
":stdcompat-Wundef",
]
}
fuchsia_unittest_component("stdcompat-polyfills-no-inline-variables-test") {
deps = [ ":stdcompat-polyfills-no-inline-variables-unit-test" ]
}
# This target will be forced to compile using stdcompat provided polyfills.
test("stdcompat-polyfills-unit-test") {
sources = stdcompat_test_sources
deps = [ ":stdcompat-test-deps" ]
configs += [
":stdcompat-select-polyfills",
":stdcompat-Wundef",
]
}
fuchsia_unittest_component("stdcompat-polyfills-test") {
deps = [ ":stdcompat-polyfills-unit-test" ]
}
# These targets will let the feature-test macros pick the std implementation if
# available. They test all the available C++ modes, not just the default one
# configured in the build.
foreach(cxx_version, stdcompat_cxx_versions) {
test("stdcompat-$cxx_version-unit-test") {
sources = stdcompat_test_sources
deps = [ ":stdcompat-test-deps" ]
configs += [
":stdcompat-c++-$cxx_version",
":stdcompat-Wundef",
]
}
fuchsia_unittest_component("stdcompat-$cxx_version-test") {
deps = [ ":stdcompat-$cxx_version-unit-test" ]
}
config("stdcompat-c++-$cxx_version") {
visibility = [ ":*" ]
cflags_cc = [ "-std=c++$cxx_version" ]
}
}
fuchsia_test_package("stdcompat-tests") {
test_components = []
foreach(test, stdcompat_tests) {
test_components += [ ":$test-test" ]
}
}
config("stdcompat-Wundef") {
visibility = [ ":*" ]
cflags = [ "-Wundef" ]
}
config("stdcompat-select-polyfills") {
visibility = [ ":*" ]
defines = [ "LIB_STDCOMPAT_USE_POLYFILLS" ]
}
config("stdcompat-no-inline-variables") {
visibility = [ ":*" ]
defines = [ "LIB_STDCOMPAT_NO_INLINE_VARIABLES" ]
}