This repository was archived by the owner on Aug 17, 2020. It is now read-only.
Subtests autoinstrumentation #123
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This
PRadds auto instrumentation to sub tests and sub benchmarks.The problem on auto instrumenting sub tests and sub benchmarks is that the call to
t.Runandb.Runare recursive from the initial test execution to other sub tests.An initial try to solve the problem could be the following implementation:
This uses
PatchandUnpatchtwice to use the originalt.Runimplementation. The problem with this algorithm is that is not valid onParallelscenarios, because we don't know the execution order, If we try to use amutexwe end with a deadlock, because eachfuncexecuted byt.Runruns in a separated goroutine.The way we solve to solve this issue, is by never
Unpatchthe patched function, but calling the original implementation in another way.In this case we copy the implementation of both
t.Runandb.Runfrom the original golang source code, to do that we are forced to create the sametesting.Tandtesting.Bstructure and useunsafeto have access to the private fields and use somelinkingto private methods. Note with this implementation we don't need any lock.With this, we add auto instrumentation support for the following cases:
Tests
Benchmarks