Build and test wasm on CI

This commit is contained in:
Max Brunsfeld 2019-04-25 17:27:24 -07:00
parent 58e1a0fee7
commit 66e006105c
14 changed files with 214 additions and 65 deletions

View file

@ -11,7 +11,13 @@ fi
mkdir -p $target_dir
emcc \
docker run \
--rm \
-v $(pwd):/src \
-u $(id -u) \
trzeci/emscripten-slim \
\
emcc \
-s WASM=1 \
-s ALLOW_MEMORY_GROWTH \
-s MAIN_MODULE=1 \

View file

@ -7,27 +7,16 @@ cargo build --release
root_dir=$PWD
tree_sitter=${root_dir}/target/release/tree-sitter
grammars_dir=${root_dir}/test/fixtures/grammars
grammar_names=(
bash
c
cpp
embedded-template
go
html
javascript
json
python
rust
)
grammar_names=$(ls $grammars_dir)
if [[ "$#" > 0 ]]; then
grammar_names=($1)
fi
for grammar_name in "${grammar_names[@]}"; do
for grammar_name in $grammar_names; do
echo "Regenerating ${grammar_name} parser"
cd ${grammars_dir}/${grammar_name}
$tree_sitter generate src/grammar.json
cd $PWD
(
cd ${grammars_dir}/${grammar_name}
$tree_sitter generate src/grammar.json
)
done

24
script/generate-fixtures-wasm Executable file
View file

@ -0,0 +1,24 @@
#!/usr/bin/env bash
set -e
cargo build --release
root_dir=$PWD
tree_sitter=${root_dir}/target/release/tree-sitter
grammars_dir=${root_dir}/test/fixtures/grammars
grammar_names=(
javascript
python
)
if [[ "$#" > 0 ]]; then
grammar_names=($1)
fi
for grammar_name in ${grammar_names[@]}; do
echo "Compiling ${grammar_name} parser to wasm"
$tree_sitter build-wasm ${grammars_dir}/${grammar_name}
done
mv tree-sitter-*.wasm target/scratch/

12
script/test-wasm Executable file
View file

@ -0,0 +1,12 @@
#!/usr/bin/env bash
set -e
cd lib/web
if [ ! -d "node_modules/chai" ] || [ ! -d "node_modules/mocha" ]; then
echo "Installing test dependencies..."
npm install
fi
./node_modules/.bin/mocha