diff options
author | Flu0r1ne <flur01ne@flu0r1ne.net> | 2021-09-05 01:29:24 -0500 |
---|---|---|
committer | Flu0r1ne <flur01ne@flu0r1ne.net> | 2021-09-05 01:29:24 -0500 |
commit | e120a9f5955551fcf314543c8889e58277aefb20 (patch) | |
tree | a027a396cfe727d33a5727ff1ba66b795fc6037f /adapters/gtest/adapter.go | |
parent | 4cc29e50d59daf445f4152d10f9f41cb1828f702 (diff) | |
download | planr-e120a9f5955551fcf314543c8889e58277aefb20.tar.xz planr-e120a9f5955551fcf314543c8889e58277aefb20.zip |
Add concurrency to evaluate
Diffstat (limited to 'adapters/gtest/adapter.go')
-rw-r--r-- | adapters/gtest/adapter.go | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/adapters/gtest/adapter.go b/adapters/gtest/adapter.go index ec11748..2961f29 100644 --- a/adapters/gtest/adapter.go +++ b/adapters/gtest/adapter.go @@ -59,17 +59,24 @@ func (adapter *Adapter) Evaluate(tcs []planr.TestCase) [] planr.TestResult { exes := createExecutables(tcs) + c := make(chan []planr.TestResult, len(exes)) for i := range exes { - succeed, buildFailures := exes[i].compile(buildDir) + go func(exe *executable) { + succeed, buildFailures := exe.compile(buildDir) - if ! succeed { - results = append(results, buildFailures...) - continue - } + if ! succeed { + c <- buildFailures + return + } - runtimeResults := exes[i].execute(buildDir) + runtimeResults := exe.execute(buildDir) - results = append(results, runtimeResults...) + c <- runtimeResults + }(&exes[i]) + } + + for range exes { + results = append(results, (<-c)...) } return results |