forked from archseer/tree-sitter-cairo
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
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,45 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -eu | ||
|
||
cd "$(dirname "$0")/.." | ||
|
||
function clone_repo { | ||
owner=$1 | ||
name=$2 | ||
sha=$3 | ||
|
||
path=examples/$name | ||
if [ ! -d "$path" ]; then | ||
echo "Cloning $owner/$name" | ||
git clone "https://github.com/$owner/$name" "$path" | ||
fi | ||
|
||
pushd "$path" >/dev/null | ||
actual_sha=$(git rev-parse HEAD) | ||
if [ "$actual_sha" != "$sha" ]; then | ||
echo "Updating $owner/$name to $sha" | ||
git fetch | ||
git reset --hard "$sha" | ||
fi | ||
popd >/dev/null | ||
} | ||
|
||
# clone_repo starkware-libs cairo 6f71adc5af2e2d93747498e8baa5187151809b95 | ||
clone_repo starkware-libs cairo-lang 12ca9e91bbdc8a423c63280949c7e34382792067 | ||
|
||
known_failures="$(cat script/known_failures.txt)" | ||
|
||
# shellcheck disable=2046 | ||
tree-sitter parse -q \ | ||
"examples/**/*.cairo" \ | ||
$(for failure in $known_failures; do echo "!${failure}"; done) | ||
|
||
example_count=$(find examples -name "*.cairo" | wc -l) | ||
failure_count=$(wc -w <<<"$known_failures") | ||
success_count=$((example_count - failure_count)) | ||
success_percent=$(bc -l <<<"100*${success_count}/${example_count}") | ||
|
||
printf \ | ||
"Successfully parsed %d of %d example files (%.1f%%)\n" \ | ||
"$success_count" "$example_count" "$success_percent" |