| # Copyright 2024 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/python/python_binary.gni") |
| import("//build/python/python_host_test.gni") |
| import("//build/python/python_library.gni") |
| import("//build/testing/python_build_time_tests.gni") |
| |
| group("tests") { |
| testonly = true |
| deps = [ |
| ":generate_prebuild_idk_integration_test($host_toolchain)", |
| ":idk_generator_unittest($host_toolchain)", |
| ] |
| } |
| |
| if (is_host) { |
| python_binary("generate_prebuild_idk") { |
| visibility = [ |
| "//build/sdk/tests:*", |
| "//sdk/*", |
| "//vendor/*", |
| ] |
| |
| # This template behaves badly when the main source filename is the same as |
| # the library, so use a different name instead. |
| main_source = "idk_generator.py" |
| deps = [ ":idk_generator_lib" ] |
| } |
| |
| python_library("idk_generator_lib") { |
| visibility = [ ":*" ] |
| library_name = "idk_generator" |
| sources = [ |
| "__init__.py", |
| "generate_sdk_package_manifest.py", |
| "idk_generator.py", |
| ] |
| |
| deps = [ |
| "//build/cpp", |
| "//build/sdk/generate_version_history", |
| "//build/sdk/sdk_common", |
| "//third_party/pyyaml:yaml", |
| ] |
| } |
| |
| # All tests here should be run at build time, as they are critical |
| # to ensuring the build works correctly. |
| action("generate_prebuild_idk_integration_test") { |
| testonly = true |
| script = |
| "//build/sdk/generate_prebuild_idk/generate_prebuild_idk_validation.py" |
| inputs = [ |
| "idk_generator.py", |
| |
| # Accessed by idk_generator.py. |
| "//build/sdk/generate_version_history/__init__.py", |
| "//docs/contribute/governance/areas/_areas.yaml", |
| "//third_party/pyyaml/src/lib/yaml/__init__.py", |
| "//third_party/pyyaml/src/lib/yaml/composer.py", |
| "//third_party/pyyaml/src/lib/yaml/constructor.py", |
| "//third_party/pyyaml/src/lib/yaml/cyaml.py", |
| "//third_party/pyyaml/src/lib/yaml/dumper.py", |
| "//third_party/pyyaml/src/lib/yaml/emitter.py", |
| "//third_party/pyyaml/src/lib/yaml/error.py", |
| "//third_party/pyyaml/src/lib/yaml/events.py", |
| "//third_party/pyyaml/src/lib/yaml/loader.py", |
| "//third_party/pyyaml/src/lib/yaml/nodes.py", |
| "//third_party/pyyaml/src/lib/yaml/parser.py", |
| "//third_party/pyyaml/src/lib/yaml/reader.py", |
| "//third_party/pyyaml/src/lib/yaml/representer.py", |
| "//third_party/pyyaml/src/lib/yaml/resolver.py", |
| "//third_party/pyyaml/src/lib/yaml/scanner.py", |
| "//third_party/pyyaml/src/lib/yaml/serializer.py", |
| "//third_party/pyyaml/src/lib/yaml/tokens.py", |
| ] |
| outputs = [ "$target_out_dir/$target_name.check" ] |
| args = [ |
| "--quiet", |
| "--stamp", |
| rebase_path(outputs[0], root_build_dir), |
| ] |
| |
| hermetic_inputs_file = "$target_out_dir/$target_name.hermetic_inputs" |
| } |
| |
| host_test_data("areas_file_test_data") { |
| visibility = [ ":*" ] |
| sources = [ "//docs/contribute/governance/areas/_areas.yaml" ] |
| } |
| |
| python_host_test("idk_generator_unittest") { |
| main_source = "idk_generator_unittest.py" |
| libraries = [ ":idk_generator_lib" ] |
| |
| # LINT.IfChange(gn_test_main) |
| main_callable = "gn_test_main" |
| source_root_relative_to_target_gen_dir = rebase_path("//", target_gen_dir) |
| extra_args = [ source_root_relative_to_target_gen_dir ] |
| |
| # LINT.ThenChange(idk_generator_unittest.py:gn_test_main) |
| |
| test_data_deps = [ ":areas_file_test_data" ] |
| } |
| } |