diff --git a/.ayi.example.yml b/.ayi.example.yml index c0f0178..4dc6122 100644 --- a/.ayi.example.yml +++ b/.ayi.example.yml @@ -1,7 +1,6 @@ debug: true test: - # FIXME: why sh is needed.... why can't just run the script - - sh ./scripts/test.sh + - sh -c "go test -v -cover $(glide novendor)" user: example-user project: name: example diff --git a/scripts/test.sh b/scripts/test.sh deleted file mode 100755 index 9cce310..0000000 --- a/scripts/test.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash - -go test -v -cover $(glide novendor) \ No newline at end of file diff --git a/util/command.go b/util/command.go index 1031c72..905b588 100644 --- a/util/command.go +++ b/util/command.go @@ -10,17 +10,12 @@ import ( // Command return a Command struct from a full commad func Command(cmd string) (*exec.Cmd, error) { + // NOTE: do not use strings.Fields or Split ! segments, err := shellquote.Split(cmd) if err != nil { return nil, errors.Wrap(err, "Cannot parse command") } name := segments[0] - // FIXME: this is not working ... - // if (name == "sh") && (segments[1] == "-c") { - // // TODO: this does not support use like go test $(glide novendor) - // fmt.Println(strings.Join(segments[2:], " ")) - // return exec.Command("sh", "-c", strings.Join(segments[2:], " ")) - // } return exec.Command(name, segments[1:]...), nil } diff --git a/util/command_test.go b/util/command_test.go index 3497132..3198a9b 100644 --- a/util/command_test.go +++ b/util/command_test.go @@ -10,10 +10,7 @@ func TestCommand(t *testing.T) { assert := assert.New(t) cmd, _ := Command("ls") assert.Equal(1, len(cmd.Args)) - // FIXME: $(glide novendor) will not be interpreted - // TODO: try sh -c "go test -v -cover $(glide novendor)" - cmd, _ = Command("go test -v -cover $(glide novendor)") - assert.Equal("test", cmd.Args[1]) + // NOTE: you must use sh -c since subshell is included cmd, _ = Command("sh -c \"go test -v -cover $(glide novendor)\"") assert.Equal("go test -v -cover $(glide novendor)", cmd.Args[2]) }