golden_test.bzl 804 B

12345678910111213141516171819202122232425
  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. """Rule for a golden test."""
  5. def golden_test(name, golden, subject, **kwargs):
  6. """Compares two files. Passes if they are identical.
  7. Args:
  8. name: Name of the build rule.
  9. subject: The generated file to be compared.
  10. golden: The golden file to be compared.
  11. **kwargs: Any additional parameters for the generated sh_test.
  12. """
  13. native.sh_test(
  14. name = name,
  15. srcs = ["//bazel/testing:golden_test.sh"],
  16. args = [
  17. "$(location %s)" % golden,
  18. "$(location %s)" % subject,
  19. ],
  20. data = [golden, subject],
  21. **kwargs
  22. )