diff --git a/bazel/container_structure_test.bzl b/bazel/container_structure_test.bzl index e59d183d..e7a3302f 100644 --- a/bazel/container_structure_test.bzl +++ b/bazel/container_structure_test.bzl @@ -44,7 +44,11 @@ fi """ def _structure_test_impl(ctx): - fixed_args = [] + fixed_args = [ + "--test-report $XML_OUTPUT_FILE", + "--output junit", + "--junit-suite-name $TEST_TARGET" + ] test_bin = ctx.toolchains["@container_structure_test//bazel:structure_test_toolchain_type"].st_info.binary jq_bin = ctx.toolchains["@aspect_bazel_lib//lib:jq_toolchain_type"].jqinfo.bin diff --git a/bazel/test/README.md b/bazel/test/README.md index 79fea015..5a351f52 100644 --- a/bazel/test/README.md +++ b/bazel/test/README.md @@ -2,8 +2,37 @@ Verifies that the container_structure_test bazel rule exposed by this project works properly. +## Running tests with pre-compiled toolchain + ```sh cd bazel/test bazel test ... bazel test --enable_bzlmod ... -``` \ No newline at end of file +``` + +## Testing with local changes (non-pre-compiled toolchain) + +When developing changes, you may want to test your modifications before they're compiled a release. Here's how to test with a locally built binary: + +1. Build your local binary: + ```sh + go build -o /tmp/container-structure-test-local ./cmd/container-structure-test/ + ``` + +2. Temporarily modify `bazel/container_structure_test.bzl`: + ```sh + sed -i.bak 's|readonly st=$(rlocation {st_path})|readonly st="/tmp/container-structure-test-local"|g' bazel/container_structure_test.bzl + ``` + +3. Run the bazel test: + ```sh + cd bazel/test + bazel test :test --test_output=all + ``` + +4. Restore the original rule: + ```sh + mv bazel/container_structure_test.bzl.bak bazel/container_structure_test.bzl + ``` + +This allows you to verify that your changes work correctly with the bazel integration before submitting them.