Skip to content

Commit

Permalink
Enable testing of wpt in travis
Browse files Browse the repository at this point in the history
  • Loading branch information
jgraham committed Jul 25, 2017
1 parent 6990c7b commit 0d63d22
Show file tree
Hide file tree
Showing 9 changed files with 97 additions and 48 deletions.
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ matrix:
env: TOXENV=py36 HYPOTHESIS_PROFILE=ci SCRIPT=tools/ci/ci_unittest.sh
- python: pypy-5.4
env: TOXENV=pypy HYPOTHESIS_PROFILE=ci SCRIPT=tools/ci/ci_unittest.sh
- python: 2.7
addons:
apt:
packages:
- libnss3-tools
env: TOXENV=py27 SCRIPT=tools/ci/ci_wpt.sh
exclude:
- env: # exclude empty env from the top-level above
allow_failures:
Expand Down
45 changes: 2 additions & 43 deletions tools/ci/ci_stability.sh
Original file line number Diff line number Diff line change
@@ -1,52 +1,11 @@
#!/bin/bash
set -e

SCRIPT_DIR=$(dirname $(readlink -f "$0"))
WPT_ROOT=$(readlink -f $SCRIPT_DIR/../..)
cd $WPT_ROOT

hosts_fixup() {
echo "travis_fold:start:hosts_fixup"
echo "Rewriting hosts file"
echo "## /etc/hosts ##"
cat /etc/hosts
sudo sed -i 's/^::1\s*localhost/::1/' /etc/hosts
sudo sh -c 'echo "
127.0.0.1 web-platform.test
127.0.0.1 www.web-platform.test
127.0.0.1 www1.web-platform.test
127.0.0.1 www2.web-platform.test
127.0.0.1 xn--n8j6ds53lwwkrqhv28a.web-platform.test
127.0.0.1 xn--lve-6lad.web-platform.test
0.0.0.0 nonexistent-origin.web-platform.test
" >> /etc/hosts'
echo "== /etc/hosts =="
cat /etc/hosts
echo "----------------"
echo "travis_fold:end:hosts_fixup"
}

install_chrome() {
channel=$1
deb_archive=google-chrome-${channel}_current_amd64.deb
wget https://dl.google.com/linux/direct/$deb_archive

# If the environment provides an installation of Google Chrome, the
# existing binary may take precedence over the one introduced in this
# script. Remove any previously-existing "alternatives" prior to
# installation in order to ensure that the new binary is installed as
# intended.
if sudo update-alternatives --list google-chrome; then
sudo update-alternatives --remove-all google-chrome
fi

# Installation will fail in cases where the package has unmet dependencies.
# When this occurs, attempt to use the system package manager to fetch the
# required packages and retry.
if ! sudo dpkg --install $deb_archive; then
sudo apt-get install --fix-broken
sudo dpkg --install $deb_archive
fi
}
source tools/ci/lib.sh

test_stability() {
./wpt check-stability $PRODUCT --output-bytes $((1024 * 1024 * 3)) --metadata ~/meta/
Expand Down
18 changes: 18 additions & 0 deletions tools/ci/ci_wpt.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash
set -e

SCRIPT_DIR=$(dirname $(readlink -f "$0"))
WPT_ROOT=$(readlink -f $SCRIPT_DIR/../..)
cd $WPT_ROOT

source tools/ci/lib.sh

main() {
hosts_fixup
install_chrome unstable
pip install -U tox codecov
cd tools/wpt
tox
}

main
45 changes: 45 additions & 0 deletions tools/ci/lib.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash

hosts_fixup() {
echo "travis_fold:start:hosts_fixup"
echo "Rewriting hosts file"
echo "## /etc/hosts ##"
cat /etc/hosts
sudo sed -i 's/^::1\s*localhost/::1/' /etc/hosts
sudo sh -c 'echo "
127.0.0.1 web-platform.test
127.0.0.1 www.web-platform.test
127.0.0.1 www1.web-platform.test
127.0.0.1 www2.web-platform.test
127.0.0.1 xn--n8j6ds53lwwkrqhv28a.web-platform.test
127.0.0.1 xn--lve-6lad.web-platform.test
0.0.0.0 nonexistent-origin.web-platform.test
" >> /etc/hosts'
echo "== /etc/hosts =="
cat /etc/hosts
echo "----------------"
echo "travis_fold:end:hosts_fixup"
}

install_chrome() {
channel=$1
deb_archive=google-chrome-${channel}_current_amd64.deb
wget https://dl.google.com/linux/direct/$deb_archive

# If the environment provides an installation of Google Chrome, the
# existing binary may take precedence over the one introduced in this
# script. Remove any previously-existing "alternatives" prior to
# installation in order to ensure that the new binary is installed as
# intended.
if sudo update-alternatives --list google-chrome; then
sudo update-alternatives --remove-all google-chrome
fi

# Installation will fail in cases where the package has unmet dependencies.
# When this occurs, attempt to use the system package manager to fetch the
# required packages and retry.
if ! sudo dpkg --install $deb_archive; then
sudo apt-get install --fix-broken
sudo dpkg --install $deb_archive
fi
}
2 changes: 1 addition & 1 deletion tools/pytest.ini
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[pytest]
norecursedirs = .* {arch} *.egg html5lib py pytest pywebsocket six wptrunner
norecursedirs = .* {arch} *.egg html5lib py pytest pywebsocket six wpt wptrunner
4 changes: 2 additions & 2 deletions tools/serve/serve.py
Original file line number Diff line number Diff line change
Expand Up @@ -763,8 +763,8 @@ def get_parser():


def run(**kwargs):
config = load_config("config.default.json",
"config.json",
config = load_config(os.path.join(repo_root, "config.default.json"),
os.path.join(repo_root, "config.json"),
**kwargs)

setup_logger(config["log_level"])
Expand Down
2 changes: 1 addition & 1 deletion tools/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ passenv =
[flake8]
ignore = E128,E129,E221,E226,E231,E251,E265,E302,E303,E305,E402,E901,F401,F821,F841
max-line-length = 141
exclude = .tox,html5lib,py,pytest,pywebsocket,six,_venv,webencodings,wptserve/docs,wptserve/tests/functional/docroot/,wptrunner
exclude = .tox,html5lib,py,pytest,pywebsocket,six,_venv,webencodings,wptserve/docs,wptserve/tests/functional/docroot/,wpt,wptrunner
2 changes: 1 addition & 1 deletion tools/wpt/tests/test_wpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def test_run_firefox():

def test_run_chrome():
with pytest.raises(SystemExit) as excinfo:
wpt.main(argv=["run", "--no-pause", "--binary-arg", "headless", "chrome", "/dom/nodes/Element-tagName.html"])
wpt.main(argv=["run", "--yes", "--no-pause", "--binary-arg", "headless", "chrome", "/dom/nodes/Element-tagName.html"])
assert excinfo.value.code == 0


Expand Down
21 changes: 21 additions & 0 deletions tools/wpt/tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[tox]
envlist = py27
skipsdist=True

[testenv]
deps =
flake8
pytest
pytest-cov
hypothesis
-r{toxinidir}/../wptrunner/requirements.txt
-r{toxinidir}/../wptrunner/requirements_chrome.txt
-r{toxinidir}/../wptrunner/requirements_firefox.txt

commands =
pytest --cov
flake8

[flake8]
ignore = E128,E129,E221,E226,E231,E251,E265,E302,E303,E305,E402,E901,F401,F821,F841
max-line-length = 141

0 comments on commit 0d63d22

Please sign in to comment.