From 1a80508c26389f190ca034df9ade1f89d9de0a2c Mon Sep 17 00:00:00 2001 From: Lucas Bajolet Date: Fri, 3 May 2024 10:09:58 -0400 Subject: [PATCH] test/suite: compile plugins in parallel Since compiling plugins is quick, but each invocation still takes a bit of time, we run those compilation jobs in parallel to shave of a couple seconds from a test run. --- test/suite_test.go | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/test/suite_test.go b/test/suite_test.go index 8e9c16d2b..1d1c96f59 100644 --- a/test/suite_test.go +++ b/test/suite_test.go @@ -2,6 +2,7 @@ package test import ( "os" + "sync" "testing" "github.com/stretchr/testify/suite" @@ -21,12 +22,24 @@ type PackerTestSuite struct { packerPath string } +func buildPluginVersion(waitgroup *sync.WaitGroup, versionString string, t *testing.T) { + waitgroup.Add(1) + go func() { + BuildSimplePlugin(NewPluginBuildConfig(versionString), t) + waitgroup.Done() + }() +} + func (ts *PackerTestSuite) buildPluginBinaries(t *testing.T) { - BuildSimplePlugin(NewPluginBuildConfig("1.0.0"), t) - BuildSimplePlugin(NewPluginBuildConfig("1.0.1-dev"), t) - BuildSimplePlugin(NewPluginBuildConfig("1.0.1"), t) - BuildSimplePlugin(NewPluginBuildConfig("1.0.9"), t) - BuildSimplePlugin(NewPluginBuildConfig("1.0.10"), t) + wg := &sync.WaitGroup{} + + buildPluginVersion(wg, "1.0.0", t) + buildPluginVersion(wg, "1.0.1-dev", t) + buildPluginVersion(wg, "1.0.1", t) + buildPluginVersion(wg, "1.0.9", t) + buildPluginVersion(wg, "1.0.10", t) + + wg.Wait() } func Test_PackerCoreSuite(t *testing.T) {