mirror of
https://github.com/magefile/mage.git
synced 2026-10-24 06:19:18 +03:00
* Helpers galore This commit adds helper functions that should be commonly needed by many magefiles. It includes command execution handlers as well as error handlers. This commit also removes the only two non-stdlib dependencies in the codebase. Since mage will likely be vendored into a repo, it would be nice to avoid cluttering the vendor directory with dependencies that are only for the build script.
35 lines
658 B
Go
35 lines
658 B
Go
package parse
|
|
|
|
import (
|
|
"reflect"
|
|
"testing"
|
|
)
|
|
|
|
func TestParse(t *testing.T) {
|
|
info, err := Package("./testdata", []string{"func.go", "command.go"})
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
expected := PkgInfo{
|
|
Funcs: []Function{
|
|
{
|
|
Name: "ReturnsError",
|
|
IsError: true,
|
|
Comment: "Synopsis for returns error.\nAnd some more text.\n",
|
|
Synopsis: "Synopsis for returns error.",
|
|
},
|
|
{
|
|
Name: "ReturnsVoid",
|
|
},
|
|
},
|
|
DefaultIsError: true,
|
|
DefaultName: "ReturnsError",
|
|
}
|
|
|
|
// TODO: Don't use DeepEqual, you lazy git!
|
|
if !reflect.DeepEqual(expected, *info) {
|
|
t.Fatalf("expected:\n%#v\n\ngot:\n%#v", expected, *info)
|
|
}
|
|
}
|