Skip to content

Commit

Permalink
fix windows
Browse files Browse the repository at this point in the history
  • Loading branch information
wildum committed Oct 17, 2024
1 parent 47cae66 commit 5f7a72c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
16 changes: 11 additions & 5 deletions internal/cmd/integration-tests/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
10 changes: 3 additions & 7 deletions internal/cmd/integration-tests/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ import (
"time"
)

const (
alloyBinaryPath = "../../../../../build/alloy"
)

type TestLog struct {
TestDir string
AlloyLog string
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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()
Expand Down

0 comments on commit 5f7a72c

Please sign in to comment.