Conversation
bbfabcf to
03ad9d1
Compare
purpleidea
left a comment
There was a problem hiding this comment.
Patch is looking good, however we need to call this something different than lint. Ideas?
| failures='' | ||
|
|
||
| # lint .mcl examples | ||
| for file in $(find examples/lang/ -maxdepth 3 -type f -name '*.mcl'); do |
There was a problem hiding this comment.
I'm really pleased you added a test for this, because I was thinking we needed this :)
examples/lang/syntaxerror.mcl.txt
Outdated
| @@ -0,0 +1,4 @@ | |||
| # this file generates a syntax error, used in lib/cli_test.go | |||
| file "/tmp/mgmt" { | |||
| content => "test" # missing trailing comma | |||
There was a problem hiding this comment.
tab for indentation, unless your point was that spaces should be a compile error ;)
There was a problem hiding this comment.
That would be a good point :)
lib/cli_test.go
Outdated
| "github.com/urfave/cli" | ||
| ) | ||
|
|
||
| func TestLintPass(t *testing.T) { |
There was a problem hiding this comment.
what's going on in these two?
lang/lang.go
Outdated
| } | ||
|
|
||
| func (obj *Lang) Lint() error { | ||
| _, err := LexParse(obj.Input) |
There was a problem hiding this comment.
This is actually the part which needs the most work... You probably want all of these to run:
https://github.com/purpleidea/mgmt/blob/master/docs/language-guide.md#stages
With the exception of actually running the function engine. All of those are needed to ascertain if a compile is successful.
4b219a4 to
6f7dbd2
Compare
faf5def to
71436a1
Compare
purpleidea
left a comment
There was a problem hiding this comment.
Most of this patch is good. I've got to step back and think about if the refactor into compile is what we want. Please fixup these issues and I'll think about the refactor.
Thanks!
examples/lang/bad/scopeerror.mcl
Outdated
| @@ -0,0 +1,3 @@ | |||
| # this file generates a scope error, used in lib/cli_test.go | |||
There was a problem hiding this comment.
all "bad" things should be in test/ dir, not easy to find in examples/
in fact, the real tests should have nothing to do with examples/
I have a test case that tests examples just to make sure the examples we submit aren't actually junk, but the real testing should happen in test/
examples/lang/bad/syntaxerror.mcl
Outdated
| @@ -0,0 +1,4 @@ | |||
| # this file generates a syntax error, used in lib/cli_test.go | |||
There was a problem hiding this comment.
let's not refer to a specific file like this
| @@ -0,0 +1,2 @@ | |||
| # this file generates a unification error, used in lib/cli_test.go | |||
There was a problem hiding this comment.
okay, however why not write this as a test in unification_test.go instead?
There was a problem hiding this comment.
i want to test validate is able to detect a unification error, not that this file generates a unification error per se.
lang/gapi.go
Outdated
| } | ||
|
|
||
| // validate syntax before deploying | ||
| filecontent, err := ioutil.ReadFile(s) |
lang/gapi.go
Outdated
| obj := &Lang{ | ||
| Input: code, | ||
| Logf: func(format string, v ...interface{}) { | ||
| log.Printf(Name+": funcs: "+format, v...) |
There was a problem hiding this comment.
probably a copy paste error i overlooked
| // read through this local path, and store it in our file system | ||
| // since our deploy should work anywhere in the cluster, let the | ||
| // engine ensure that this file system is replicated everywhere! | ||
|
|
There was a problem hiding this comment.
why is this line missing?
if there's a reason, okay, but it sends the message you don't review your diffs before submitting.
the goal should be for me to see your patch and say "perfect, merged" :)
There was a problem hiding this comment.
must have slipped past
lib/cli_test.go
Outdated
| files := []struct { | ||
| path string | ||
| }{ | ||
| {"../examples/lang/bad/syntaxerror.mcl"}, |
There was a problem hiding this comment.
no ../ paths please and no references to examples/ in our code.
we need to think of a better way to get the code in. i'd actually prefer to just inline it for now. see:
https://github.com/purpleidea/mgmt/blob/master/lang/lexparse_test.go#L93
7294036 to
2f67d1b
Compare
#313
Todo: