From 5f7a72cdc3f26c4ac74dc70c36435b2c9b6f248e Mon Sep 17 00:00:00 2001 From: William Dumont Date: Thu, 17 Oct 2024 17:07:43 +0200 Subject: [PATCH] fix windows --- internal/cmd/integration-tests/main.go | 16 +++++++++++----- .../windows/config.alloy | 0 .../windows/windows_metrics_test.go | 0 internal/cmd/integration-tests/utils.go | 10 +++------- 4 files changed, 14 insertions(+), 12 deletions(-) rename internal/cmd/integration-tests/{tests => tests-windows}/windows/config.alloy (100%) rename internal/cmd/integration-tests/{tests => tests-windows}/windows/windows_metrics_test.go (100%) diff --git a/internal/cmd/integration-tests/main.go b/internal/cmd/integration-tests/main.go index 28885e0c50..b44288d98c 100644 --- a/internal/cmd/integration-tests/main.go +++ b/internal/cmd/integration-tests/main.go @@ -36,25 +36,31 @@ func runIntegrationTests(cmd *cobra.Command, args []string) { if !skipBuild { buildAlloy() } + + testFolder := "./tests/" + alloyBinaryPath := filepath.Join("..", "..", "..", "..", "..", "build", "alloy") + if runtime.GOOS != "windows" { setupEnvironment() } else { + testFolder = "./tests-windows/" + alloyBinaryPath += ".exe" fmt.Println("Skipping environment setup on Windows.") } if specificTest != "" { fmt.Println("Running", specificTest) - if !filepath.IsAbs(specificTest) && !strings.HasPrefix(specificTest, "./tests/") { - specificTest = "./tests/" + specificTest + if !filepath.IsAbs(specificTest) && !strings.HasPrefix(specificTest, testFolder) { + specificTest = testFolder + specificTest } logChan = make(chan TestLog, 1) - runSingleTest(specificTest, 12345) + runSingleTest(alloyBinaryPath, specificTest, 12345) } else { - testDirs, err := filepath.Glob("./tests/*") + testDirs, err := filepath.Glob(testFolder + "*") if err != nil { panic(err) } logChan = make(chan TestLog, len(testDirs)) - runAllTests() + runAllTests(alloyBinaryPath) } } diff --git a/internal/cmd/integration-tests/tests/windows/config.alloy b/internal/cmd/integration-tests/tests-windows/windows/config.alloy similarity index 100% rename from internal/cmd/integration-tests/tests/windows/config.alloy rename to internal/cmd/integration-tests/tests-windows/windows/config.alloy diff --git a/internal/cmd/integration-tests/tests/windows/windows_metrics_test.go b/internal/cmd/integration-tests/tests-windows/windows/windows_metrics_test.go similarity index 100% rename from internal/cmd/integration-tests/tests/windows/windows_metrics_test.go rename to internal/cmd/integration-tests/tests-windows/windows/windows_metrics_test.go diff --git a/internal/cmd/integration-tests/utils.go b/internal/cmd/integration-tests/utils.go index 33ab7beb62..6177f99f70 100644 --- a/internal/cmd/integration-tests/utils.go +++ b/internal/cmd/integration-tests/utils.go @@ -12,10 +12,6 @@ import ( "time" ) -const ( - alloyBinaryPath = "../../../../../build/alloy" -) - type TestLog struct { TestDir string AlloyLog string @@ -44,7 +40,7 @@ func setupEnvironment() { time.Sleep(45 * time.Second) } -func runSingleTest(testDir string, port int) { +func runSingleTest(alloyBinaryPath string, testDir string, port int) { info, err := os.Stat(testDir) if err != nil { panic(err) @@ -94,7 +90,7 @@ func runSingleTest(testDir string, port int) { } } -func runAllTests() { +func runAllTests(alloyBinaryPath string) { testDirs, err := filepath.Glob("./tests/*") if err != nil { panic(err) @@ -106,7 +102,7 @@ func runAllTests() { wg.Add(1) go func(td string, offset int) { defer wg.Done() - runSingleTest(td, port+offset) + runSingleTest(alloyBinaryPath, td, port+offset) }(testDir, i) } wg.Wait()