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

go: add support for test coverage #16550

Merged
merged 8 commits into from
Aug 21, 2022
Merged

Conversation

tdyas
Copy link
Contributor

@tdyas tdyas commented Aug 17, 2022

Update the Go backend to gather code coverage data for packages under test. The coverage files are written under dist/coverage/go/IMPORT_PATH directories (where IMPORT_PATH has slashes escaped to underscores). The coverage output is the raw cover.out format from the go tooling and is not rendered by this PR (which can be done in a follow-on since it is a bit involved).

[ci skip-rust]

[ci skip-build-wheels]

@tdyas tdyas requested review from stuhood and Eric-Arellano August 17, 2022 02:03
@tdyas tdyas added category:new feature backend: Go Go backend-related issues labels Aug 17, 2022
Copy link
Member

@stuhood stuhood left a comment

Choose a reason for hiding this comment

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

Thanks!

src/python/pants/backend/go/goals/test.py Outdated Show resolved Hide resolved
src/python/pants/backend/go/goals/test.py Outdated Show resolved Hide resolved
src/python/pants/backend/go/goals/test.py Outdated Show resolved Hide resolved
)

_coverage_output_dir = StrOption(
default=str(PurePath("{distdir}", "coverage", "go", "{import_path_escaped}")),
Copy link
Member

Choose a reason for hiding this comment

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

Hm... I'm surprised that you need this prefix... I guess that the test goal doesn't add it?

IIRC, @benjyw refactored the report output location to have a default, which would probably be reasonable to do here too if it makes things easier for you.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The test goal does not influence the output location. I based this code on the option code in the Python backend which supplies the path prefix itself. See

_output_dir = StrOption(
default=str(PurePath("{distdir}", "coverage", "python")),
advanced=True,
help="Path to write the Pytest Coverage report to. Must be relative to the build root.",
)

Tom Dyas added 8 commits August 20, 2022 20:07
[ci skip-rust]

[ci skip-build-wheels]
[ci skip-rust]

[ci skip-build-wheels]
[ci skip-rust]

[ci skip-build-wheels]
[ci skip-rust]

[ci skip-build-wheels]
[ci skip-rust]

[ci skip-build-wheels]
[ci skip-rust]

[ci skip-build-wheels]
of the test package only and `go` leaves this value blank in that case

[ci skip-rust]

[ci skip-build-wheels]
[ci skip-rust]

[ci skip-build-wheels]
@tdyas tdyas force-pushed the golang_test_coverage branch from 74d7be4 to c47c486 Compare August 21, 2022 01:15
@tdyas tdyas merged commit a3f6f04 into pantsbuild:main Aug 21, 2022
@tdyas tdyas deleted the golang_test_coverage branch August 21, 2022 04:37
cczona pushed a commit to cczona/pants that referenced this pull request Sep 1, 2022
Update the Go backend to gather code coverage data for packages under test. The coverage files are written under `dist/coverage/go/IMPORT_PATH` directories (where `IMPORT_PATH` has slashes escaped to underscores). The coverage output is the raw `cover.out` format from the `go` tooling and is not rendered by this PR (which can be done in a follow-on since it is a bit involved).

[ci skip-rust]

[ci skip-build-wheels]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend: Go Go backend-related issues category:new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants