# Copyright 2021 The Chromium Authors # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. import("//build/config/rust.gni") import("//build/rust/rust_unit_tests_group.gni") # Build some minimal binaries to exercise the Rust toolchain # only if that toolchain is enabled in gn args. group("tests") { testonly = true deps = [ ":deps" ] if (can_build_rust_unit_tests) { deps += [ ":build_rust_tests" ] } } group("deps") { testonly = true deps = [] # All the rest require Rust. if (toolchain_has_rust) { deps += [ "bindgen_test", "test_aliased_deps", "test_aliased_deps:test_aliased_deps_exe", "test_bin_crate", "test_cpp_including_rust", "test_rlib_crate:target1", "test_rlib_crate:target2", "test_rlib_crate:test_rlib_crate_associated_bin", "test_rust_calling_cpp", "test_rust_exe", "test_rust_metadata:test_rust_metadata_cc_exe", "test_rust_metadata:test_rust_metadata_exe", "test_rust_multiple_dep_versions_exe", "test_rust_static_library", "test_serde_json_lenient", "test_simple_rust_exe", # TODO(https://crbug.com/1329611): Enable the additional target below # once `rs_bindings_from_cc` is distributed via `gclient sync`. In the # meantime see the instructions in # `//build/rust/run_rs_bindings_from_cc.py`. #"test_rs_bindings_from_cc:test_rs_bindings_from_cc", ] if (can_build_rust_unit_tests) { deps += [ "bindgen_test:bindgen_test_lib_unittests", "test_aliased_deps:test_aliased_deps_unittests", "test_cpp_including_rust:test_cpp_including_rust_unittests", "test_rlib_crate:target1_test_rlib_crate_v0_2_unittests", "test_rlib_crate:target2_test_rlib_crate_v0_2_unittests", "test_rust_exe:test_rust_exe_unittests", "test_rust_metadata:test_rust_metadata_unittests", "test_rust_multiple_dep_versions_exe/v1:test_lib_v1_unittests", "test_rust_multiple_dep_versions_exe/v2:test_lib_v2_unittests", "test_rust_static_library:test_rust_static_library_unittests", "test_rust_static_library_non_standard_arrangement:foo_tests", "test_rust_unittests", # TODO(https://crbug.com/1329611): Enable the additional target below # once `rs_bindings_from_cc` is distributed via `gclient sync`. In the # meantime see the instructions in # `//build/rust/run_rs_bindings_from_cc.py`. #"test_rs_bindings_from_cc:test_rs_bindings_from_cc_unittests", ] } # Dylibs should only be built in component builds. We turn on flags which # are incompatible with shared library compilation in non-component builds # (such as code coverage https://crbug.com/1457533). if (is_component_build) { deps += [ "test_rust_shared_library" ] if (can_build_rust_unit_tests) { deps += [ "test_cpp_including_rust:test_cpp_including_rust_dylib_unittests", ] # TODO(crbug.com/1442273): The shared library unittest EXE ends up # requiring the DLL to run, even though it does not use the DLL. if (!is_win && !is_mac) { deps += [ "test_rust_shared_library:test_rust_shared_library_unittests" ] } } } if (is_win) { deps += [ "test_control_flow_guard" ] } } } if (can_build_rust_unit_tests) { # Generates a script that will run all the native Rust unit tests, in order # to have them all part of a single test step on infra bots. rust_unit_tests_group("build_rust_tests") { deps = [ ":deps" ] } }