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

introduce back go-junit-report for parsing go test output #82

Closed
Closed
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
12 changes: 10 additions & 2 deletions build_defs/go.build_defs
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ def go_test(name:str, srcs:list, resources:list=None, data:list|dict=None, deps:
)
cmds, tools = _go_binary_cmds(static=static, definitions=definitions, gcov=cgo)

test_cmd = f'$TEST {flags} 2>&1 | tee $TMP_DIR/test.results'
test_cmd = f'$TEST {flags} 2>&1 | $TOOLS_JUNIT_REPORT | tee $RESULTS_FILE'
worker_cmd = f'$(worker {worker})' if worker else ""
if worker_cmd:
test_cmd = f'{worker_cmd} && {test_cmd} '
Expand Down Expand Up @@ -646,6 +646,9 @@ def go_test(name:str, srcs:list, resources:list=None, data:list|dict=None, deps:
debug_tools = debug_tools,
cmd = cmds,
test_cmd = test_cmd,
test_tools = {
"junit_report": "//third_party/go:junit_report",
},
debug_cmd = debug_cmd,
visibility = visibility,
test_sandbox = sandbox,
Expand Down Expand Up @@ -912,7 +915,12 @@ def _go_install_module(name:str, module:str, install:list, src:str, outs:list, d
]

if binary:
outs = [f'pkg/{CONFIG.OS}_{CONFIG.ARCH}/bin/{name}']
# This decouples the name of the target from the name of the installed binary when it's unambiguous what the
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the change from #81

# output binary should be. This is especially useful when installing a module like
# github.com/jstemmer/go-junit-report/v2 which results in a binary called v2 which isn't a very helpful name for
# a build target.
bin_name = basename(install[0]) if len(install) == 1 else name
outs = [f'pkg/{CONFIG.OS}_{CONFIG.ARCH}/bin/{bin_name}']
else:
outs = [f'pkg/{CONFIG.OS}_{CONFIG.ARCH}/{out}' for out in _remove_redundant_outs(outs)]

Expand Down
15 changes: 15 additions & 0 deletions third_party/go/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,21 @@ go_module(
visibility = ["PUBLIC"],
)

go_mod_download(
name = "junit_report_download",
module = "github.com/marcuscaisey/go-junit-report/v2",
version = "f9f65c7e2eb4a7e4a98b4cc8757772ae1092d211",
)

go_module(
name = "junit_report",
binary = True,
download = ":junit_report_download",
licences = ["MIT"],
module = "github.com/jstemmer/go-junit-report/v2",
visibility = ["PUBLIC"],
)

go_module(
name = "spew",
install = ["spew"],
Expand Down