From 826804e6f0f120411bb76d5d77425868bccb118b Mon Sep 17 00:00:00 2001 From: Ahmet Alp Balkan Date: Thu, 18 Aug 2016 16:04:35 -0700 Subject: [PATCH] Fix 'govvv list', add regression test Signed-off-by: Ahmet Alp Balkan --- integration-test/test.bats | 6 ++++++ main.go | 10 +++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/integration-test/test.bats b/integration-test/test.bats index d8e5be3..cebdde7 100644 --- a/integration-test/test.bats +++ b/integration-test/test.bats @@ -40,6 +40,12 @@ [[ "$output" =~ ^-X\ .* ]] } +@test "govvv list" { + run govvv list ./integration-test/app-empty + echo "$output" + [ "$status" -eq 0 ] +} + @test "govvv build - program with no compile-time variables" { tmp="${BATS_TMPDIR}/a.out" run govvv build -o "$tmp" ./integration-test/app-empty diff --git a/main.go b/main.go index d28ba1f..527050b 100644 --- a/main.go +++ b/main.go @@ -47,9 +47,13 @@ func main() { fmt.Print(ldflags) return } - args, err = addLdFlags(args[1:], ldflags) - if err != nil { - log.Fatalf("failed to add ldflags to args: %v", err) + args = args[1:] // rm executable name + + if args[0] == "build" || args[0] == "install" { + args, err = addLdFlags(args, ldflags) + if err != nil { + log.Fatalf("failed to add ldflags to args: %v", err) + } } if findArg(args, flDryRun) != -1 {