Skip to content

Implement a Formatter for Tree-Sitter Grammar Tests in Darklang #5378

Description

@OceanOak

We tried to plug tree-sitter-tests-formatter in our repository, to format tree-sitter-darklang/test/corpus test files, but decided against it due to the 1.5 GB ( for Rust) it would add to the Dockerfile

We want to write a formatter for our Tree-sitter grammar tests in Darklang

Notes:

  • Handle nested directories : not all test files are in tree-sitter-darklang/test/corpus; some are in nested directories, e.g.tree-sitter-darklang/test/corpus/exhaustive/exprs
  • maintain a consistent number of # symbols at the beginning of each test header
  • trim test names
  • keep the test case as is (no trimming no formatting)
  • have a triple hyphen (---) separator between the test case and the generated tree
  • spacing rules: two newlines after each test block, one after each title, test case, and after the triple hyphen separator
  • format the S-expression based on the following example

Example of a formatted test:

==================
boolean - true
==================

true

---

(source_file 
  (expression 
    (simple_expression 
      (bool_literal)
    )
  )
)

Misc:

  • Run the script using the cli?
  • Figure out a way to run it in CI

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions