smartystreets / goconvey

Go testing in the browser. Integrates with `go test`. Write behavioral tests in Go.
http://smartystreets.github.io/goconvey/
Other
8.25k stars 555 forks source link

Getting a 'not defined: -json' error using Go v1.5 #361

Open lcaballero opened 9 years ago

lcaballero commented 9 years ago

I've looked around for a fix for this but the solutions I've seen suggest upgrading Go to 1.2+. I was never on 1.2, but I am seeing this in 1.5 now. I've commented out a few lines where the -json flag is being added and things run normally (as a quick work around in shell.go). But, I don't completely understand the solution, and may have opened the door for other issues.

mdwhatcott commented 9 years ago

Hmm. It might be helpful to see console output...

Just curious, did you run go install github.com/smartystreets/goconvey after upgrading to go 1.5? If not, try doing that and see if that resolves the issue.

lcaballero commented 9 years ago

Here's a bit of the console

015/10/29 22:07:48 shell.go:102: Coverage output: ?     myproj/test_helpers [no test files]
2015/10/29 22:07:48 shell.go:104: Run without coverage
2015/10/29 22:07:48 shell.go:102: Coverage output: ?    myproj/tools    [no test files]
2015/10/29 22:07:48 shell.go:104: Run without coverage
2015/10/29 22:07:51 shell.go:102: Coverage output: flag provided but not defined: -json
Usage of /var/folders/m2/xxhtw5612zq8gznj2077mg5chbqp3b/T/go-build689486213/myproj/entry/_test/entry.test:
  -service string
        -service=name #this name should be the same name as the service name (default "unknown")
  -test.bench string
        regular expression to select benchmarks to run
  -test.benchmem
        print memory allocations for benchmarks
  -test.benchtime duration
        approximate run time for each benchmark (default 1s)

... further down ...

exit status 2
FAIL    myproj/entry    0.059s
2015/10/29 22:07:51 shell.go:104: Run without coverage
2015/10/29 22:07:51 shell.go:102: Coverage output: ?    myproj  [no test files]
2015/10/29 22:07:51 shell.go:104: Run without coverage
2015/10/29 22:07:54 parser.go:24: [failed]: myproj/entry
Potential error parsing output of myproj/entry ; couldn't handle this stray line: flag provided but not defined: -json
Potential error parsing output of myproj/entry ; couldn't handle this stray line: Usage of /var/folders/m2/xxhtw5612zq8gznj2077mg5chbqp3b/T/go-build280812813/myproj/entry/_test/entry.test:
Potential error parsing output of myproj/entry ; couldn't handle this stray line:   -service string
Potential error parsing output of myproj/entry ; couldn't handle this stray line:       -service=name #this name should be the same name as the service name (default "unknown")
Potential error parsing output of myproj/entry ; couldn't handle this stray line:   -test.bench string

After further investigation it appears that it might be related to my seelog.xml file settings. I'm using an asynctimer setting and that interleaves output from some logging called in init() methods in libs I'm pulling in? But, that only makes sense if those calls are output to the stream that goconvey is parsing, which doesn't seem right exactly.

mdwhatcott commented 9 years ago

Well, I'm not sure what's going on. Is there any way you can provide a sample that causes the bad behavior? Maybe a public github repo I could clone and run?

lcaballero commented 9 years ago

I'll try to reproduce in a public repo (in the next few days). I would have started there, but felt I wouldn't have luck reproducing it outside of my current project. My hope was that it would be a trivial thing like "oh, we ran into that and here is the solution." I can see now that it's more involved than that.

Nainterceptor commented 8 years ago

Hi guys,

On this project https://github.com/Nainterceptor/4PJT-MewPipe, I have this issue ;)

On a smaller PoC : https://github.com/Nainterceptor/MiniProject-Ping/

mdwhatcott commented 8 years ago

Hmm. Thanks for the example @Nainterceptor . I pulled it down and tried to build the test binary for the entities package with go test -o. Sure enough, it was missing the goconvey flags (-json, -silent, etc...) that should be added in as a result of importing the convey package. Here's a terminal session in the examples package of the goconvey project that illustrates the flags being added correctly:

Last login: Mon Jan 18 09:51:13 on ttys001

mike@Michael:~

 • cd github.com/smartystreets/goconvey/examples
/Users/mike/src/github.com/smartystreets/goconvey/examples

mike@Michael:~/src/github.com/smartystreets/goconvey/examples [master ?]

 • go test -o examples
.............
13 total assertions

........
21 total assertions

.........
30 total assertions

........
38 total assertions

....
42 total assertions

....
46 total assertions

..........
56 total assertions

.....
61 total assertions

....
65 total assertions

PASS
ok      github.com/smartystreets/goconvey/examples  0.007s

mike@Michael:~/src/github.com/smartystreets/goconvey/examples [master ?]

 • ./examples -help
Usage of ./examples:
  -json
        When true, emits results in JSON blocks. Default: 'false'
  -silent
        When true, all output from GoConvey is suppressed.
  -story
        When true, emits story output, otherwise emits dot output. When not provided, this flag mirros the value of the '-test.v' flag
  -test.bench string
        regular expression to select benchmarks to run
  -test.benchmem
        print memory allocations for benchmarks
  -test.benchtime duration
        approximate run time for each benchmark (default 1s)
  -test.blockprofile string
        write a goroutine blocking profile to the named file after execution
  -test.blockprofilerate int
        if >= 0, calls runtime.SetBlockProfileRate() (default 1)
  -test.count n
        run tests and benchmarks n times (default 1)
  -test.coverprofile string
        write a coverage profile to the named file after execution
  -test.cpu string
        comma-separated list of number of CPUs to use for each test
  -test.cpuprofile string
        write a cpu profile to the named file during execution
  -test.memprofile string
        write a memory profile to the named file after execution
  -test.memprofilerate int
        if >=0, sets runtime.MemProfileRate
  -test.outputdir string
        directory in which to write profiles
  -test.parallel int
        maximum test parallelism (default 8)
  -test.run string
        regular expression to select tests and examples to run
  -test.short
        run smaller test suite to save time
  -test.timeout duration
        if positive, sets an aggregate time limit for all tests
  -test.trace string
        write an execution trace to the named file after execution
  -test.v
        verbose: print additional output

mike@Michael:~/src/github.com/smartystreets/goconvey/examples [master ?]

 • 

Basically, I'm not sure why those flags aren't being added in for this case.

rootscity commented 8 years ago

FWIW, I had this problem as well. Upgrading to go 1.6, re-installing goconvey, and clearing the tmp directory solved it.

robwithhair commented 8 years ago

I had this problem. Running go install github.com/smartystreets/goconvey on 1.6.2 fixed it for me