Skip to content

Commit

Permalink
get mage tests to pass on windows (#312)
Browse files Browse the repository at this point in the history
  • Loading branch information
danbrakeley authored Aug 12, 2020
1 parent 707b7bd commit 50f568e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
27 changes: 21 additions & 6 deletions mage/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,10 @@ func TestListMagefilesMain(t *testing.T) {
if err != nil {
t.Errorf("error from magefile list: %v: %s", err, buf)
}
expected := []string{"testdata/mixed_main_files/mage_helpers.go", "testdata/mixed_main_files/magefile.go"}
expected := []string{
filepath.FromSlash("testdata/mixed_main_files/mage_helpers.go"),
filepath.FromSlash("testdata/mixed_main_files/magefile.go"),
}
if !reflect.DeepEqual(files, expected) {
t.Fatalf("expected %q but got %q", expected, files)
}
Expand All @@ -211,9 +214,9 @@ func TestListMagefilesIgnoresGOOS(t *testing.T) {
}
var expected []string
if runtime.GOOS == "windows" {
expected = []string{"testdata/goos_magefiles/magefile_windows.go"}
expected = []string{filepath.FromSlash("testdata/goos_magefiles/magefile_windows.go")}
} else {
expected = []string{"testdata/goos_magefiles/magefile_nonwindows.go"}
expected = []string{filepath.FromSlash("testdata/goos_magefiles/magefile_nonwindows.go")}
}
if !reflect.DeepEqual(files, expected) {
t.Fatalf("expected %q but got %q", expected, files)
Expand All @@ -235,9 +238,9 @@ func TestListMagefilesIgnoresRespectsGOOSArg(t *testing.T) {
}
var expected []string
if goos == "windows" {
expected = []string{"testdata/goos_magefiles/magefile_windows.go"}
expected = []string{filepath.FromSlash("testdata/goos_magefiles/magefile_windows.go")}
} else {
expected = []string{"testdata/goos_magefiles/magefile_nonwindows.go"}
expected = []string{filepath.FromSlash("testdata/goos_magefiles/magefile_nonwindows.go")}
}
if !reflect.DeepEqual(files, expected) {
t.Fatalf("expected %q but got %q", expected, files)
Expand Down Expand Up @@ -307,7 +310,10 @@ func TestListMagefilesLib(t *testing.T) {
if err != nil {
t.Errorf("error from magefile list: %v: %s", err, buf)
}
expected := []string{"testdata/mixed_lib_files/mage_helpers.go", "testdata/mixed_lib_files/magefile.go"}
expected := []string{
filepath.FromSlash("testdata/mixed_lib_files/mage_helpers.go"),
filepath.FromSlash("testdata/mixed_lib_files/magefile.go"),
}
if !reflect.DeepEqual(files, expected) {
t.Fatalf("expected %q but got %q", expected, files)
}
Expand Down Expand Up @@ -1078,6 +1084,9 @@ func TestCompiledFlags(t *testing.T) {
t.Fatal(err)
}
name := filepath.Join(compileDir, "mage_out")
if runtime.GOOS == "windows" {
name += ".exe"
}
// The CompileOut directory is relative to the
// invocation directory, so chop off the invocation dir.
outName := "./" + name[len(dir)-1:]
Expand Down Expand Up @@ -1162,6 +1171,9 @@ func TestCompiledEnvironmentVars(t *testing.T) {
t.Fatal(err)
}
name := filepath.Join(compileDir, "mage_out")
if runtime.GOOS == "windows" {
name += ".exe"
}
// The CompileOut directory is relative to the
// invocation directory, so chop off the invocation dir.
outName := "./" + name[len(dir)-1:]
Expand Down Expand Up @@ -1251,6 +1263,9 @@ func TestCompiledVerboseFlag(t *testing.T) {
t.Fatal(err)
}
filename := filepath.Join(compileDir, "mage_out")
if runtime.GOOS == "windows" {
filename += ".exe"
}
// The CompileOut directory is relative to the
// invocation directory, so chop off the invocation dir.
outName := "./" + filename[len(dir)-1:]
Expand Down
1 change: 0 additions & 1 deletion mage/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ Options:
fs.Usage()
return
}
// color is ANSI color type
type color int
Expand Down

0 comments on commit 50f568e

Please sign in to comment.