Skip to content

Commit 1e1bb81

Browse files
Bazel output results as junit.xml (#507)
* add an option to set junit suite name. Pass the bazel target name * Apply suggestions from code review Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> * update instructions to work with bsd and gnu sed * disable bazel test * re-enable bazel tests --------- Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
1 parent 63ee63e commit 1e1bb81

File tree

2 files changed

+35
-2
lines changed

2 files changed

+35
-2
lines changed

bazel/container_structure_test.bzl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,11 @@ fi
4444
"""
4545

4646
def _structure_test_impl(ctx):
47-
fixed_args = []
47+
fixed_args = [
48+
"--test-report $XML_OUTPUT_FILE",
49+
"--output junit",
50+
"--junit-suite-name $TEST_TARGET"
51+
]
4852
test_bin = ctx.toolchains["@container_structure_test//bazel:structure_test_toolchain_type"].st_info.binary
4953
jq_bin = ctx.toolchains["@aspect_bazel_lib//lib:jq_toolchain_type"].jqinfo.bin
5054

bazel/test/README.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,37 @@
22

33
Verifies that the container_structure_test bazel rule exposed by this project works properly.
44

5+
## Running tests with pre-compiled toolchain
6+
57
```sh
68
cd bazel/test
79
bazel test ...
810
bazel test --enable_bzlmod ...
9-
```
11+
```
12+
13+
## Testing with local changes (non-pre-compiled toolchain)
14+
15+
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:
16+
17+
1. Build your local binary:
18+
```sh
19+
go build -o /tmp/container-structure-test-local ./cmd/container-structure-test/
20+
```
21+
22+
2. Temporarily modify `bazel/container_structure_test.bzl`:
23+
```sh
24+
sed -i.bak 's|readonly st=$(rlocation {st_path})|readonly st="/tmp/container-structure-test-local"|g' bazel/container_structure_test.bzl
25+
```
26+
27+
3. Run the bazel test:
28+
```sh
29+
cd bazel/test
30+
bazel test :test --test_output=all
31+
```
32+
33+
4. Restore the original rule:
34+
```sh
35+
mv bazel/container_structure_test.bzl.bak bazel/container_structure_test.bzl
36+
```
37+
38+
This allows you to verify that your changes work correctly with the bazel integration before submitting them.

0 commit comments

Comments
 (0)