blob: 55b2f8fe7a6483ac08edeaa1e31b7bb878b90bb3 [file] [log] [blame]
# 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.
# Defines a target which runs one or more Python tests at build time.
#
# This should only be used to run small tests that verify the correctness
# of Python scripts that are invoked *during* the build, and which use
# explicit sys.path.insert() calls to import modules from other locations
# in the Fuchsia source tree.
#
# Contrary to python_host_test(), this template does not generate a .pyz
# file, nor adds an entry in tests.json. Type checking is also disabled.
# Failing as soon as possible at build time is intentional.
#
# These tests can be run in parallel by Ninja, but should not last
# very long to avoid impacting overall build time.
#
# Arguments:
# tests: List of Python test scripts to run.
#
# inputs: Additional inputs used by the test scripts. All imported
# modules and other runtime dependencies should appear here.
# There is no support for depfiles or hermetic_input_files.
#
# deps, data_deps: Usual GN meaning
#
template("python_build_time_tests") {
if (current_toolchain == default_toolchain) {
action(target_name) {
testonly = true
script = "//build/testing/python_build_time_tests.py"
inputs = invoker.tests + invoker.inputs
outputs = [ "$target_out_dir/$target_name.check" ]
args = [
"--quiet",
"--stamp",
rebase_path(outputs[0], root_build_dir),
"--test-files",
] + rebase_path(invoker.tests, root_build_dir)
forward_variables_from(invoker,
[
"deps",
"data_deps",
])
}
} else {
group(target_name) {
testonly = true
public_deps = [ ":$target_name($default_toolchain)" ]
}
not_needed(invoker,
[
"deps",
"data_deps",
"inputs",
"tests",
])
}
}