Skip to content

Commit 50f568e

Browse files
authored
get mage tests to pass on windows (#312)
1 parent 707b7bd commit 50f568e

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

mage/main_test.go

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,10 @@ func TestListMagefilesMain(t *testing.T) {
191191
if err != nil {
192192
t.Errorf("error from magefile list: %v: %s", err, buf)
193193
}
194-
expected := []string{"testdata/mixed_main_files/mage_helpers.go", "testdata/mixed_main_files/magefile.go"}
194+
expected := []string{
195+
filepath.FromSlash("testdata/mixed_main_files/mage_helpers.go"),
196+
filepath.FromSlash("testdata/mixed_main_files/magefile.go"),
197+
}
195198
if !reflect.DeepEqual(files, expected) {
196199
t.Fatalf("expected %q but got %q", expected, files)
197200
}
@@ -211,9 +214,9 @@ func TestListMagefilesIgnoresGOOS(t *testing.T) {
211214
}
212215
var expected []string
213216
if runtime.GOOS == "windows" {
214-
expected = []string{"testdata/goos_magefiles/magefile_windows.go"}
217+
expected = []string{filepath.FromSlash("testdata/goos_magefiles/magefile_windows.go")}
215218
} else {
216-
expected = []string{"testdata/goos_magefiles/magefile_nonwindows.go"}
219+
expected = []string{filepath.FromSlash("testdata/goos_magefiles/magefile_nonwindows.go")}
217220
}
218221
if !reflect.DeepEqual(files, expected) {
219222
t.Fatalf("expected %q but got %q", expected, files)
@@ -235,9 +238,9 @@ func TestListMagefilesIgnoresRespectsGOOSArg(t *testing.T) {
235238
}
236239
var expected []string
237240
if goos == "windows" {
238-
expected = []string{"testdata/goos_magefiles/magefile_windows.go"}
241+
expected = []string{filepath.FromSlash("testdata/goos_magefiles/magefile_windows.go")}
239242
} else {
240-
expected = []string{"testdata/goos_magefiles/magefile_nonwindows.go"}
243+
expected = []string{filepath.FromSlash("testdata/goos_magefiles/magefile_nonwindows.go")}
241244
}
242245
if !reflect.DeepEqual(files, expected) {
243246
t.Fatalf("expected %q but got %q", expected, files)
@@ -307,7 +310,10 @@ func TestListMagefilesLib(t *testing.T) {
307310
if err != nil {
308311
t.Errorf("error from magefile list: %v: %s", err, buf)
309312
}
310-
expected := []string{"testdata/mixed_lib_files/mage_helpers.go", "testdata/mixed_lib_files/magefile.go"}
313+
expected := []string{
314+
filepath.FromSlash("testdata/mixed_lib_files/mage_helpers.go"),
315+
filepath.FromSlash("testdata/mixed_lib_files/magefile.go"),
316+
}
311317
if !reflect.DeepEqual(files, expected) {
312318
t.Fatalf("expected %q but got %q", expected, files)
313319
}
@@ -1078,6 +1084,9 @@ func TestCompiledFlags(t *testing.T) {
10781084
t.Fatal(err)
10791085
}
10801086
name := filepath.Join(compileDir, "mage_out")
1087+
if runtime.GOOS == "windows" {
1088+
name += ".exe"
1089+
}
10811090
// The CompileOut directory is relative to the
10821091
// invocation directory, so chop off the invocation dir.
10831092
outName := "./" + name[len(dir)-1:]
@@ -1162,6 +1171,9 @@ func TestCompiledEnvironmentVars(t *testing.T) {
11621171
t.Fatal(err)
11631172
}
11641173
name := filepath.Join(compileDir, "mage_out")
1174+
if runtime.GOOS == "windows" {
1175+
name += ".exe"
1176+
}
11651177
// The CompileOut directory is relative to the
11661178
// invocation directory, so chop off the invocation dir.
11671179
outName := "./" + name[len(dir)-1:]
@@ -1251,6 +1263,9 @@ func TestCompiledVerboseFlag(t *testing.T) {
12511263
t.Fatal(err)
12521264
}
12531265
filename := filepath.Join(compileDir, "mage_out")
1266+
if runtime.GOOS == "windows" {
1267+
filename += ".exe"
1268+
}
12541269
// The CompileOut directory is relative to the
12551270
// invocation directory, so chop off the invocation dir.
12561271
outName := "./" + filename[len(dir)-1:]

mage/template.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ Options:
9292
fs.Usage()
9393
return
9494
}
95-
9695
9796
// color is ANSI color type
9897
type color int

0 commit comments

Comments
 (0)