-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ignore go:generate directives for other tools
- fixes #137
- Loading branch information
1 parent
c570f95
commit 35e91c8
Showing
2 changed files
with
102 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package command | ||
|
||
import ( | ||
"log" | ||
"testing" | ||
|
||
. "github.com/onsi/gomega" | ||
"github.com/sclevine/spec" | ||
"github.com/sclevine/spec/report" | ||
) | ||
|
||
func TestRunner(t *testing.T) { | ||
spec.Run(t, "Regexp", testRegexp, spec.Report(report.Terminal{})) | ||
} | ||
|
||
type Case struct { | ||
input string | ||
matches bool | ||
args []string | ||
} | ||
|
||
func testRegexp(t *testing.T, when spec.G, it spec.S) { | ||
var cases []Case | ||
|
||
it.Before(func() { | ||
RegisterTestingT(t) | ||
log.SetFlags(log.Llongfile) | ||
cases = []Case{ | ||
{ | ||
input: "//go:generate counterfeiter . Intf", | ||
matches: true, | ||
args: []string{".", "Intf"}, | ||
}, | ||
{ | ||
input: "//go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . Intf", | ||
matches: true, | ||
args: []string{".", "Intf"}, | ||
}, | ||
{ | ||
input: "//counterfeiter:generate . Intf", | ||
matches: true, | ||
args: []string{".", "Intf"}, | ||
}, | ||
{ | ||
input: "//go:generate stringer -type=Enum", | ||
matches: false, | ||
args: []string{".", "Intf"}, | ||
}, | ||
} | ||
}) | ||
|
||
it.Focus("splits args correctly", func() { | ||
Expect(stringToArgs(". Intf")).To(ConsistOf([]string{"counterfeiter", ".", "Intf"})) | ||
Expect(stringToArgs(" . Intf ")).To(ConsistOf([]string{"counterfeiter", ".", "Intf"})) | ||
}) | ||
|
||
it("matches lines appropriately", func() { | ||
for _, c := range cases { | ||
result := matchForString(c.input) | ||
if c.matches { | ||
Expect(result).NotTo(BeNil(), c.input) | ||
Expect(result.args).To(ConsistOf(c.args)) | ||
} else { | ||
Expect(result).To(BeNil(), c.input) | ||
} | ||
} | ||
}) | ||
} |