Skip to content
This repository was archived by the owner on Apr 8, 2024. It is now read-only.
This repository was archived by the owner on Apr 8, 2024. It is now read-only.

Test serialization format improvements #61

@ehuss

Description

@ehuss

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

  • I find it difficult to review and compare the input and the output. Particularly with the files in separate directories, it can be cumbersome to look at them both. Ideally I would find it easier if the input and output were in the same file. Consider how to review this PR: https://github.com/rust-lang-nursery/wg-grammar/pull/38/files.

  • It does not include the tokens in the leaves, making it difficult to see what was matched.

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

  • It is rather verbose, making it difficult to see the structure.

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

  • Error tests are particularly difficult (just says "ParseError" with a long list of possible tokens). Perhaps errors could be annotated similar to compiletest where the exact location of the error is a comment below using ^ to mark the error.

  • Lexer errors don't work at all. Sometimes I think it might be useful to have tests that do not lex properly (like a.1foo).

  • I think there might be value in choosing a commonly available serialization format (or something more formal than just a debug dump). This might make it easier to be able to reuse the test suite with other parsers (creating a sort of conformance test suite). Other parsers could have an adapter which would convert their tree structure to something compatible with the lyg structure, and then compare the results with the expected test output.

    There are various other routes this could take. Such as providing a Rust library with a common tree structure other parsers could target, and the library would handle comparing test output.

  • 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.).

Metadata

Metadata

Assignees

No one assigned

    Labels

    testsIssues with the test framework

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions