forked from IndianBoy42/tree-sitter-just
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add parse and highlight tests for all files
- Loading branch information
Showing
3 changed files
with
197 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
# List all recipes | ||
default: | ||
just --list | ||
|
||
# Run deno lint | ||
lint: | ||
deno lint | ||
|
||
alias fmt := format | ||
|
||
# Run deno format | ||
format: | ||
deno fmt | ||
|
||
# Run tests that are built into tree-sitter | ||
test-ts: | ||
npm test | ||
|
||
# Verify that tree-sitter can parse and highlight all files in the repo. Requires a tree-sitter configuration. | ||
test-parse-highlight: | ||
#!/bin/sh | ||
set -eaux | ||
|
||
echo '::group::Parse and highlight testing' | ||
# skip readme.just because it is broken but works for testing | ||
find {{justfile_directory()}} -type f -iregex '.*[\./]just[^\./]*' | | ||
grep -v readme.just | | ||
while read -r fname | ||
do | ||
echo "::notice:: checking parsing of $fname" | ||
npx tree-sitter parse "$fname" | ||
echo "::notice:: checking highlight of $fname" | ||
npx tree-sitter highlight "$fname" | ||
done | ||
echo '::endgroup::' | ||
|
||
# Run all test options | ||
test: test-ts test-parse-highlight | ||
|
||
# Check C files with more strict arguments | ||
check-c: | ||
#!/bin/sh | ||
set -eaux | ||
|
||
find src/ -name '*.c' ! -name "parser.c" | | ||
xargs -IFNAME sh -c \ | ||
'echo && echo "::notice:: checking file FNAME"' && | ||
clang FNAME -c -Wall -Werror --pedantic \ | ||
-Wno-format-pedantic \ | ||
-o/dev/null' | ||
# Verify that the `just` tool parses all files we are using | ||
verify-just-parsing: | ||
#!/bin/sh | ||
set -eaux | ||
# skip readme.just because it is broken but works for testing | ||
find . -type f -iregex '.*[\./]just[^\./]*' | | ||
grep -v readme.just | | ||
while read -r fname | ||
do | ||
echo "::notice file=$fname:: checking Just parsing" | ||
just --list --unstable --justfile "$fname" | ||
done | ||
# Make sure that no tests contain errors | ||
verify-no-error-tests: | ||
! grep -nr -C4 -E '(ERROR|MISSING|UNEXPECTED)' test | ||
# Configure tree-sitter to use this directory | ||
configure-tree-sitter: | ||
#!/usr/bin/env python3 | ||
import json | ||
import os | ||
import subprocess as sp | ||
cfg_fname = """{{ config_directory() / "tree-sitter" / "config.json" }}""" | ||
if not os.path.isfile(cfg_fname): | ||
sp.run(["npx", "tree-sitter", "init-config"], check=True) | ||
with open(cfg_fname, "r+") as f: | ||
s = json.loads(f.read()) | ||
f.seek(0) | ||
# Add this directory to the config file | ||
parent_dir = os.path.dirname("{{ justfile_directory() }}") | ||
s["parser-directories"].append(parent_dir) | ||
f.write(s.dumps()) | ||
f.truncate() | ||
# Run lint and check formatting | ||
ci-codestyle: | ||
deno lint | ||
deno fmt --check | ||
# Make sure that files have not changed | ||
ci-validate-generated-files: | ||
#!/bin/sh | ||
set -eaux | ||
git tag ci-tmp-pre-updates | ||
npm run gen | ||
failed=false | ||
git diff ci-tmp-pre-updates --exit-code || failed=true | ||
if ! [ "$failed" = "false" ]; then | ||
echo '::warning::Generated files are out of date!' | ||
echo '::warning::run `npm run gen` and commit the changes' | ||
fi | ||
git tag -d ci-tmp-pre-updates |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
alias b := build | ||
alias c := check | ||
alias dr := dry-run | ||
alias sw := switch | ||
alias t := test | ||
alias u := update | ||
alias ui := update-input | ||
|
||
rebuildArgs := "--verbose" | ||
rebuild := if os() == "macos" { "darwin-rebuild" } else { "nixos-rebuild" } | ||
|
||
default: | ||
@just --choose | ||
|
||
[private] | ||
rebuild subcmd: | ||
{{ rebuild }} {{ subcmd }} {{ rebuildArgs }} --flake . | ||
|
||
build: (rebuild "build") | ||
|
||
dry-run: (rebuild "dry-run") | ||
|
||
switch: (rebuild "switch") | ||
|
||
test: (rebuild "test") | ||
|
||
ci: | ||
nix run \ | ||
--inputs-from . \ | ||
--override-input nixpkgs nixpkgs \ | ||
github:Mic92/nix-fast-build -- \ | ||
--no-nom \ | ||
--skip-cached \ | ||
--option accept-flake-config true \ | ||
--option allow-import-from-derivation false \ | ||
--flake '.#hydraJobs' | ||
|
||
check: | ||
nix flake check \ | ||
--print-build-logs \ | ||
--show-trace \ | ||
--accept-flake-config | ||
|
||
update: | ||
nix flake update | ||
|
||
update-input input: | ||
nix flake lock \ | ||
--update-input {{ input }} \ | ||
--commit-lock-file \ | ||
--commit-lockfile-summary "flake: update {{ input }}" | ||
|
||
deploy system: | ||
nix run \ | ||
--inputs-from . \ | ||
'nixpkgs#deploy-rs' -- \ | ||
-s '.#{{ system }}' | ||
|
||
deploy-all: | ||
nix run \ | ||
--inputs-from . \ | ||
'nixpkgs#deploy-rs' -- -s | ||
|
||
clean: | ||
rm -rf \ | ||
result* \ | ||
repl-result-out* \ | ||
config.tf.json \ | ||
.terraform* |