darklang / darklang/dark

Implement a Formatter for Tree-Sitter Grammar Tests in Darklang

Open
#5,378 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
F#
Stars
2.2k
Forks
115
Avg merge
17h 28m
Merged PRs (30d)
50

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the test files under tree-sitter-darklang/test/corpus, including nested directories such as exhaustive/exprs, and compare them with the formatted example in the issue. Define the formatter's CLI and CI entry points, then verify that headers, spacing, separators, test-case text, and S-expressions follow the stated rules across all corpus files.

Written by the indexing model from the issue text.

Assessment

Tech stack
fsharp
Domain
testing-qa, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.