Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions mage/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1877,6 +1877,28 @@ func TestWrongDependency(t *testing.T) {
}
}

// Regression tests, add tests to ensure we do not regress on known issues.

// TestBug508 is a regression test for: Bug: using Default with imports selects first matching func by name
func TestBug508(t *testing.T) {
stdout := &bytes.Buffer{}
stderr := &bytes.Buffer{}
inv := Invocation{
Dir: "./testdata/bug508",
Stderr: stderr,
Stdout: stdout,
}
code := Invoke(inv)
if code != 0 {
t.Log(stderr.String())
t.Fatalf("expected 0, but got %v", code)
}
expected := "test\n"
if stdout.String() != expected {
t.Fatalf("expected %q, but got %q", expected, stdout.String())
}
}

// / This code liberally borrowed from https://github.com/rsc/goversion/blob/master/version/exe.go

type (
Expand Down
20 changes: 20 additions & 0 deletions mage/testdata/bug508/deps/ambiguousimports.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package deps

import (
"fmt"

"github.com/magefile/mage/mg"
)

// All code in this package belongs to @na4ma4 in GitHub https://github.com/na4ma4/magefile-test-import
// reproduced here for ease of testing regression on bug 508

type Docker mg.Namespace

func (Docker) Test() {
fmt.Println("docker")
}

func Test() {
fmt.Println("test")
}
11 changes: 11 additions & 0 deletions mage/testdata/bug508/magefile.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//go:build mage
// +build mage

package main

import (
//mage:import
"github.com/magefile/mage/mage/testdata/bug508/deps"
)

var Default = deps.Test
Loading