File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -115,6 +115,26 @@ matrix:
115115 - TRAVIS_RUST_VERSION=nightly
116116 - REGULAR_TEST=false
117117 - CODE_COVERAGE=true
118+ - name : test WASM
119+ language : python
120+ python : 3.6
121+ cache :
122+ pip : true
123+ # Because we're using the Python Travis environment, we can't use
124+ # the built-in cargo cacher
125+ directories :
126+ - /home/travis/.cargo
127+ - target
128+ addons :
129+ firefox : latest
130+ install :
131+ - nvm install node
132+ - pip install pipenv
133+ script :
134+ - wasm/tests/.travis-runner.sh
135+ env :
136+ - REGULAR_TEST=true
137+ - TRAVIS_RUST_VERSION=stable
118138 allow_failures :
119139 - rust : nightly
120140 env : REGULAR_TEST=true
Original file line number Diff line number Diff line change 1616 "raw-loader" : " ^1.0.0" ,
1717 "webpack" : " ^4.16.3" ,
1818 "webpack-cli" : " ^3.1.0" ,
19- "webpack-dev-server" : " ^3.1.5"
19+ "webpack-dev-server" : " ^3.1.5" ,
20+ "start-server-and-test" : " ^1.7.11"
2021 },
2122 "scripts" : {
2223 "dev" : " webpack-dev-server -d" ,
2324 "build" : " webpack" ,
24- "dist" : " webpack --mode production"
25+ "dist" : " webpack --mode production" ,
26+ "test" : " cd ../tests; pipenv run pytest" ,
27+ "ci" : " start-server-and-test dev http-get://localhost:8080 test"
2528 },
2629 "repository" : {
2730 "type" : " git" ,
Original file line number Diff line number Diff line change 1+ #! /bin/sh -eux
2+ # This script is intended to be run in Travis from the root of the repository
3+
4+ # Install Rust
5+ curl -sSf https://build.travis-ci.org/files/rustup-init.sh | sh -s -- --default-toolchain=$TRAVIS_RUST_VERSION -y
6+ export PATH=$HOME /.cargo/bin:$PATH
7+
8+ # install wasm-pack
9+ if [ ! -f $HOME /.cargo/bin/wasm-pack ]; then
10+ curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
11+ fi
12+
13+ # install geckodriver
14+ wget https://github.com/mozilla/geckodriver/releases/download/v0.24.0/geckodriver-v0.24.0-linux32.tar.gz
15+ mkdir geckodriver
16+ tar -xzf geckodriver-v0.24.0-linux32.tar.gz -C geckodriver
17+ export PATH=$PATH :$PWD /geckodriver
18+
19+ # Install pipenv
20+ pip install pipenv
21+ (cd wasm/tests; pipenv install)
22+
23+ (cd wasm/demo; npm install; npm run ci)
Original file line number Diff line number Diff line change 1+ [[source ]]
2+ url = " https://pypi.org/simple"
3+ verify_ssl = true
4+ name = " pypi"
5+
6+ [packages ]
7+ pytest = " *"
8+ selenium = " *"
9+
10+ [dev-packages ]
11+
12+ [requires ]
13+ python_version = " 3"
Original file line number Diff line number Diff line change 1+ import time
2+
3+ from selenium import webdriver
4+ from selenium .webdriver .firefox .options import Options
5+ import pytest
6+
7+ RUN_CODE_TEMPLATE = """
8+ var output = "";
9+ save_output = function(text) {{
10+ output += text
11+ }};
12+ var vm = window.rp.vmStore.init('test_vm');
13+ vm.setStdout(save_output);
14+ vm.exec('{}');
15+ vm.destroy();
16+ return output;
17+ """
18+
19+ @pytest .fixture (scope = "module" )
20+ def driver (request ):
21+ options = Options ()
22+ options .add_argument ('-headless' )
23+ driver = webdriver .Firefox (options = options )
24+ driver .get ("http://localhost:8080" )
25+ time .sleep (5 )
26+ yield driver
27+ driver .close ()
28+
29+
30+ @pytest .mark .parametrize ("script, output" ,
31+ [
32+ ("print(5)" , "5" ),
33+ ("a=5;b=4;print(a+b)" , "9" )
34+ ]
35+ )
36+ def test_demo (driver , script , output ):
37+ script = RUN_CODE_TEMPLATE .format (script )
38+ assert driver .execute_script (script ).strip () == output
You can’t perform that action at this time.
0 commit comments