rust-lang / wg-grammar

Where the work of WG-grammar, aiming to provide a canonical grammar for Rust, resides
Apache License 2.0
100 stars 20 forks source link

Test serialization format improvements #61

Open ehuss opened 5 years ago

ehuss commented 5 years ago

The current snap tests which dump a debug output of the nodes have a variety of issues:

CAD97 commented 5 years ago

It seems to have some non-deterministic ordering (possibly with just the error case), making the tests fail.

Any nondeterminism is a bug in gll that needs to be fixed.

Span information is not included, making it difficult to see where things correspond.

That's on someone (probably me) to go and enable proc_macro_semver_exempt on the test runner and remove the output mangling (which currently removes the useless Span..Span labels).

Lexer errors don't work at all.

Currently we delegate to proc_macro for the lexing stage. Until that changes (we probably want a formal lexer at some point), it's probably not our purview to be testing the lexer.

I think it might be a good idea to restrict tests to certain high-level fragments of the language to make it easier to test with other parsers. I would propose sticking with macro_rules fragments as the lowest-level each test should use (that is, items, statements, expressions, paths, types, etc.).

This makes sense so long as we can continue to be able to test any weird edge cases we find. Keep in mind that we're still going to be providing more information than a yes/no answer, though.

eddyb commented 5 years ago

One thing we could do to improve error output is integrate with something like annotate-snippets-rs.