rules.bzl 1.0 KB

12345678910111213141516171819202122232425262728293031
  1. # Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. # Exceptions. See /LICENSE for license information.
  3. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. load("@rules_cc//cc:defs.bzl", "cc_test")
  5. """Rules for building fuzz tests."""
  6. def file_test(name, tests, data = [], args = [], **kwargs):
  7. """Generates tests using the file_test base.
  8. There will be one main test using `name` that can be sharded, and includes
  9. all files. Additionally, per-file tests will be generated as
  10. `name.file_path`; these per-file tests will be manual.
  11. Args:
  12. name: The base name of the tests.
  13. tests: The list of test files to use as data, typically a glob.
  14. data: Passed to cc_test.
  15. args: Passed to cc_test.
  16. **kwargs: Passed to cc_test.
  17. """
  18. cc_test(
  19. name = name,
  20. data = tests + data,
  21. args = ["--file_tests=" + ",".join([
  22. "$(location {0})".format(x)
  23. for x in tests
  24. ])] + args,
  25. **kwargs
  26. )