From 8469a9de07c45435b61cbfd4aed7167fb9e59cca Mon Sep 17 00:00:00 2001 From: "[[ BOT ]] Lynn Cyrin" Date: Thu, 22 Aug 2019 21:42:07 -0700 Subject: [PATCH 1/5] show test failures --- build.go | 68 +++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 57 insertions(+), 11 deletions(-) diff --git a/build.go b/build.go index 2a38f8ba82..125d25f0a3 100644 --- a/build.go +++ b/build.go @@ -6,12 +6,13 @@ import ( "bufio" "bytes" "fmt" - "github.com/urfave/cli" "io/ioutil" "log" "os" "os/exec" "strings" + + "github.com/urfave/cli" ) var packages = []string{"cli", "altsrc"} @@ -52,7 +53,13 @@ func main() { } func VetActionFunc(_ *cli.Context) error { - return exec.Command("go", "vet").Run() + cmd := exec.Command("go", "vet") + + cmd.Stdin = os.Stdin + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + + return cmd.Run() } func TestActionFunc(c *cli.Context) error { @@ -67,10 +74,13 @@ func TestActionFunc(c *cli.Context) error { coverProfile := fmt.Sprintf("--coverprofile=%s.coverprofile", pkg) - err := exec.Command( - "go", "test", "-v", coverProfile, packageName, - ).Run() + cmd := exec.Command("go", "test", "-v", coverProfile, packageName) + cmd.Stdin = os.Stdin + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + + err := cmd.Run() if err != nil { return err } @@ -142,16 +152,34 @@ func GfmrunActionFunc(_ *cli.Context) error { return err } - return exec.Command("gfmrun", "-c", fmt.Sprint(counter), "-s", "README.md").Run() + cmd := exec.Command("gfmrun", "-c", fmt.Sprint(counter), "-s", "README.md") + + cmd.Stdin = os.Stdin + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + + return cmd.Run() } func TocActionFunc(_ *cli.Context) error { - err := exec.Command("node_modules/.bin/markdown-toc", "-i", "README.md").Run() + cmd := exec.Command("node_modules/.bin/markdown-toc", "-i", "README.md") + + cmd.Stdin = os.Stdin + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + + err := cmd.Run() if err != nil { return err } - err = exec.Command("git", "diff", "--exit-code").Run() + cmd = exec.Command("git", "diff", "--exit-code") + + cmd.Stdin = os.Stdin + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + + err = cmd.Run() if err != nil { return err } @@ -160,17 +188,35 @@ func TocActionFunc(_ *cli.Context) error { } func GenActionFunc(_ *cli.Context) error { - err := exec.Command("go", "generate", "flag-gen/main.go").Run() + cmd := exec.Command("go", "generate", "flag-gen/main.go") + + cmd.Stdin = os.Stdin + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + + err := cmd.Run() if err != nil { return err } - err = exec.Command("go", "generate", "cli.go").Run() + cmd = exec.Command("go", "generate", "cli.go") + + cmd.Stdin = os.Stdin + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + + err = cmd.Run() if err != nil { return err } - err = exec.Command("git", "diff", "--exit-code").Run() + cmd = exec.Command("git", "diff", "--exit-code") + + cmd.Stdin = os.Stdin + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + + err = cmd.Run() if err != nil { return err } From 29ad6ee6ad7e02dbec3334e8843bb6711c011b55 Mon Sep 17 00:00:00 2001 From: "[[ BOT ]] Lynn Cyrin" Date: Fri, 23 Aug 2019 20:09:08 -0700 Subject: [PATCH 2/5] DRY --- build.go | 64 ++++++++++++-------------------------------------------- 1 file changed, 13 insertions(+), 51 deletions(-) diff --git a/build.go b/build.go index 125d25f0a3..4572d283ba 100644 --- a/build.go +++ b/build.go @@ -52,8 +52,8 @@ func main() { } } -func VetActionFunc(_ *cli.Context) error { - cmd := exec.Command("go", "vet") +func runCmd(args ...string) error { + cmd := exec.Command(args[0], args[1:]...) cmd.Stdin = os.Stdin cmd.Stdout = os.Stdout @@ -62,6 +62,10 @@ func VetActionFunc(_ *cli.Context) error { return cmd.Run() } +func VetActionFunc(_ *cli.Context) error { + return runCmd("go", "vet") +} + func TestActionFunc(c *cli.Context) error { for _, pkg := range packages { var packageName string @@ -74,13 +78,7 @@ func TestActionFunc(c *cli.Context) error { coverProfile := fmt.Sprintf("--coverprofile=%s.coverprofile", pkg) - cmd := exec.Command("go", "test", "-v", coverProfile, packageName) - - cmd.Stdin = os.Stdin - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr - - err := cmd.Run() + err := runCmd("go", "test", "-v", coverProfile, packageName) if err != nil { return err } @@ -152,34 +150,16 @@ func GfmrunActionFunc(_ *cli.Context) error { return err } - cmd := exec.Command("gfmrun", "-c", fmt.Sprint(counter), "-s", "README.md") - - cmd.Stdin = os.Stdin - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr - - return cmd.Run() + return runCmd("gfmrun", "-c", fmt.Sprint(counter), "-s", "README.md") } func TocActionFunc(_ *cli.Context) error { - cmd := exec.Command("node_modules/.bin/markdown-toc", "-i", "README.md") - - cmd.Stdin = os.Stdin - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr - - err := cmd.Run() + err := runCmd("node_modules/.bin/markdown-toc", "-i", "README.md") if err != nil { return err } - cmd = exec.Command("git", "diff", "--exit-code") - - cmd.Stdin = os.Stdin - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr - - err = cmd.Run() + err = runCmd("git", "diff", "--exit-code") if err != nil { return err } @@ -188,35 +168,17 @@ func TocActionFunc(_ *cli.Context) error { } func GenActionFunc(_ *cli.Context) error { - cmd := exec.Command("go", "generate", "flag-gen/main.go") - - cmd.Stdin = os.Stdin - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr - - err := cmd.Run() + err := runCmd("go", "generate", "flag-gen/main.go") if err != nil { return err } - cmd = exec.Command("go", "generate", "cli.go") - - cmd.Stdin = os.Stdin - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr - - err = cmd.Run() + err = runCmd("go", "generate", "cli.go") if err != nil { return err } - cmd = exec.Command("git", "diff", "--exit-code") - - cmd.Stdin = os.Stdin - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr - - err = cmd.Run() + err = runCmd("git", "diff", "--exit-code") if err != nil { return err } From 1095838cca9d596e55cff88bcb35b67cf83bf4e4 Mon Sep 17 00:00:00 2001 From: Lynn Cyrin Date: Sat, 24 Aug 2019 00:49:29 -0700 Subject: [PATCH 3/5] check length --- build.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/build.go b/build.go index 4572d283ba..57d8432350 100644 --- a/build.go +++ b/build.go @@ -53,7 +53,12 @@ func main() { } func runCmd(args ...string) error { - cmd := exec.Command(args[0], args[1:]...) + var cmd *exec.Cmd + if len(args) > 1 { + cmd = exec.Command(args[0], args[1:]...) + } else { + cmd = exec.Command(args[0]) + } cmd.Stdin = os.Stdin cmd.Stdout = os.Stdout From c2d1a132082e3b02a219e61eeef49da364d2c315 Mon Sep 17 00:00:00 2001 From: Lynn Cyrin Date: Sat, 24 Aug 2019 03:05:45 -0700 Subject: [PATCH 4/5] Revert "check length" This reverts commit 1095838cca9d596e55cff88bcb35b67cf83bf4e4. --- build.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/build.go b/build.go index 57d8432350..4572d283ba 100644 --- a/build.go +++ b/build.go @@ -53,12 +53,7 @@ func main() { } func runCmd(args ...string) error { - var cmd *exec.Cmd - if len(args) > 1 { - cmd = exec.Command(args[0], args[1:]...) - } else { - cmd = exec.Command(args[0]) - } + cmd := exec.Command(args[0], args[1:]...) cmd.Stdin = os.Stdin cmd.Stdout = os.Stdout From d3edef887a2fc39830216cd41b16955ef60d0d3c Mon Sep 17 00:00:00 2001 From: Audrius Butkevicius Date: Sat, 24 Aug 2019 11:34:03 +0100 Subject: [PATCH 5/5] Update build.go --- build.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.go b/build.go index 4572d283ba..bd1b3cfe08 100644 --- a/build.go +++ b/build.go @@ -52,8 +52,8 @@ func main() { } } -func runCmd(args ...string) error { - cmd := exec.Command(args[0], args[1:]...) +func runCmd(arg string, args ...string) error { + cmd := exec.Command(arg, args...) cmd.Stdin = os.Stdin cmd.Stdout = os.Stdout