Skip to content

Commit

Permalink
Avoid re-creating runner
Browse files Browse the repository at this point in the history
  • Loading branch information
mrodm committed May 20, 2024
1 parent 5626a32 commit 8c69dfb
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cmd/testrunner.go
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ func testTypeCommandActionFactory(runner testrunner.TestRunner) cobraext.Command
var results []testrunner.TestResult
for _, folder := range testFolders {
runnerOptions.TestFolder = folder
r, err := testrunner.Run(ctx, testType, runnerOptions)
r, err := testrunner.Run(ctx, runner, runnerOptions)

// Results must be appended even if there is an error, since there could be
// tests (e.g. system tests) that return both error and results.
Expand Down
7 changes: 1 addition & 6 deletions internal/testrunner/testrunner.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,12 +301,7 @@ func NewRunner(testType TestType) (TestRunner, error) {
}

// Run method delegates execution to the registered test runner, based on the test type.
func Run(ctx context.Context, testType TestType, options TestOptions) ([]TestResult, error) {
runner, defined := runners[testType]
if !defined {
return nil, fmt.Errorf("unregistered runner test: %s", testType)
}

func Run(ctx context.Context, runner TestRunner, options TestOptions) ([]TestResult, error) {
results, err := runner.Run(ctx, options)
tdErr := runner.TearDown(ctx)
if err != nil {
Expand Down

0 comments on commit 8c69dfb

Please sign in to comment.