Skip to content

Commit

Permalink
Add a test suite and CI to run it
Browse files Browse the repository at this point in the history
Use the basic skeleton from the tree-sitter organization to create some tests.
Add a github CI configuration to run these tests.
  • Loading branch information
tgross35 committed Jan 3, 2024
1 parent 4e5f5f3 commit 13caefa
Show file tree
Hide file tree
Showing 5 changed files with 668 additions and 2 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
on:
workflow_dispatch:
pull_request:
push:

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install modules
run: npm install
- name: Run ESLint
run: npm run lint

test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
- run: npm install
- run: npm test
- run: tree-sitter parse test/*.just
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@ require"nvim-treesitter.install".compilers = {"gcc-11"}

Building locally:

```
```sh
# Create autogenerated files
npm run gen
# Run tests
npm run test
tree-sitter parse test/test.just
```
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"main": "grammar.js",
"scripts": {
"test": "tree-sitter test",
"gen": "tree-sitter generate"
"gen": "tree-sitter generate",
"lint": "eslint grammar.js"
},
"repository": {
"type": "git",
Expand All @@ -24,6 +25,8 @@
"tree-sitter": "^0.19.0"
},
"devDependencies": {
"eslint": "^8.51.0",
"eslint-config-google": "^0.14.0",
"tree-sitter-cli": "^0.19.3"
},
"tree-sitter": [
Expand Down
238 changes: 238 additions & 0 deletions test/corpus/recipes.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,238 @@
================================================================================
recipe
================================================================================

foo:
body

--------------------------------------------------------------------------------

(source_file
(item
(eol
(NEWLINE)))
(item
(recipe
(recipeheader
(NAME))
(NEWLINE)
(body
(INDENT)
(recipe_body
(line
(recipeline
(notcomment)
(NEWLINE))))
(MISSING DEDENT)))))

================================================================================
quiet
================================================================================

@foo:
body

--------------------------------------------------------------------------------

(source_file
(item
(eol
(NEWLINE)))
(item
(recipe
(recipeheader
(NAME))
(NEWLINE)
(body
(INDENT)
(recipe_body
(line
(recipeline
(notcomment)
(NEWLINE))))
(MISSING DEDENT)))))

================================================================================
dependencies
================================================================================

foo: bar baz
body

--------------------------------------------------------------------------------

(source_file
(item
(eol
(NEWLINE)))
(item
(recipe
(recipeheader
(NAME)
(dependencies
(dependency
(NAME))
(dependency
(NAME))))
(NEWLINE)
(body
(INDENT)
(recipe_body
(line
(recipeline
(notcomment)
(NEWLINE))))
(MISSING DEDENT)))))

================================================================================
arguments
================================================================================

foo bar *baz:
body

--------------------------------------------------------------------------------

(source_file
(item
(eol
(NEWLINE)))
(item
(recipe
(recipeheader
(NAME)
(parameters
(parameter
(NAME))
(variadic_parameters
(parameter
(NAME)))))
(NEWLINE)
(body
(INDENT)
(recipe_body
(line
(recipeline
(notcomment)
(NEWLINE))))
(MISSING DEDENT)))))

================================================================================
dependency expression
================================================================================

foo +bar: baz(bar)
body

--------------------------------------------------------------------------------

(source_file
(item
(eol
(NEWLINE)))
(item
(recipe
(recipeheader
(NAME)
(parameters
(parameter
(MISSING NAME))
(variadic_parameters
(parameter
(NAME))))
(dependencies
(dependency
(NAME))
(dependency
(depcall
(NAME)))))
(NEWLINE)
(body
(INDENT)
(recipe_body
(line
(recipeline
(notcomment)
(NEWLINE))))
(MISSING DEDENT)))))

================================================================================
attribute FIXME(attributes): XFAIL no attribute support
================================================================================

[attribute]
foo:
body

--------------------------------------------------------------------------------

(source_file
(item
(eol
(NEWLINE)))
(ERROR
(INDENT)
(NAME))
(item
(eol
(NEWLINE)))
(item
(recipe
(recipeheader
(NAME))
(NEWLINE)))
(ERROR
(NAME))
(item
(eol
(NEWLINE))))


================================================================================
shebang
================================================================================

foo:
#!/bin/sh
if [ -f "foo" ]; then
echo "foo {{var}}"
fi

--------------------------------------------------------------------------------

(source_file
(item
(eol
(NEWLINE)))
(item
(recipe
(recipeheader
(NAME))
(NEWLINE)
(body
(INDENT)
(shebang_recipe
(shebang
(TEXT)
(NEWLINE))
(shebang_body
(line
(recipeline
(notcomment)
(TEXT)
(TEXT)
(TEXT)
(TEXT)
(TEXT)
(NEWLINE)))
(line
(recipeline
(notcomment)
(TEXT)
(TEXT)
(NEWLINE)))
(line
(recipeline
(notcomment)
(NEWLINE)))))
(DEDENT)))))
Loading

0 comments on commit 13caefa

Please sign in to comment.