BUILD.gn: Only build tests in Chromium. (#2392)

The prior GoogleTest integration was incomplete and produced errors
when building with 'gn check' enabled. Fix this by scoping the test
integration to Chromium.

Fixes Issue #2382
This commit is contained in:
Jamie Madill 2019-02-19 10:38:38 -05:00 committed by dan sinclair
parent 6d20f62570
commit 4b42cd19d3

187
BUILD.gn
View File

@ -657,132 +657,85 @@ group("SPIRV-Tools") {
]
}
if (!build_with_chromium) {
googletest_dir = spirv_tools_googletest_dir
config("gtest_config") {
include_dirs = [
"${googletest_dir}/googletest",
"${googletest_dir}/googletest/include",
]
}
static_library("gtest") {
testonly = true
# The tests are scoped to Chromium to avoid needing to write gtest integration.
# See Chromium's third_party/googletest/BUILD.gn for a complete integration.
if (build_with_chromium) {
test("spvtools_test") {
sources = [
"${googletest_dir}/googletest/src/gtest-all.cc",
"test/assembly_context_test.cpp",
"test/assembly_format_test.cpp",
"test/binary_destroy_test.cpp",
"test/binary_endianness_test.cpp",
"test/binary_header_get_test.cpp",
"test/binary_parse_test.cpp",
"test/binary_strnlen_s_test.cpp",
"test/binary_to_text.literal_test.cpp",
"test/binary_to_text_test.cpp",
"test/comment_test.cpp",
"test/enum_set_test.cpp",
"test/enum_string_mapping_test.cpp",
"test/ext_inst.debuginfo_test.cpp",
"test/ext_inst.glsl_test.cpp",
"test/ext_inst.opencl_test.cpp",
"test/fix_word_test.cpp",
"test/generator_magic_number_test.cpp",
"test/hex_float_test.cpp",
"test/immediate_int_test.cpp",
"test/libspirv_macros_test.cpp",
"test/name_mapper_test.cpp",
"test/named_id_test.cpp",
"test/opcode_make_test.cpp",
"test/opcode_require_capabilities_test.cpp",
"test/opcode_split_test.cpp",
"test/opcode_table_get_test.cpp",
"test/operand_capabilities_test.cpp",
"test/operand_pattern_test.cpp",
"test/operand_test.cpp",
"test/target_env_test.cpp",
"test/test_fixture.h",
"test/text_advance_test.cpp",
"test/text_destroy_test.cpp",
"test/text_literal_test.cpp",
"test/text_start_new_inst_test.cpp",
"test/text_to_binary.annotation_test.cpp",
"test/text_to_binary.barrier_test.cpp",
"test/text_to_binary.constant_test.cpp",
"test/text_to_binary.control_flow_test.cpp",
"test/text_to_binary.debug_test.cpp",
"test/text_to_binary.device_side_enqueue_test.cpp",
"test/text_to_binary.extension_test.cpp",
"test/text_to_binary.function_test.cpp",
"test/text_to_binary.group_test.cpp",
"test/text_to_binary.image_test.cpp",
"test/text_to_binary.literal_test.cpp",
"test/text_to_binary.memory_test.cpp",
"test/text_to_binary.misc_test.cpp",
"test/text_to_binary.mode_setting_test.cpp",
"test/text_to_binary.pipe_storage_test.cpp",
"test/text_to_binary.reserved_sampling_test.cpp",
"test/text_to_binary.subgroup_dispatch_test.cpp",
"test/text_to_binary.type_declaration_test.cpp",
"test/text_to_binary_test.cpp",
"test/text_word_get_test.cpp",
"test/unit_spirv.cpp",
"test/unit_spirv.h",
]
public_configs = [ ":gtest_config" ]
}
config("gmock_config") {
include_dirs = [
"${googletest_dir}/googlemock",
"${googletest_dir}/googlemock/include",
"${googletest_dir}/googletest/include",
]
if (is_clang) {
# TODO: Can remove this if/when the issue is fixed.
# https://github.com/google/googletest/issues/533
cflags = [ "-Wno-inconsistent-missing-override" ]
}
}
static_library("gmock") {
testonly = true
sources = [
"${googletest_dir}/googlemock/src/gmock-all.cc",
]
public_configs = [ ":gmock_config" ]
}
}
test("spvtools_test") {
sources = [
"test/assembly_context_test.cpp",
"test/assembly_format_test.cpp",
"test/binary_destroy_test.cpp",
"test/binary_endianness_test.cpp",
"test/binary_header_get_test.cpp",
"test/binary_parse_test.cpp",
"test/binary_strnlen_s_test.cpp",
"test/binary_to_text.literal_test.cpp",
"test/binary_to_text_test.cpp",
"test/comment_test.cpp",
"test/enum_set_test.cpp",
"test/enum_string_mapping_test.cpp",
"test/ext_inst.debuginfo_test.cpp",
"test/ext_inst.glsl_test.cpp",
"test/ext_inst.opencl_test.cpp",
"test/fix_word_test.cpp",
"test/generator_magic_number_test.cpp",
"test/hex_float_test.cpp",
"test/immediate_int_test.cpp",
"test/libspirv_macros_test.cpp",
"test/name_mapper_test.cpp",
"test/named_id_test.cpp",
"test/opcode_make_test.cpp",
"test/opcode_require_capabilities_test.cpp",
"test/opcode_split_test.cpp",
"test/opcode_table_get_test.cpp",
"test/operand_capabilities_test.cpp",
"test/operand_pattern_test.cpp",
"test/operand_test.cpp",
"test/target_env_test.cpp",
"test/test_fixture.h",
"test/text_advance_test.cpp",
"test/text_destroy_test.cpp",
"test/text_literal_test.cpp",
"test/text_start_new_inst_test.cpp",
"test/text_to_binary.annotation_test.cpp",
"test/text_to_binary.barrier_test.cpp",
"test/text_to_binary.constant_test.cpp",
"test/text_to_binary.control_flow_test.cpp",
"test/text_to_binary.debug_test.cpp",
"test/text_to_binary.device_side_enqueue_test.cpp",
"test/text_to_binary.extension_test.cpp",
"test/text_to_binary.function_test.cpp",
"test/text_to_binary.group_test.cpp",
"test/text_to_binary.image_test.cpp",
"test/text_to_binary.literal_test.cpp",
"test/text_to_binary.memory_test.cpp",
"test/text_to_binary.misc_test.cpp",
"test/text_to_binary.mode_setting_test.cpp",
"test/text_to_binary.pipe_storage_test.cpp",
"test/text_to_binary.reserved_sampling_test.cpp",
"test/text_to_binary.subgroup_dispatch_test.cpp",
"test/text_to_binary.type_declaration_test.cpp",
"test/text_to_binary_test.cpp",
"test/text_word_get_test.cpp",
"test/unit_spirv.cpp",
"test/unit_spirv.h",
]
deps = [
":spvtools",
":spvtools_language_header_unified1",
":spvtools_val",
]
if (build_with_chromium) {
deps += [
deps = [
"//testing/gmock",
"//testing/gtest",
"//testing/gtest:gtest_main",
":spvtools",
":spvtools_language_header_unified1",
":spvtools_val",
]
} else {
deps += [
":gmock",
":gtest",
]
sources += [ "${googletest_dir}/googletest/src/gtest_main.cc" ]
}
if (is_clang) {
cflags_cc = [ "-Wno-self-assign" ]
}
if (is_clang) {
cflags_cc = [ "-Wno-self-assign" ]
}
configs += [ ":spvtools_internal_config" ]
configs += [ ":spvtools_internal_config" ]
}
}
if (spirv_tools_standalone) {