fix: build fails when `-cover` and/or `-covermode` are passed
Overhaul the Injector API to stop using decorator.Load which internally relies on the use of packages.Load (similar to go list), which caused all dependencies to be built without instrumentation as part of the instrumentation build (i.e, wasted effort).
It turns out it is viable to instead use a combination of standard library APIs to construct just the required inputs:
- use
go/parser.ParseFileto parse the original source code to ago/asttree - use
go/typesto type-check the source code- use a custom
go/importerthat looks up from the-importcfgfile - extract the
Usesmap from producedtypes.Info
- use a custom
- Create a
decorator.Decoratorusinggotypes.DecoratorResolverbuilt from theUsesmap - From this point on, the previous mode of operation is fully supported
This actually simplifies the flow quite a bit, as fewer information is now necessary from the proxy.CompileCommand (we no longer need to infer a source tree root), and allows working with files that have been transformed by other tools (such as go tool cover) seamlessly.
This PR also introduces a new way to adjust line position information (generation of //line directives) to produce more accurate results. It does so by comparing line information of nodes between the newly restored AST & the original AST, and making sure adjusted line information matches; adding new directives as necessary.
This also updates the test runners' go runtimes to go1.22.6 and go1.21.13 releases, which include bug fixes that allow us to:
- forego using
gotipto use thecovdatatool, as it no longer keeps an excessive amount of file descriptors open; - collect coverage of the integration tests themselves during ingteration test runs.
Fixes #214