2
0
Fork 0
mirror of https://github.com/bazel-contrib/bazel-lib synced 2024-11-25 11:32:33 +00:00
bazel-lib/BUILD.bazel
Jesse Schalken f2e5f4675f fix: diff_test not working for files in directories starting with "external"
Example "external-dependencies/foo.txt"
2022-07-07 16:31:00 -07:00

69 lines
1.8 KiB
Python

load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("@bazel_gazelle//:def.bzl", "gazelle", "gazelle_binary")
load("//lib:write_source_files.bzl", "write_source_files")
load("//lib:yq.bzl", "yq")
load("//lib:diff_test.bzl", "diff_test")
load("@bazel_skylib//rules:write_file.bzl", "write_file")
load("@bazel_skylib//rules:copy_file.bzl", "copy_file")
gazelle_binary(
name = "gazelle_bin",
languages = ["@bazel_skylib//gazelle/bzl"],
)
gazelle(
name = "gazelle",
gazelle = "gazelle_bin",
)
bzl_library(
name = "internal_deps",
srcs = ["internal_deps.bzl"],
visibility = ["//visibility:public"],
deps = [
"@bazel_tools//tools/build_defs/repo:http.bzl",
"@bazel_tools//tools/build_defs/repo:utils.bzl",
],
)
# write_source_files() to a git ignored subdirectory of the root
genrule(
name = "write_source_file_root",
outs = ["write_source_file-root_directory"],
cmd = "mkdir -p $@ && echo 'test' > $@/test.txt",
visibility = ["//visibility:private"],
)
write_source_files(
name = "write_source_file_root-test",
diff_test = False,
files = {"test-out/dist/write_source_file_root-test": ":write_source_file_root"},
)
# Test that yq works in the root package
yq(
name = "yq_root-test",
srcs = ["//lib/tests/yq:a.yaml"],
expression = ".",
)
# Test case: diff_test with a file in a directory prefixed with "external"
# stamped in the root package
write_file(
name = "file_in_external_prefixed_dir",
out = "external-dir/foo.txt",
content = ["foo"],
)
copy_file(
name = "copy_of_file_in_external_prefixed_dir",
src = "external-dir/foo.txt",
out = "foo_copy.txt",
)
diff_test(
name = "case_file_has_external_prefix",
file1 = "external-dir/foo.txt",
file2 = "foo_copy.txt",
)