Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testing: Tests with cover option fail because of syntax error, tests without coverage are passing #10250

Closed
mrfuxi opened this issue Mar 25, 2015 · 1 comment

Comments

Projects
None yet
4 participants
@mrfuxi
Copy link

commented Mar 25, 2015

Go version go1.4.1 linux/amd64

When looping over channel without actually looking at value cover is reporting error:

expected operand, found 'range' (and 1 more errors)

However app runs fine and tests without coverage are passing correctly.

Console

$ go test
PASS
ok      _/home/fuxi/test    0.003s

$ go test -cover
# cover _/path/test
2015/03/25 22:45:53 cover: /path/test/main.go: /path/test/main.go:10:9: expected operand, found 'range' (and 1 more errors)
FAIL    _/path/test [build failed]

Code to reproduce:

  • main.go
package main

import (
    "fmt"
    "time"
)

func main() {
    t := time.NewTicker(time.Duration(time.Second))
    for range t.C {
        fmt.Println("Exec")
    }
}
  • main_test.go
package main

import "testing"

func TestMain(t *testing.T) {}
@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

commented Mar 25, 2015

I think you need to reinstall your cover program.

go get -u golang.org/x/tools/cmd/cover

@minux minux closed this Mar 25, 2015

@mikioh mikioh changed the title Tests with cover option fail because of syntax error, tests without coverage are passing testing: Tests with cover option fail because of syntax error, tests without coverage are passing Mar 25, 2015

@golang golang locked and limited conversation to collaborators Jun 25, 2016

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.