Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add oci_tarball test for sh_test #624

Merged
merged 1 commit into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 33 additions & 1 deletion examples/assertion/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ assert_json_matches(
filter1 = ".[0].RepoTags",
)

# Case 10: An oci_image directly fed into oci_tarball
# Case 10: an oci_tarball run as part of a genrule
oci_image(
name = "case10",
architecture = "arm64",
Expand All @@ -312,6 +312,38 @@ $(location :case10_tarball) && echo "worked" > $@
tools = [":case10_tarball"],
)

# Case 11: an oci_tarball run as part of sh_test
oci_image(
name = "case11",
architecture = "arm64",
os = "linux",
)

oci_tarball(
name = "case11_tarball",
image = ":case11",
repo_tags = ["case11:example"],
)

write_file(
name = "case11_test_sh",
out = "case11_test.sh",
content = [
"output=$($1)",
'if [[ "$output" != "Loaded image: case11:example" ]]; then',
' echo "failed to load: $output"',
" exit 1",
"fi",
],
)

sh_test(
name = "case11_test",
srcs = ["case11_test.sh"],
args = ["$(location :case11_tarball)"],
data = [":case11_tarball"],
)

# build them as test.
build_test(
name = "test",
Expand Down
2 changes: 2 additions & 0 deletions oci/private/tarball_run.sh.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ set -o pipefail -o errexit -o nounset

{{BASH_RLOCATION_FUNCTION}}

runfiles_export_envvars

readonly TAR="$(rlocation "{{tar}}")"
readonly MTREE="$(rlocation "{{mtree_path}}")"
readonly LOADER="$(rlocation "{{loader}}")"
Expand Down
Loading