mirror of https://github.com/pulumi/pulumi.git
6af5f0b39d
**Overview** This re-enables tracking of code coverage. For Go, there are two kinds of coverage at play: unit test and integration test coverage. Unit tests follow the usual pattern of running `go test -cover -coverprofile=whatever.cov`. For integration tests, we use the new integration test profiling support [added in Go 1.20](https://go.dev/testing/coverage/). In short, the way it works is: # Build a coverage instrumented binary: go build -cover # Set GOCOVERDIR to a directory and run the integration tests # that will invoke this coverage-instrumented binary. GOCOVERDIR=$(pwd)/coverage go test ./tests # $GOCOVERDIR will now be filled with coverage data # from every invocation of the coverage-instrumented binary. # Combine it into a single coverage file: go tool covdata textfmt -i=$(GOCOVERDIR) -o=out.cov # The resulting file can be uploaded to codecov as-is. The above replaces the prior, partially working hacks we had in place to get coverage-instrumented binaries with `go test -c` and hijacking the TestMain. **Notable changes** - TestMain hijacking is deleted from the Pulumi CLI. We no longer need this to build coverage-instrumented binaries. - ProgramTest no longer tracks or passes PULUMI_TEST_COVERAGE_PATH because the Pulumi binary no longer accepts a test.coverprofile flag. This information is now in the GOCOVERDIR environment variable. - We add an `enable-coverage` parameter to the `ci-build-binaries` workflow to mirror some of the other workflows. It will produce coverage-instrumented binaries if this is true. These binaries are then used by `ci-run-test` which will set `GOCOVERDIR` and merge the coverage results from it. - Coverage configuration no longer counts tests, testdata, and Protobuf-generated code against coverage. - go-wrapper.sh: Because we're no longer relying on the `go test -c` hack, this no longer excludes Windows and language providers from coverage tracking. - go-test.py and go-wrapper.sh will include pulumi-language-go and pulumi-language-nodejs in covered packages. *Other changes* - go-test.py: Fixed a bug where `args` parameters added for coverage were ignored. Note that this change DOES NOT track coverage for calls made to Pulumi packages by plugins downloaded from external sources, e.g. provider plugins. Arguably, that's out of scope of coverage trackcing for the Pulumi repository. Resolves #8615, #11419 |
||
---|---|---|
.. | ||
command.go | ||
doc.go | ||
program.go | ||
program_test.go | ||
pulumi.go | ||
s3reporter.go | ||
util.go |