matryer / is

Professional lightweight testing mini-framework for Go.
MIT License
1.78k stars 58 forks source link

Add Helper method #33

Closed breml closed 4 years ago

breml commented 4 years ago

Helper marks the calling function as a test helper function. When printing file and line information, that function will be skipped.

Adopted from testings.Helper from the stdlib.

Related: #30

breml commented 4 years ago

The build is failing on Go 1.6.x because some of the required functions are not available:

./is.go:266: undefined: runtime.CallersFrames
./is.go:283: undefined: runtime.CallersFrames
./is.go:284: undefined: runtime.Frame

Would it be fine to remove Go 1.6.x from the list of supported versions (officially only the latest two versions of Go are supported by the Go team, currently Go 1.12.x and Go 1.13.x)?

matryer commented 4 years ago

Ha this is great.

@breml Actually we should just put the new functionality into its own file with an appropriate build tag. I know lots of people are stuck on previous releases and it'd be nice to actively support them. This worked nicely in https://github.com/matryer/httperr

breml commented 4 years ago

@matryer OK, I moved the new functionality into separate files and used appropriate build tags. Now the Helper() method is only available starting from Go 1.7.

As a drive by I also added test execution to the build pipeline in travisci.

breml commented 4 years ago

To get the tests running in travisci (including Windows and OSX) was a little bit more work than initial thought, but now I think it works as supposed.

Be aware, that Go 1.6.x on OSX is not supported by travisci. Also tip of Go for Windows is (currently?) not working on travisci. (see the exceptions in .travis.yml)

To speedup the CI pipeline I suggest to reduce number of matrix builds (e.g. only build with Go 1.6.x, 1.x and tip for OSX and Windows). I assume, this would still cover all the important cases.