1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-03-17 20:47:50 +02:00
Carlos Alexandro Becker 2bf08f11a6
ci: run build/test workflow on windows too (#5263)
Maybe 3rd time is the charm!

This makes the CI build run on windows too, and fix broken tests/featuers on Windows.

Most of the changes are related to ignoring certain tests on windows, or making sure to use the right path separators.

More work to do in the future, probably!

#4293

---------

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
2024-11-16 10:30:39 -03:00

37 lines
749 B
Go

package testlib
import (
"os"
"os/exec"
"runtime"
"testing"
)
// CheckPath skips the test if the binary is not in the PATH, or if CI is true.
func CheckPath(tb testing.TB, cmd string) {
tb.Helper()
if !InPath(cmd) {
tb.Skipf("%s not in PATH", cmd)
}
}
// InPath returns true if the given cmd is in the PATH, or if CI is true.
func InPath(cmd string) bool {
if os.Getenv("CI") == "true" {
return true
}
_, err := exec.LookPath(cmd)
return err == nil
}
// IsWindows returns true if current OS is Windows.
func IsWindows() bool { return runtime.GOOS == "windows" }
// SkipIfWindows skips the test if runtime OS is windows.
func SkipIfWindows(tb testing.TB) {
tb.Helper()
if IsWindows() {
tb.Skip("test skipped on windows")
}
}