Files
carbon-lang/bazel/testing/lit_test.bzl
T
Jon Meow 9009ae5e1b Cleanup up lit_test and require explicit tool paths (#1049)
I think lit_test accrued a bit of cruft as I switched approaches... I still may go further, but this is particularly fixing a bug where `FileCheck` (instead of `%{FileCheck}`) should've failed in tests.
2022-01-27 16:27:30 -08:00

37 lines
1.2 KiB
Python

# Part of the Carbon Language project, under the Apache License v2.0 with LLVM
# Exceptions. See /LICENSE for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
"""Rule for a lit test."""
def lit_test(name, test_dir, data = None, **kwargs):
"""Runs `lit` on test_dir.
`lit` reference:
https://llvm.org/docs/CommandGuide/lit.html
To pass flags to `lit`, use `--test_arg`. For example:
bazel test :lit_test --test_arg=-v
bazel test :lit_test --test_arg=--filter=REGEXP
Args:
name: Name of the build rule.
test_dir: The directory with the lit tests.
data: An optional list of tools to provide to the tests. These will be
aliased for execution.
**kwargs: Any additional parameters for the generated py_test.
"""
if not data:
data = []
data += [
"@llvm-project//llvm:lit",
]
native.py_test(
name = name,
srcs = ["//bazel/testing:lit_test.py"],
main = "//bazel/testing:lit_test.py",
data = data + native.glob([test_dir + "/**"]),
args = ["--package_name=%s" % native.package_name(), "--test_dir=%s" % test_dir, "--"],
**kwargs
)