1# Copyright 2024 The Chromium Authors 2# Use of this source code is governed by a BSD-style license that can be found 3# in the LICENSE file. 4 5# The crosier_tests template is used to define crosier test targets in 6# subdirectories. They should be in the dependency chain of the top-level 7# chromeos_integration_tests target. 8# 9# crosier_tests behaves like source_set except that it supports (and expects) a 10# "sources_metadata" variable that lists the yaml metadata files corresponding 11# to the test sources. These files will be copied to the appropriate directory. 12# See docs/testing/chromeos_integration/crosier_metadata.md for details. 13 14import("//build/config/chromeos/ui_mode.gni") 15 16template("crosier_tests") { 17 assert(is_chromeos_device) 18 assert(defined(invoker.sources), 19 "Need sources in $target_name listing the C++ files.") 20 assert(defined(invoker.sources_metadata), 21 "Need sources_metadata in $target_name listing the yaml files.") 22 23 _have_metadata = invoker.sources_metadata != [] 24 25 source_set(target_name) { 26 forward_variables_from(invoker, "*", [ "sources_metadata" ]) 27 testonly = true 28 if (defined(defines)) { 29 defines += [ "HAS_OUT_OF_PROC_TEST_RUNNER" ] 30 } else { 31 defines = [ "HAS_OUT_OF_PROC_TEST_RUNNER" ] 32 } 33 if (_have_metadata) { 34 if (defined(data_deps)) { 35 data_deps += [ ":${target_name}_metadata" ] 36 } else { 37 data_deps = [ ":${target_name}_metadata" ] 38 } 39 } 40 } 41 42 if (_have_metadata) { 43 copy("${target_name}_metadata") { 44 testonly = true 45 sources = invoker.sources_metadata 46 outputs = [ "$root_out_dir/crosier_metadata/{{source_file_part}}" ] 47 } 48 } 49} 50