2022-04-28 00:22:30 +00:00
|
|
|
"""Integration testing that aspect_bazel_lib works when used via bzlmod.
|
|
|
|
|
|
|
|
NB: We don't use yq, so we can confirm that Bazel never fetches it.
|
|
|
|
You can manually verify this after testing this repo with
|
|
|
|
`ls $(bazel info output_base)/external | grep yq`
|
|
|
|
You'll see a aspect_bazel_lib.ext.yq_toolchains repo, but no downloaded yq binary.
|
|
|
|
"""
|
|
|
|
|
2023-01-17 03:37:36 +00:00
|
|
|
load("@aspect_bazel_lib//lib:copy_directory.bzl", "copy_directory")
|
|
|
|
load("@aspect_bazel_lib//lib:copy_to_directory.bzl", "copy_to_directory")
|
2022-04-29 07:36:41 +00:00
|
|
|
load("@aspect_bazel_lib//lib:diff_test.bzl", "diff_test")
|
2023-01-17 03:37:36 +00:00
|
|
|
load("@aspect_bazel_lib//lib:jq.bzl", "jq")
|
|
|
|
load("@aspect_bazel_lib//lib:yq.bzl", "yq")
|
2022-04-28 00:22:30 +00:00
|
|
|
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
|
2023-02-19 04:09:27 +00:00
|
|
|
load("@aspect_bazel_lib_host//:defs.bzl", "host")
|
2022-04-27 04:07:17 +00:00
|
|
|
|
2022-04-28 00:22:30 +00:00
|
|
|
bzl_library(
|
|
|
|
name = "defs",
|
|
|
|
srcs = ["defs.bzl"],
|
|
|
|
)
|
|
|
|
|
|
|
|
# Validate that stardoc dependency works.
|
|
|
|
# Note, stardoc is generally broken under bzlmod, see
|
|
|
|
# https://github.com/bazelbuild/stardoc/issues/117
|
|
|
|
# This happens to work because we don't reference any external repos
|
|
|
|
# from defs.bzl.
|
2022-10-26 22:05:27 +00:00
|
|
|
# TODO: re-enable this once it works
|
|
|
|
# load("@aspect_bazel_lib//lib:docs.bzl", "stardoc_with_diff_test")
|
|
|
|
# stardoc_with_diff_test(
|
|
|
|
# name = "docs",
|
|
|
|
# bzl_library_target = "//:defs",
|
|
|
|
# )
|
2022-04-28 00:22:30 +00:00
|
|
|
|
|
|
|
# Validate that JQ works and resolves its toolchain
|
2022-04-27 04:07:17 +00:00
|
|
|
jq(
|
2023-01-17 03:37:36 +00:00
|
|
|
name = "jq_case_no_sources",
|
2022-04-27 04:07:17 +00:00
|
|
|
srcs = [],
|
|
|
|
filter = ".",
|
|
|
|
)
|
|
|
|
|
|
|
|
diff_test(
|
2023-01-17 03:37:36 +00:00
|
|
|
name = "jq_test",
|
|
|
|
file1 = "jq_case_no_sources",
|
|
|
|
file2 = "expected_jq",
|
|
|
|
)
|
|
|
|
|
|
|
|
# Validate that YQ works and resolves its toolchain
|
|
|
|
yq(
|
|
|
|
name = "yq_case_no_sources",
|
|
|
|
srcs = [],
|
|
|
|
expression = ".",
|
|
|
|
)
|
|
|
|
|
|
|
|
diff_test(
|
|
|
|
name = "yq_test",
|
|
|
|
file1 = "yq_case_no_sources",
|
|
|
|
file2 = "expected_yq",
|
|
|
|
)
|
|
|
|
|
|
|
|
# Validate that copy_directory works and resolves its toolchain
|
|
|
|
copy_directory(
|
|
|
|
name = "copy_directory_case",
|
|
|
|
src = "d",
|
|
|
|
out = "d_out",
|
|
|
|
)
|
|
|
|
|
|
|
|
diff_test(
|
|
|
|
name = "copy_directory_test",
|
|
|
|
file1 = "d",
|
|
|
|
file2 = "copy_directory_case",
|
|
|
|
# Source directories are not support on remote execution.
|
|
|
|
tags = ["no-remote-exec"],
|
|
|
|
)
|
|
|
|
|
|
|
|
# Validate that copy_to_directory works and resolves its toolchain
|
|
|
|
copy_to_directory(
|
|
|
|
name = "copy_to_directory_case",
|
|
|
|
srcs = ["d"],
|
|
|
|
out = "d2_out",
|
|
|
|
replace_prefixes = {"d/": ""},
|
|
|
|
)
|
|
|
|
|
|
|
|
diff_test(
|
|
|
|
name = "copy_to_directory_test",
|
|
|
|
file1 = "d",
|
|
|
|
file2 = "copy_to_directory_case",
|
|
|
|
# Source directories are not support on remote execution.
|
|
|
|
tags = ["no-remote-exec"],
|
2022-04-27 04:07:17 +00:00
|
|
|
)
|
2023-02-19 04:09:27 +00:00
|
|
|
|
|
|
|
genrule(
|
|
|
|
name = "host_bazel_version",
|
|
|
|
outs = ["host_bazel_version.txt"],
|
|
|
|
cmd = "echo '%s' > $@" % host.bazel_version,
|
|
|
|
)
|