-
Notifications
You must be signed in to change notification settings - Fork 54
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
3 changed files
with
145 additions
and
94 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 |
---|---|---|
@@ -1,39 +1,47 @@ | ||
#!/bin/bash | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
set -eu | ||
|
||
cd "$(dirname "$0")/.." | ||
|
||
function checkout_at() { | ||
path="examples/$1" | ||
url=$2 | ||
sha=$3 | ||
|
||
if [ ! -d "$path" ]; then | ||
git clone "https://github.com/$url" "$path" | ||
fi | ||
|
||
pushd "$path" | ||
git fetch && git reset --hard "$sha" | ||
popd | ||
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 | ||
} | ||
|
||
checkout_at "laravel" "laravel/laravel" "9d0862b3340c8243ee072afc181e315ffa35e110" | ||
checkout_at "phabricator" "phacility/phabricator" "d0b01a41f2498fb2a6487c2d6704dc7acfd4675f" | ||
checkout_at "phpunit" "sebastianbergmann/phpunit" "5e523bdc7dd4d90fed9fb29d1df05347b3e7eaba" | ||
checkout_at "WordPress" "WordPress/WordPress" "45286c5bb3f6fe5005567903ec858d87077eae2c" | ||
clone_repo laravel laravel 9d0862b3340c8243ee072afc181e315ffa35e110 | ||
clone_repo phacility phabricator d0b01a41f2498fb2a6487c2d6704dc7acfd4675f | ||
clone_repo sebastianbergmann phpunit 5e523bdc7dd4d90fed9fb29d1df05347b3e7eaba | ||
clone_repo WordPress WordPress 45286c5bb3f6fe5005567903ec858d87077eae2c | ||
|
||
known_failures="$(cat script/known-failures.txt)" | ||
known_failures=$(cat script/known-failures.txt) | ||
|
||
# shellcheck disable=2046 | ||
tree-sitter parse -q \ | ||
'examples/**/*.php' \ | ||
$(for file in $known_failures; do echo "!${file}"; done) | ||
examples/**/*.php \ | ||
$(for file in $known_failures; do echo "!${file}"; done) | ||
|
||
example_count=$(find examples -name '*.php' | wc -l) | ||
failure_count=$(wc -w <<< "$known_failures") | ||
success_count=$(( $example_count - $failure_count )) | ||
success_percent=$(bc -l <<< "100*${success_count}/${example_count}") | ||
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 | ||
"Successfully parsed %d of %d example files (%.1f%%)\n" \ | ||
"$success_count" "$example_count" "$success_percent" |
Oops, something went wrong.