Skip to content
This repository has been archived by the owner on Feb 24, 2024. It is now read-only.

Commit

Permalink
Allow for testing a single package
Browse files Browse the repository at this point in the history
Fixes #907
  • Loading branch information
arschles authored and markbates committed Feb 9, 2018
1 parent d320864 commit 98a27a5
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions buffalo/cmd/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func testRunner(args []string) error {
}

if !runFlag {
pkgs, err := testPackages()
pkgs, err := testPackages(args)
if err != nil {
return errors.WithStack(err)
}
Expand All @@ -115,7 +115,7 @@ func mFlagRunner(args []string) error {
pwd, _ := os.Getwd()
defer os.Chdir(pwd)

pkgs, err := testPackages()
pkgs, err := testPackages(args)
if err != nil {
return errors.WithStack(err)
}
Expand All @@ -139,7 +139,14 @@ func mFlagRunner(args []string) error {
return nil
}

func testPackages() ([]string, error) {
func testPackages(givenArgs []string) ([]string, error) {
// If there are args, then assume these are the packages to test.
//
// Instead of always returning all packages from 'go list ./...', just
// return the given packages in this case
if len(givenArgs) > 0 {
return givenArgs, nil
}
args := []string{}
out, err := exec.Command(envy.Get("GO_BIN", "go"), "list", "./...").Output()
if err != nil {
Expand All @@ -159,7 +166,6 @@ func newTestCmd(args []string) *exec.Cmd {
if _, err := exec.LookPath("gotest"); err == nil {
cmd = exec.Command("gotest", "-p", "1")
}
cmd.Args = append(cmd.Args, args...)
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
Expand Down

0 comments on commit 98a27a5

Please sign in to comment.