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: cmd/covdata: traverse subdirectories of those passed via the -i argument #63275
Comments
CC @thanm |
Thanks for the prompt intake on this proposal! I also wanted to clarify that if accepted, I'd be willing to author the CR for this |
It seems to me that this could be avoided easily with a very minimal amount of scripting, e.g.
something along those lines. |
Absolutely, which is why I mentioned this is more a minor papercut. It is very much a solvable problem with the existing tools, and more of a nit with regards to developer ease-of-use. Are you mostly working backwards from keeping the surface area / scope of behavior for |
I'll leave another potential developer mistake for consideration below:
In this case, some general profiles have been written to the top level directory, and other platform-specific profiles to the platform-specific subdirectories below. If the developer runs |
Closing this as I'm fine with the current behavior upon deeper reflection. |
Currently a number of the subcommands of
go tool covdata
(textfmt
,percent
, ...) require users to pass the-i
argument which specifies the input dirs to examine (comma separated) for coverage data. Only the files in the named directory/directories are examined, and no subdirectories are visited. This lack of subdirectory traversal leads to some (admittedly minor) inconveniences for users of this command.Example 1: Multiple static locations, unchanging
Users may want to examine the unit test coverage (
go tool covdata func -i=coveragedata/unittests
), the integration test coverage (go tool covdata func -i=coveragedata/integrationtests
), or the combined coverage. Today, getting the combined coverage requires either manually specifying both directories as part of thefunc
subcommand (go tool covdata func -i=coveragedata/unittests,coveragedata/integrationtests
), or by manually specifying both directories as part of themerge
subcommand (go tool covdata merge -i=coveragedata/unittests,coveragedata/integrationtests -o merged
) and then later running thefunc
command on the merged result (go tool covdata func -i=merged
).It would be easier to allow for
-i
to traverse the passed directories (including any subdirectories), such that users wishing to view coverage data for both could simply rungo tool covdata func -i=coveragedata
orgo tool covdata merge -i=coveragedata -o merged && go tool covdata func -i=merged
. However, for two static directory locations which don't change, this represents a very minor papercut and can easily be worked around with existing options.Example 2: Multiple static locations, changing
The testing coverage docs specifically reference an example of:
In practice, this could become a bit unwieldily, as the every time a new platform is added for testing the call to the
covdata
command would have to be updated to manually pass in this new directory location. Updating the coverage command may be forgotten, silently missing being included in top level coverage. If directory traversal was included, this command could again be simplified togo tool covdata func -i=coveragedata
eliminating the risk of new platforms being missed. Again, the current tools provide the necessary workaround (-i=coveragedata/windows,coveragedata/macos, ...), and the behavior still remains a minor papercut.Example 3: Dynamic Locations
Consider a hypothetical company which handles user purchases which wants to run its integration test suite for a number of countries (EN / CA / ES / ...), platforms (windows, macos, ...), and payment vendors (paypal, stripe, ...) to measure overall coverage for all supported combinations of purchase flows. This generates a dynamic number of directory locations, which all need to be fed into the
-i
argument. This can certainly be accomplished with the current tooling, but would likely be much simpler (and less error-prone) if they could just specifygo tool covdata func -i=coveragedata
and avoid having to dynamically build a list of every possible directory location.The proposed change would be to update this to instead call
filepath.WalkDir
, with no other changes to the parsing logic.The text was updated successfully, but these errors were encountered: