Conversation
using `t.Run` instead including the test name in error message is a more idiomatic way of testing things in go. Since this feature was added to go in 1.7 release and the travis config explicitly specifies 1.4 and 1.5 (2 and 2,5 year old releases) as test targets this change will break the CI builds, therefore this commit also proposes dropping those releases in favour of adding a newer version of go (1.8) as the test target. Signed-off-by: Sevki <s@sevki.org>
since non of the test cases actually use the err string field and the golden file testing pattern does not really need it, this commit proposes the removal of the errString field from tests Signed-off-by: Sevki <s@sevki.org>
this commit proposes using a file based golden tests approach, parts of this refactor uses code and conventions from the go std library. At it's current state go-jsonnet does not support many of the examples on http://jsonnet.org/docs/demo.html, motive behind the refactor is to add the demo examples to the test suite and the demo examples are too big to be inlined. Signed-off-by: Sevki <s@sevki.org>
|
to follow the std library conventions some of the test logic and code has been "borrowed" from the std library, as I am not a lawyer I don't know if it violates the license agreement of go or go-jsonnet. If they are problematic I'm happy to do a rewrite of the offending code. |
|
Thanks again. Stan is working full time on developing go-jsonnet. Why don't we bring you in on our plans? We'd be very happy to work closely with you on this. ksonnet slack might be a good place to sync up. This is a good start on improving end-to-end testing. For testing going forward, it'd be great to have:
|
What do you think? |
|
This looks like a step in good direction. Thank you! Here is more info if you're interested:
Yeah. Majority of language features are still missing and I'm working on changing that. There's an uncomfortably large PR (#24) that adds most missing language features - but there's much more work left to do. It's currently possible to run tests from C++ version (tests.sh). It also uses a golden files pattern (take a look: https://github.com/google/jsonnet/tree/master/test_suite). It also runs all the examples from the website. Ideally we would have one way to run end2end tests against any implementation and one common, unified test suite. And as the test suite logic gets more complex having it implemented in Go seems like a better option than bash we have now. There are a few reasons why we have these tests in go version: As you can see, none of these is a fundamental problem. There are also some other practical problems with tests: Note: What I said applies to end2end tests. We also have tests for specific components, but that's a different discussion. |
|
(uh, apparently I had some race condition with @sparkprime, but it seems our message is mostly consistent :-)). |
main_test.go
Outdated
| } | ||
| } | ||
|
|
||
| // "barrowed" from the std library |
There was a problem hiding this comment.
s/barrowed/borrowed
Can you add to the top of this file, underneath the existing copyright notice, the Go one: https://github.com/golang/go/blob/master/LICENSE
If we substantially rewrite it then we can remove it later.
There was a problem hiding this comment.
Or alternatively, move the diff code into its own file and use that copyright header for it.
There was a problem hiding this comment.
@sparkprime how would you feel about adding a library that does the diffing?
since it's in the tests, it's not a dependency and it would look nicer and would resolve the license issue
deps:
Details
sevki@sevki-ThinkPad-X220:~/code/go/src/github.com/google/go-jsonnet$ go list -f '{{ join .Imports "\n" }}'
bytes
encoding/hex
fmt
math
reflect
sort
strconv
strings
unicode/utf8
sevki@sevki-ThinkPad-X220:~/code/go/src/github.com/google/go-jsonnet$ go list -f '{{ join .Deps "\n" }}'
bytes
encoding/hex
errors
fmt
internal/cpu
internal/poll
internal/race
io
math
os
reflect
runtime
runtime/internal/atomic
runtime/internal/sys
sort
strconv
strings
sync
sync/atomic
syscall
time
unicode
unicode/utf8
unsafe
There was a problem hiding this comment.
FYI for pretty diffs, we're using git diff in C++/bash version.
Can you post a link to this lib?
There was a problem hiding this comment.
yup. this one https://github.com/sergi/go-diff/
There was a problem hiding this comment.
A library to do it sounds good to me. It removes the unix dependency (hopefully).
There was a problem hiding this comment.
yeah, there is that :)
the proposed change would remove the dependency of a diff binary in favour of using a library Signed-off-by: Sevki <s@sevki.org>
|
LGTM, ready to go? |
|
I'm good, if you guys want to move forward with this |

many of the demo examples on jsonnet.org do not evaluate, this PR proposes
switching the test style from a table driven tests approach to the golden files
technique that more closely mirrors the behavior of the standard library so
demo examples can be added to the test suite when go-jsonnet reaches
parity with it's c++ counterpart or earlier for individuals wanting to use a
test driven development approach.