2022-09-16 18:51:48 +00:00
|
|
|
load("@aspect_bazel_lib_host//:defs.bzl", "host")
|
2021-11-08 14:20:26 +00:00
|
|
|
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
|
|
|
|
load("@bazel_gazelle//:def.bzl", "gazelle", "gazelle_binary")
|
2022-04-01 17:49:16 +00:00
|
|
|
load("//lib:write_source_files.bzl", "write_source_files")
|
2022-05-02 22:41:06 +00:00
|
|
|
load("//lib:yq.bzl", "yq")
|
2022-07-06 10:46:51 +00:00
|
|
|
load("//lib:diff_test.bzl", "diff_test")
|
2022-09-16 18:51:48 +00:00
|
|
|
load("//lib:testing.bzl", "assert_contains")
|
2022-07-06 10:46:51 +00:00
|
|
|
load("@bazel_skylib//rules:write_file.bzl", "write_file")
|
|
|
|
load("@bazel_skylib//rules:copy_file.bzl", "copy_file")
|
2021-11-08 14:20:26 +00:00
|
|
|
|
|
|
|
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",
|
|
|
|
],
|
|
|
|
)
|
2022-03-31 00:04:35 +00:00
|
|
|
|
|
|
|
# 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"],
|
|
|
|
)
|
2022-04-01 17:49:16 +00:00
|
|
|
|
2022-03-31 00:04:35 +00:00
|
|
|
write_source_files(
|
|
|
|
name = "write_source_file_root-test",
|
|
|
|
diff_test = False,
|
2022-08-16 18:00:33 +00:00
|
|
|
files = {
|
|
|
|
"test-out/dist/write_source_file_root-test": ":write_source_file_root",
|
|
|
|
"test-out/dist/write_source_file_root-test_b": ":write_source_file_root",
|
|
|
|
},
|
2022-03-31 00:04:35 +00:00
|
|
|
)
|
2022-05-02 22:41:06 +00:00
|
|
|
|
|
|
|
# Test that yq works in the root package
|
|
|
|
yq(
|
|
|
|
name = "yq_root-test",
|
|
|
|
srcs = ["//lib/tests/yq:a.yaml"],
|
|
|
|
expression = ".",
|
|
|
|
)
|
2022-07-06 10:46:51 +00:00
|
|
|
|
|
|
|
# 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",
|
|
|
|
)
|
2022-09-16 18:51:48 +00:00
|
|
|
|
|
|
|
assert_contains(
|
|
|
|
name = "bazel_version_test",
|
|
|
|
actual = ".bazelversion",
|
|
|
|
expected = str(host.bazel_version),
|
|
|
|
)
|