138 lines
3.3 KiB
Python
138 lines
3.3 KiB
Python
load("@aspect_bazel_lib//lib:bats.bzl", "bats_test")
|
|
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:expand_template.bzl", "expand_template")
|
|
load("@aspect_bazel_lib//lib:jq.bzl", "jq")
|
|
load("@aspect_bazel_lib//lib:tar.bzl", "tar")
|
|
load("@aspect_bazel_lib//lib:yq.bzl", "yq")
|
|
|
|
# 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",
|
|
verbose = True,
|
|
)
|
|
|
|
diff_test(
|
|
name = "copy_directory_test",
|
|
file1 = "d",
|
|
file2 = "copy_directory_case",
|
|
)
|
|
|
|
# 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",
|
|
)
|
|
|
|
# Validate that expand_template works and resolves its toolchain
|
|
expand_template(
|
|
name = "a_tmpl_stamp",
|
|
out = "a_stamp",
|
|
data = ["a.tmpl"],
|
|
stamp = 1,
|
|
stamp_substitutions = {
|
|
"{{VERSION}}": "v{{BUILD_SCM_VERSION}}",
|
|
},
|
|
substitutions = {
|
|
"{{VERSION}}": "v0.0.0",
|
|
"{{WORKSPACE}}": "$(WORKSPACE)",
|
|
},
|
|
template = "a.tmpl",
|
|
)
|
|
|
|
diff_test(
|
|
name = "a_stamp_test",
|
|
file1 = ":a_stamp",
|
|
file2 = select({
|
|
"@aspect_bazel_lib//lib:bzlmod": "a_stamp_expected_bzlmod",
|
|
"//conditions:default": "a_stamp_expected",
|
|
}),
|
|
)
|
|
|
|
# Validate that tar works and resolves its toolchain
|
|
tar(
|
|
name = "tar_empty",
|
|
srcs = [],
|
|
mtree = [],
|
|
)
|
|
|
|
bats_test(
|
|
name = "bats",
|
|
srcs = [
|
|
"basic.bats",
|
|
],
|
|
)
|
|
|
|
copy_to_directory(
|
|
name = "copy_to_directory_mtime_case",
|
|
srcs = ["d"],
|
|
out = "copy_to_directory_mtime_out",
|
|
preserve_mtime = True,
|
|
)
|
|
|
|
copy_directory(
|
|
name = "copy_directory_mtime_case",
|
|
src = "d",
|
|
out = "copy_directory_mtime_out",
|
|
preserve_mtime = True,
|
|
)
|
|
|
|
sh_test(
|
|
name = "test_preserve_mtime",
|
|
size = "small",
|
|
srcs = ["test_preserve_mtime.sh"],
|
|
data = [
|
|
"d",
|
|
":copy_directory_mtime_case",
|
|
":copy_to_directory_mtime_case",
|
|
],
|
|
# FIXME(#898)
|
|
# On macos, fails with
|
|
# stat: illegal option -- -
|
|
# usage: stat [-FLnq] [-f format | -l | -r | -s | -x] [-t timefmt] [file ...]
|
|
# On windows, fails with
|
|
# stat: cannot stat 'd/1': No such file or directory
|
|
# On Linux, it's helplessly flaky, often failing in 2/2 attempts like
|
|
# Preserve mtime test failed. Modify times do not match for d/1 and copy_to_directory_mtime_out/d/1
|
|
# Original modify time: 2024-08-14 18:23:01.413642851 +0000
|
|
# Copied modify time: 2024-08-14 18:23:31.501819589 +0000
|
|
tags = ["manual"],
|
|
)
|