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
cmd/go: binaries built with test -c
do not support -json
option
#31051
Comments
I fell at the first hurdle, because |
|
Thanks, but the other host is actually (sometimes) running a different OS (i.e. the build is sometimes a cross-build, sorry, I should have mentioned that!) so it's sadly not as simple as just a copy for me. |
go test -c
do not support -json
optiontest -c
do not support -json
option
I believe this is in effect a dup of #22996. |
Thanks and sorry for not finding the previous issue (I did search, I promise). I understand the issues from #22996, it's not ideal but I think I can lash something together, thanks! |
As well as gotestsum we now also need to build `test2json` because test binaries build with `go test -c` do not support the `-test` option. That option just wraps the test run in the `test2json` code which translates from the standard output syntax to json. (See golang/go#31051 for more info). This uses `cmd/test2json` the source of which is part of the go distribution and is therefore available in the base images. Once we have them then we "simply" chain them together, `gotestsum` takes a `--raw-command` for which we pass `test2json`. In turn `test2json` takes a command which it will wrap and we pass the actual e2e test binary. Since running `test2json` manually gives us the opportunity to set the package name (with `-p`) we give it a distinct name rather than munging the output after the fact like we do with the unit tests. Since the only references to these tools are in `Jenkinsfile.*` we don't need to worry about making them available for non-containerised runs. Signed-off-by: Ian Campbell <ijc@docker.com>
As well as gotestsum we now also need to build `test2json` because test binaries build with `go test -c` do not support the `-test` option. That option just wraps the test run in the `test2json` code which translates from the standard output syntax to json. (See golang/go#31051 for more info). This uses `cmd/test2json` the source of which is part of the go distribution and is therefore available in the base images. Once we have them then we "simply" chain them together, `gotestsum` takes a `--raw-command` for which we pass `test2json`. In turn `test2json` takes a command which it will wrap and we pass the actual e2e test binary. Since running `test2json` manually gives us the opportunity to set the package name (with `-p`) we give it a distinct name rather than munging the output after the fact like we do with the unit tests. Since the only references to these tools are in `Jenkinsfile.*` we don't need to worry about making them available for non-containerised runs. Signed-off-by: Ian Campbell <ijc@docker.com>
As well as gotestsum we now also need to build `test2json` because test binaries build with `go test -c` do not support the `-test` option. That option just wraps the test run in the `test2json` code which translates from the standard output syntax to json. (See golang/go#31051 for more info). This uses `cmd/test2json` the source of which is part of the go distribution and is therefore available in the base images. Once we have them then we "simply" chain them together, `gotestsum` takes a `--raw-command` for which we pass `test2json`. In turn `test2json` takes a command which it will wrap and we pass the actual e2e test binary. Since running `test2json` manually gives us the opportunity to set the package name (with `-p`) we give it a distinct name rather than munging the output after the fact like we do with the unit tests. Since the only references to these tools are in `Jenkinsfile.*` we don't need to worry about making them available for non-containerised runs. Signed-off-by: Ian Campbell <ijc@docker.com>
As well as gotestsum we now also need to build `test2json` because test binaries build with `go test -c` do not support the `-test` option. That option just wraps the test run in the `test2json` code which translates from the standard output syntax to json. (See golang/go#31051 for more info). This uses `cmd/test2json` the source of which is part of the go distribution and is therefore available in the base images. Once we have them then we "simply" chain them together, `gotestsum` takes a `--raw-command` for which we pass `test2json`. In turn `test2json` takes a command which it will wrap and we pass the actual e2e test binary. Running `test2json` manually gives us the opportunity to set the package name (with `-p`) we give it a distinct name rather than munging the output after the fact like we do with the unit tests. Since the only references to these tools are in `Jenkinsfile.*` we don't need to worry about making them available for non-containerised runs. `test2json` requires verbose output, so add `-test.v` in one case. Signed-off-by: Ian Campbell <ijc@docker.com>
As well as gotestsum we now also need to build `test2json` because test binaries build with `go test -c` do not support the `-test` option. That option just wraps the test run in the `test2json` code which translates from the standard output syntax to json. (See golang/go#31051 for more info). This uses `cmd/test2json` the source of which is part of the go distribution and is therefore available in the base images. Once we have them then we "simply" chain them together, `gotestsum` takes a `--raw-command` for which we pass `test2json`. In turn `test2json` takes a command which it will wrap and we pass the actual e2e test binary. Running `test2json` manually gives us the opportunity to set the package name (with `-p`) we give it a distinct name rather than munging the output after the fact like we do with the unit tests. Since the only references to these tools are in `Jenkinsfile.*` we don't need to worry about making them available for non-containerised runs. `test2json` requires verbose output, so add `-test.v` in one case. Signed-off-by: Ian Campbell <ijc@docker.com>
For future diggers: gotestyourself/gotestsum#77 |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
I believe 1.12.1 is latest, so yes.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I am building a test binary using
go test -c
(with the intention of running the actual test on another host, which has no Go toolchain installed) and I would like to use it withgotestsum
(primarily for the--junitfile
support to integrate with Jenkins).However the binaries built this way do not support the
-json
option required bygotestsum
(nor does it support-test.json
).go test --json ./
producesjson
output while:I'm aware that I can pipe the output of my test binary to
go tool test2json
but this is inconvenient since the target host lacks Go. I'm going to experiment with working around this by usingTestMain
to inject something like the code which backs the-json
option ongo test
(https://github.com/golang/go/blob/master/src/cmd/go/internal/test/test.go#L1045...L1049), but it would be great if this just worked.What did you expect to see?
Support for the
-json
option in my test binary built withgo test -s
What did you see instead?
No support for
-json
in that binary.The text was updated successfully, but these errors were encountered: