generated from kubernetes/kubernetes-template-project
-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This patch reduces the number of accesses to the context in the testEnv to only the ones that are strictly necessary and that should be synchronous. So, testEnv still contains a ctx, but is only to be used as a starting point and won't be updated except after the setup and finish phase. According to the following logic: - If `Test` is used, the same logic of now applies. So the context is passed to all features being run sequentially and the most updated version is then returned to the caller. - If `TestInParallel` is used (and parallel tests are enabled), the context is first populated by the `BeforeEachTest` functions and then a dedicated child of the parent context is provided to each test running in parallel, which is then discarded and only the original parent context is passed to the `AfterEachTest` functions and back into the environment. This is actually fixing a race condition in the previous implementation of `TestInParallel`. - If `t.Parallel` is used to run one or more features either using `Test` or `TestInParallel`, the same logic above applies, given that each caller will get its own context back. The only caveat is that the context is that the Finish phase will only be able to see the context from the Setup phase and not the one from the features themselves. Co-authored-by: Matteo Ruina <matteo.ruina@datadoghq.com> Signed-off-by: Philippe Scorsolini <p.scorsolini@gmail.com>
- Loading branch information
Showing
11 changed files
with
322 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -92,5 +92,5 @@ func TestScenarioOne(t *testing.T) { | |
}). | ||
Feature() | ||
|
||
testEnv.Test(t, feature) | ||
_ = testEnv.Test(t, feature) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.