| # 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/testing/host_test.gni") |
| import("//build/testing/host_test_data.gni") |
| |
| # Defines a host-side test for a triage configuration |
| # |
| # Packages a set of triage configuration files into a single test which |
| # runs all of the tests in the `test` section of the configuration file. |
| # This test will pass if all of the tests pass and fail if any of them fail. |
| # |
| # Parameters |
| # |
| # sources (required) |
| # The list of configuration files. These sources must be within source_dir. |
| # |
| # source_dir (optional) |
| # Directory containing the test sources. |
| # Defaults to "config". |
| # |
| # Example of usage: |
| # |
| # triage_config_test("some_test") { |
| # sources = [ |
| # "bar.triage", |
| # "foo.triage", |
| # ] |
| # } |
| # |
| # Example of running: |
| # |
| # fx test some_test |
| # |
| template("triage_config_test") { |
| assert(defined(invoker.sources), |
| "triage_config_test() requires 'sources' be defined") |
| |
| if (defined(invoker.source_dir)) { |
| config_source_dir = invoker.source_dir |
| } else { |
| config_source_dir = "config" |
| } |
| |
| config_target_name = target_name + "_configs" |
| host_test_data(config_target_name) { |
| sources = [] |
| foreach(config, invoker.sources) { |
| sources += [ "${config_source_dir}/${config}" ] |
| } |
| outputs = |
| [ "$target_gen_dir/runtime_deps/${target_name}/{{source_file_part}}" ] |
| } |
| |
| host_test(target_name) { |
| binary_path = "${root_out_dir}/triage_config_test_runner" |
| |
| config_files = get_target_outputs(":${config_target_name}") |
| args = [] |
| foreach(file, config_files) { |
| args += [ |
| "--config", |
| rebase_path(file, root_build_dir), |
| ] |
| } |
| deps = [ |
| ":${config_target_name}", |
| "//src/diagnostics/triage/build/triage_config_test_runner", |
| ] |
| } |
| } |