This repository was archived by the owner on Sep 9, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 162
Expand file tree
/
Copy pathrun
More file actions
executable file
·57 lines (49 loc) · 1.29 KB
/
run
File metadata and controls
executable file
·57 lines (49 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env sh
set -eu
dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
error() {
echo "Error: $1" 1>&2
}
usage() {
echo "Usage: $0 [-h|--help] [-V|--save-visualization] [EXAMPLE_DIR]"
}
py_pkg="tree-sitter-python@0.20.1"
py_dir="$dir/.$py_pkg"
if [ ! -e "$py_dir" ]; then
echo "Missing Python grammar. Run bootstrap script to install."
exit 1
fi
tssg_opts="--output-mode=always"
example_dir="."
while [ $# -gt 0 ]; do
arg="$1"
shift 1
case "$arg" in
-h|--help)
usage
exit 0
;;
-V|--save-visualization)
tssg_opts="$tssg_opts -V=%r/%d/%n.html"
;;
*)
example_dir="$arg"
if [ $# -gt 0 ]; then
error "Too many positional arguments provided."
usage 1>&2
exit 1
fi
;;
esac
done
tsg_file="$example_dir/stack-graphs.tsg"
tests_dir="$example_dir/tests"
if [ ! -e "$tsg_file" ]; then
error "Missing TSG file $tsg_file. Is $example_dir not an example directory?"
exit 1
fi
if [ ! -e "$tests_dir" ]; then
error "Missing directory $tests_dir. Is $example_dir not an example directory?"
exit 1
fi
cargo -q run --features=cli -- test $tssg_opts --grammar "$py_dir" --tsg "$tsg_file" "$tests_dir"