Skip to content

Commit

Permalink
Potential test fix for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
amitsaha committed Aug 24, 2023
1 parent 5925589 commit 8625581
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,23 @@ import (
"os/exec"
"path"
"reflect"
"runtime"
"testing"
)

func TestCliUsage(t *testing.T) {
cmd := exec.Command("go", "build", "-o", "gitbackup_test_bin")
binaryFilename := "gitbackup_test_bin"
if runtime.GOOS == "windows" {
binaryFilename = "gitbackup_test_bin.exe"
}

cmd := exec.Command("go", "build", "-o", binaryFilename)
stdoutStderr, err := cmd.CombinedOutput()
if err != nil {
t.Fatalf("Error building test binary: %v - %v", err, string(stdoutStderr))
}
defer func() {
err := os.Remove("gitbackup_test_bin")
err := os.Remove(binaryFilename)
if err != nil {
t.Fatal(err)
}
Expand All @@ -27,7 +33,8 @@ func TestCliUsage(t *testing.T) {
goldenFilepath := path.Join("testdata", t.Name()+".golden")
goldenFilepathNew := goldenFilepath + ".expected"

cmd = exec.Command("./gitbackup_test_bin", "-h")
cmd = exec.Command("./"+binaryFilename, "-h")
t.Log(cmd.String())
cmd.Stdout = &stdout
cmd.Stderr = &stderr
err = cmd.Run()
Expand Down

0 comments on commit 8625581

Please sign in to comment.