Skip to content

Commit abb4d41

Browse files
committed
Add selenium test to travis
1 parent f281aab commit abb4d41

File tree

4 files changed

+53
-9
lines changed

4 files changed

+53
-9
lines changed

.travis.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff 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

wasm/demo/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,15 @@
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",

wasm/tests/.travis-runner.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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)

wasm/tests/test_demo.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import time
22

33
from selenium import webdriver
4-
from selenium.webdriver.chrome.options import Options
4+
from selenium.webdriver.firefox.options import Options
55
import pytest
66

77
RUN_CODE_TEMPLATE = """
@@ -19,15 +19,13 @@
1919
@pytest.fixture(scope="module")
2020
def driver(request):
2121
options = Options()
22-
options.headless = True
23-
options.add_argument('--disable-gpu')
24-
driver = webdriver.Chrome(options=options)
22+
options.add_argument('-headless')
23+
driver = webdriver.Firefox(options=options)
2524
driver.get("http://localhost:8080")
26-
assert "RustPython" in driver.title
2725
time.sleep(5)
2826
yield driver
29-
driver.close()
30-
27+
driver.close()
28+
3129

3230
@pytest.mark.parametrize("script, output",
3331
[

0 commit comments

Comments
 (0)