Permalink
Browse files

goveralls command doesn't accept TOKEN nor packages arguments

  • Loading branch information...
1 parent 619dd4e commit 0211c7c50cc29944025d86d538d9ccf3adf0a674 @haya14busa haya14busa committed Sep 12, 2016
Showing with 20 additions and 4 deletions.
  1. +5 −2 goveralls.go
  2. +15 −2 goveralls_test.go
View
@@ -47,7 +47,7 @@ var (
var usage = func() {
cmd := os.Args[0]
// fmt.Fprintf(os.Stderr, "Usage of %s:\n", cmd)
- s := "Usage: %s [options] TOKEN\n"
+ s := "Usage: %s [options]\n"
fmt.Fprintf(os.Stderr, s, cmd)
flag.PrintDefaults()
}
@@ -123,7 +123,6 @@ func getCoverage() ([]*SourceFile, error) {
args = append(args, "-v")
}
args = append(args, line)
- args = append(args, flag.Args()...)
cmd.Args = args
b, err := cmd.CombinedOutput()
if err != nil {
@@ -179,6 +178,10 @@ func process() error {
//
flag.Usage = usage
flag.Parse()
+ if len(flag.Args()) > 0 {
+ flag.Usage()
+ os.Exit(1)
+ }
//
// Setup PATH environment variable
View
@@ -24,6 +24,20 @@ func TestUsage(t *testing.T) {
}
}
+func TestInvalidArg(t *testing.T) {
+ tmp := prepareTest(t)
+ defer os.RemoveAll(tmp)
+ cmd := exec.Command("goveralls", "pkg")
+ b, err := cmd.CombinedOutput()
+ if err == nil {
+ t.Fatal("Expected exit code 1 bot 0")
+ }
+ s := strings.Split(string(b), "\n")[0]
+ if !strings.HasPrefix(s, "Usage: goveralls ") {
+ t.Fatalf("Expected %v, but %v", "Usage: ", s)
+ }
+}
+
func TestGoveralls(t *testing.T) {
wd, _ := os.Getwd()
tmp := prepareTest(t)
@@ -44,8 +58,7 @@ func TestGoveralls(t *testing.T) {
func prepareTest(t *testing.T) (tmpPath string) {
tmp := os.TempDir()
tmp = filepath.Join(tmp, uuid.New())
- os.Setenv("GOPATH", tmp)
- runCmd(t, "go", "get", "github.com/mattn/goveralls")
+ runCmd(t, "go", "build", "-o", filepath.Join(tmp, "bin", "goveralls"), "github.com/mattn/goveralls")
os.Setenv("PATH", filepath.Join(tmp, "bin")+string(filepath.ListSeparator)+os.Getenv("PATH"))
os.MkdirAll(filepath.Join(tmp, "src"), 0755)
return tmp

0 comments on commit 0211c7c

Please sign in to comment.