Skip to content

Commit

Permalink
feat: add test script
Browse files Browse the repository at this point in the history
  • Loading branch information
amaanq committed Mar 8, 2023
1 parent b20a108 commit b75363e
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
Empty file added script/known_failures.txt
Empty file.
45 changes: 45 additions & 0 deletions script/parse-examples
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"

0 comments on commit b75363e

Please sign in to comment.