| # Copyright 2018 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/host.gni") |
| import("//build/rust/rustc_binary.gni") |
| import("//build/rust/rustc_library.gni") |
| import("//build/rust/rustc_test.gni") |
| import("//build/test.gni") |
| |
| group("triage") { |
| testonly = true |
| deps = [ |
| ":tests", |
| ":triage_bin", |
| ] |
| } |
| |
| # Note: This does not pick up all triage tests - there are tests in |
| # //src/diagnostics/lib/triage and //src/diagnostics/config/triage. |
| # Use --with //src/diagnostics:tests, not --with //src/diagnostics/triage:tests. |
| group("tests") { |
| testonly = true |
| |
| deps = [ |
| ":triage_lib_test($host_toolchain)", |
| "build/triage_config_test_runner:tests", |
| "test_data", |
| ] |
| } |
| |
| # Needed for testing on host |
| copy("copy_configs") { |
| testonly = true |
| |
| # Any data that is needed for a test should be included in this list. |
| sources = [ |
| "test_data/config/annotation_tests.triage", |
| "test_data/config/error_rate.triage", |
| "test_data/config/log_tests.triage", |
| "test_data/config/map_fold.triage", |
| "test_data/config/other.triage", |
| "test_data/config/sample.triage", |
| "test_data/config/sample_bundle.json", |
| "test_data/config/sample_bundle_file_type_error.json", |
| "test_data/config/sample_bundle_files_error.json", |
| "test_data/config/sample_tags.triage", |
| ] |
| |
| # If this path changes then the integration.rs file needs to be udpated |
| # to look in the correct place. |
| outputs = [ "$root_out_dir/test_data/triage/config/{{source_file_part}}" ] |
| } |
| |
| # Needed for testing on host |
| copy("copy_snapshot") { |
| testonly = true |
| |
| sources = [ |
| "test_data/snapshot/annotations.json", |
| "test_data/snapshot/inspect.json", |
| ] |
| |
| # If this path changes then the integration.rs file needs to be udpated |
| # to look in the correct place. |
| outputs = [ "$root_out_dir/test_data/triage/snapshot/{{source_file_part}}" ] |
| } |
| |
| # Needed to generate the runtime deps file which is used in CQ for sandboxing |
| group("test_data") { |
| testonly = true |
| |
| deps = [ |
| ":copy_configs", |
| ":copy_snapshot", |
| ] |
| |
| # Need to indicate our dependencies for host side integration testing |
| runtime_deps = |
| get_target_outputs(":copy_snapshot") + |
| get_target_outputs(":copy_configs") + [ "${root_out_dir}/triage" ] |
| |
| metadata = { |
| test_runtime_deps = runtime_deps |
| } |
| } |
| |
| lib_deps = [ |
| "//src/diagnostics/lib/triage", |
| "//third_party/rust_crates:anyhow", |
| "//third_party/rust_crates:log", |
| "//third_party/rust_crates:serde", |
| "//third_party/rust_crates:serde_derive", |
| "//third_party/rust_crates:serde_json", |
| "//third_party/rust_crates:structopt", |
| ] |
| |
| rustc_library("triage_app_lib") { |
| edition = "2021" |
| |
| deps = lib_deps |
| |
| sources = [ |
| "src/app.rs", |
| "src/config.rs", |
| "src/file_io.rs", |
| "src/lib.rs", |
| ] |
| } |
| |
| rustc_test("triage_lib_test") { |
| edition = "2021" |
| |
| deps = lib_deps + [ |
| ":test_data", |
| ":triage_app_lib", |
| "//src/lib/fuchsia", |
| ] |
| |
| # we need to take a dependency on our bin because our integration tests invoke it |
| data_deps = [ ":triage_bin" ] |
| |
| sources = [ |
| "src/app.rs", |
| "src/config.rs", |
| "src/file_io.rs", |
| "src/lib.rs", |
| "src/test.rs", |
| "src/test/integration.rs", |
| ] |
| } |
| |
| rustc_binary("triage_bin") { |
| name = "triage" |
| edition = "2021" |
| |
| deps = lib_deps + [ ":triage_app_lib" ] |
| |
| sources = [ "src/main.rs" ] |
| |
| if (!is_fuchsia) { |
| exclude_toolchain_tags = [ |
| # Triage host tool performs poorly when built with asan or profile. |
| "asan", |
| "profile", |
| ] |
| } |
| } |
| |
| install_host_tools("install") { |
| deps = [ ":triage_bin" ] |
| |
| outputs = [ "triage" ] |
| } |