Save test coverage data to bazel-testlogs. (#1387)

This lets `bazel coverage //some:test` produce a Go coverage data file
in `bazel-testlogs/some/test/coverage.dat`. This file can be processed
by normal Go coverage tooling to produce a coverage report.

The change to `go/private/rules/test.bzl` needs some explanation --
Bazel only looks for coverage data if the test target has an
`InstrumentedFilesProvider`, but this provider can currently only be
created using "legacy" provider syntax. Old and new provider syntaxes
can be combined by putting new-style providers in a `providers` field
of the old-style struct.

If the provider is found and at least one source file is present, Bazel
will set the `COVERAGE_OUTPUT_FILE` environment variable during tests
and will save that file to the build events + test outputs.
3 files changed