96 lines
2.5 KiB
Python
96 lines
2.5 KiB
Python
"""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.
|
|
"""
|
|
|
|
load("@aspect_bazel_lib//lib:copy_directory.bzl", "copy_directory")
|
|
load("@aspect_bazel_lib//lib:copy_to_directory.bzl", "copy_to_directory")
|
|
load("@aspect_bazel_lib//lib:diff_test.bzl", "diff_test")
|
|
load("@aspect_bazel_lib//lib:jq.bzl", "jq")
|
|
load("@aspect_bazel_lib//lib:yq.bzl", "yq")
|
|
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
|
|
load("@aspect_bazel_lib_host//:defs.bzl", "host")
|
|
|
|
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.
|
|
# 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",
|
|
# )
|
|
|
|
# Validate that JQ works and resolves its toolchain
|
|
jq(
|
|
name = "jq_case_no_sources",
|
|
srcs = [],
|
|
filter = ".",
|
|
)
|
|
|
|
diff_test(
|
|
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"],
|
|
)
|
|
|
|
genrule(
|
|
name = "host_bazel_version",
|
|
outs = ["host_bazel_version.txt"],
|
|
cmd = "echo '%s' > $@" % host.bazel_version,
|
|
)
|