rules.bzl 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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. """Rules for building fuzz tests."""
  5. load("@bazel_skylib//rules:native_binary.bzl", "native_test")
  6. def file_test(name, srcs, deps, tests, shard_count = 1):
  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. srcs: cc_test srcs.
  14. deps: cc_test deps.
  15. tests: The list of test files to use as data.
  16. shard_count: The number of shards to use; defaults to 1.
  17. """
  18. subset_name = "{0}.subset".format(name)
  19. native.cc_test(
  20. name = name,
  21. srcs = srcs,
  22. deps = deps,
  23. data = tests,
  24. args = ["$(location {0})".format(x) for x in tests],
  25. shard_count = shard_count,
  26. )
  27. native_test(
  28. name = subset_name,
  29. src = name,
  30. out = subset_name,
  31. data = tests,
  32. tags = ["manual"],
  33. )