Don't rely on sh being in the PATH on Windows for tests

Signed-off-by: Paul "TBBle" Hampson <Paul.Hampson@Pobox.com>
v0.8
Paul "TBBle" Hampson 2020-07-28 03:34:11 +10:00
parent b2d3473cba
commit 31195373cf
2 changed files with 13 additions and 2 deletions

View File

@ -4651,7 +4651,12 @@ func tmpdir(appliers ...fstest.Applier) (string, error) {
func runShell(dir string, cmds ...string) error {
for _, args := range cmds {
cmd := exec.Command("sh", "-c", args)
var cmd *exec.Cmd
if runtime.GOOS == "windows" {
cmd = exec.Command("powershell", "-command", args)
} else {
cmd = exec.Command("sh", "-c", args)
}
cmd.Dir = dir
if err := cmd.Run(); err != nil {
return errors.Wrapf(err, "error running %v", args)

View File

@ -6,6 +6,7 @@ import (
"os"
"os/exec"
"path/filepath"
"runtime"
"strings"
"testing"
@ -392,7 +393,12 @@ func setupGitRepo(dir string) (string, error) {
func runShell(dir string, cmds ...string) error {
for _, args := range cmds {
cmd := exec.Command("sh", "-c", args)
var cmd *exec.Cmd
if runtime.GOOS == "windows" {
cmd = exec.Command("powershell", "-command", args)
} else {
cmd = exec.Command("sh", "-c", args)
}
cmd.Dir = dir
if err := cmd.Run(); err != nil {
return errors.Wrapf(err, "error running %v", args)