Add script for testing the parser against popular repositories

This commit is contained in:
Jonatan Kłosko 2021-09-29 20:45:47 +02:00
parent 01d428d3a6
commit e846449ef6
4 changed files with 27 additions and 3 deletions

View File

@ -89,6 +89,9 @@ npm run format
# Run parser against the given repository
scripts/parse_repo.sh elixir-lang/elixir
# Run parser against a predefined list of popular repositories
scripts/integration_test.sh
```
## Implementation notes

View File

@ -58,8 +58,6 @@ const ATOM_OPERATOR_LITERALS = ALL_OPS.filter(
(operator) => !/[a-z]/.test(operator) && operator !== "=>"
);
// Note that for keywords we use external scanner (KEYWORD_SPECIAL_LITERAL),
// so it should be kept in sync
const ATOM_SPECIAL_LITERALS = ["...", "%{}", "{}", "%", "<<>>", "..//"];
// See Ref 6. in the docs

23
scripts/integration_test.sh Executable file
View File

@ -0,0 +1,23 @@
#!/bin/bash
set -e
cd "$(dirname "$0")/.."
print_usage_and_exit() {
echo "Usage: $0"
echo ""
echo "Runs the parser against a predefined list of popular Elixir repositories"
echo ""
exit 1
}
if [ $# -ne 0 ]; then
print_usage_and_exit
fi
repos="elixir-lang/elixir elixir-lang/ex_doc elixir-plug/plug elixir-ecto/ecto dashbitco/broadway elixir-nx/nx elixir-nx/axon livebook-dev/livebook"
for repo in $repos; do
./scripts/parse_repo.sh $repo
done

View File

@ -26,7 +26,7 @@ dir="tmp/gh/${gh_repo//[\/-]/_}"
if [[ ! -d "$dir" ]]; then
mkdir -p "$(dirname "$dir")"
git clone "https://github.com/$gh_repo.git" "$dir"
git clone --depth 1 "https://github.com/$gh_repo.git" "$dir"
fi
echo "Running parser against $gh_repo"