-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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
proposal: go/test: add a package to facilitate test tooling #47101
Comments
It seems like this is something that can and should be done outside the standard library, at least to start. |
This proposal has been added to the active column of the proposals project |
As I see it, the only options for doing it outside of the standard library involve one of the following:
The API proposal above was my attempt at a minimal interface to allow reuse of |
If we fix |
Test events ( Aside from that, two features would be extremely helpful for IDE integration:
I recognize that the only feasible way to provide a file path and line number for a subtest is for |
We already have The problem with a go/test package is that it locks us into a specific API in an area that we know from experience is subject to change over time. It's clearly preferable to get this information by invoking cmd/go if at all possible. That is, I think we would rather lock down the cmd/go command line API than we would a programmatic API for test information. |
One of the persistent issues is that In other words, the output of If IIRC, |
We do have to consider the case of |
go/packages is a nice Go API around the go list command line, It would be fine to write a third-party go/test package outside the standard library and see if that is useful. |
Without changes to |
A key point here is that the output you are concerned about isn't really coming from |
One of the issues parsing |
You're right: a failure building the test is reported by |
Just wanted to jump in and give my support for an API for interacting with My specific use case is auto grading programming assignments that we run in a custom CI environment; I use I don't have a clear idea right now what my API needs are, but I will certainly follow this issue and think more about this. Edit: Another use case for me is that if the student submitted code didn't compile -- then, no test binary runs, then there won't be any score output since it's the same binary the generates the score. I've not tried to fix this yet, just telling students that their code must compile... A wrapper around |
Based on the discussion above, this proposal seems like a likely decline. |
@rsc @ianlancetaylor Would a proposal along the lines, "add a --machine-readable-output flag to go test" be more successful? |
We already have machine readable output from |
gotestsum has been consuming the The main bugs seemed to be related to #24929, and tests or sub-tests not being correctly identified as passed or failed, either because of missing newlines or panics. But
I have been wondering if this would address the problems. Since build failures go to If I understand correctly that would mostly be a change to the @firelizzard18 I don't have any of the requirements that you mentioned for line numbers, but my impression is that sending events to a separate FD might be a prerequisite for making that happen. I guess file names and line numbers can't be added to the existing Would you like to create that proposal? If you don't I will try to propose something. I'm not all that familiar with the internals of Some more context for why I think sending events to another FD will likely fix the problems. The challenge with If there were a different FD then at least the run/pass/fail events would be reliable. If we could add a Any writes directly to |
@dnephin I do intend to make a proposal along those lines, but I'm not sure when I'll have time to work on that. Feel free to do it yourself if you want it to happen soon. |
No change in consensus, so declined. |
Developing tooling around
go test
is painful. To do anything meaningful beyond showing the output ofgo test
in plaintext, you have to parse the output ofgo test -v
.go test -json
is an option, but that's doing the same thing - parsing the output of a command that was not designed to be parsed. This is brittle - see #31969, #37555, #24929, #23037, etc.This is especially painful for benchmarks. For a successful benchmark,
test2json
never produces lifecycle events - all it produces areoutput
events where theTest
field is empty. To turn that into lifecycle events, you have to use a regex or equivalent to findBenchmarkXxx\n
andBenchmarkXxx-<maxProcs> <results>\n
in the output stream.I propose a new package, e.g.
go/test
, with an approximate interface below. The two areas I am personally most interested in are improving test and coverage reporting for CI and IDE integration. With respect to the latter, I am working on a PR tovscode-go
that implements the new VSCode test controller API. If this proposal is accepted, this feature could be integrated intogopls
to enable much more robust IDE test execution.The text was updated successfully, but these errors were encountered: