From 8712bf84858fd4d31b04011dc889767723ba85e8 Mon Sep 17 00:00:00 2001 From: Amjad Mash'al Date: Mon, 31 Aug 2015 01:26:58 +0200 Subject: [PATCH 1/6] Restructuring test directories --- test-chromium.sh | 24 ------- test.sh | 68 +------------------- test/chromium.sh | 31 +++++++++ test/{chrome => chromium}/README.md | 0 test/{chrome => chromium}/requirements.txt | 0 test/{chrome => chromium}/script.py | 0 test/firefox.sh | 75 ++++++++++++++++++++++ 7 files changed, 109 insertions(+), 89 deletions(-) delete mode 100755 test-chromium.sh create mode 100755 test/chromium.sh rename test/{chrome => chromium}/README.md (100%) rename test/{chrome => chromium}/requirements.txt (100%) rename test/{chrome => chromium}/script.py (100%) create mode 100755 test/firefox.sh diff --git a/test-chromium.sh b/test-chromium.sh deleted file mode 100755 index 02b37f170a88..000000000000 --- a/test-chromium.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash -# -# Build the extension and run a chromium extension with it installed. -# -set -o errexit -o xtrace - -# If you just want to run Chromium with the latest code: -if [ "$1" == "--justrun" ]; then - shift - source makecrx.sh - echo "running Chromium" - source utils/mktemp.sh - - PROFILE_DIRECTORY="$(mktemp -d)" - trap 'rm -r "$PROFILE_DIRECTORY"' EXIT - chromium-browser \ - --user-data-dir="$PROFILE_DIRECTORY" \ - --load-extension=pkg/crx/ -else - source makecrx.sh - echo "running tests" - CRX_NAME="`ls -tr pkg/*.crx | tail -1`" - python2.7 test/chrome/script.py $CRX_NAME -fi diff --git a/test.sh b/test.sh index 0462f0d2329e..76052472a889 100755 --- a/test.sh +++ b/test.sh @@ -5,70 +5,8 @@ # or as .git/hooks/pre-push, so we need to find the directory containing # test.sh before we can proceed. If $0 is not a symlink, `readlink` will # print nothing; if it is a symlink it will print the link target. -cd $(dirname $0)/$(dirname $(readlink $0)) - -source utils/mktemp.sh - -# dummy Jetpack addon that contains tests -TEST_ADDON_PATH=./https-everywhere-tests/ - -# We'll create a Firefox profile here and install HTTPS Everywhere into it. -PROFILE_DIRECTORY="$(mktemp -d)" -trap 'rm -r "$PROFILE_DIRECTORY"' EXIT -HTTPSE_INSTALL_DIRECTORY=$PROFILE_DIRECTORY/extensions/https-everywhere-eff@eff.org - -# Build the XPI to run all the validations in makexpi.sh, and to ensure that -# we test what is actually getting built. -./makexpi.sh -XPI_NAME="`ls -tr pkg/*-eff.xpi | tail -1`" - -# Set up a skeleton profile and then install into it. -# The skeleton contains a few files required to trick Firefox into thinking -# that the extension was fully installed rather than just unpacked. -rsync -a https-everywhere-tests/test_profile_skeleton/ $PROFILE_DIRECTORY -unzip -qd $HTTPSE_INSTALL_DIRECTORY $XPI_NAME - -die() { - echo "$@" - exit 1 -} -if [ ! -f "addon-sdk/bin/activate" ]; then - die "Addon SDK not available. Run git submodule update." -fi - -if [ ! -d "$HTTPSE_INSTALL_DIRECTORY" ]; then - die "Firefox profile does not have HTTPS Everywhere installed" -fi - -# Activate the Firefox Addon SDK. -pushd addon-sdk -source bin/activate -popd - -if ! type cfx > /dev/null; then - die "Addon SDK failed to activiate." -fi - -pushd $TEST_ADDON_PATH - -# If you just want to run Firefox with the latest code: -if [ "$1" == "--justrun" ]; then - echo "running firefox" - shift - firefox -no-remote -profile "$PROFILE_DIRECTORY" "$@" -else - echo "running tests" - cfx test --profiledir="$PROFILE_DIRECTORY" --verbose -fi - -popd +cd $(dirname $0)/$(dirname $(readlink $0)) -bash test-ruleset-coverage.sh -# Echo the version of sqlite3, since the determinism of the build depends on -# having the same version. -echo "To reproduce this build (https://wiki.debian.org/ReproducibleBuilds)," \ - "please use this version of sqlite3:" -sqlite3 -version -shasum=$(openssl sha -sha256 "$XPI_NAME") -echo -e "Git commit `git rev-parse HEAD`\n$shasum" +./test/firefox.sh $@ +# ./test/chromium.sh \ No newline at end of file diff --git a/test/chromium.sh b/test/chromium.sh new file mode 100755 index 000000000000..c54d225203b4 --- /dev/null +++ b/test/chromium.sh @@ -0,0 +1,31 @@ +#!/bin/bash +# Run Chromium tests for HTTPS Everywhere +# +# Get into the project-root. This script may be executed as `chromium.sh` +# or as ./test/chromium.sh, so we need to find the directory +# containing firefox.sh before we can proceed. If $0 is not a symlink, +# `readlink` will print nothing; if it is a symlink it will print the +# link target. + +set -o errexit -o xtrace + +cd $(dirname $0)/$(dirname $(readlink $0))../ + +# If you just want to run Chromium with the latest code: +if [ "$1" == "--justrun" ]; then + shift + ./makecrx.sh + echo "running Chromium" + ./utils/mktemp.sh + + PROFILE_DIRECTORY="$(mktemp -d)" + trap 'rm -r "$PROFILE_DIRECTORY"' EXIT + chromium-browser \ + --user-data-dir="$PROFILE_DIRECTORY" \ + --load-extension=pkg/crx/ +else + source makecrx.sh + echo "running tests" + CRX_NAME="`ls -tr pkg/*.crx | tail -1`" + python2.7 test/chromium/script.py $CRX_NAME +fi diff --git a/test/chrome/README.md b/test/chromium/README.md similarity index 100% rename from test/chrome/README.md rename to test/chromium/README.md diff --git a/test/chrome/requirements.txt b/test/chromium/requirements.txt similarity index 100% rename from test/chrome/requirements.txt rename to test/chromium/requirements.txt diff --git a/test/chrome/script.py b/test/chromium/script.py similarity index 100% rename from test/chrome/script.py rename to test/chromium/script.py diff --git a/test/firefox.sh b/test/firefox.sh new file mode 100755 index 000000000000..0ce6d30e97c9 --- /dev/null +++ b/test/firefox.sh @@ -0,0 +1,75 @@ +#!/bin/bash -ex +# Run Firefox tests for HTTPS Everywhere +# +# Get into the project-root. This script may be executed as `firefox.sh` +# or as ./test/firefox.sh, so we need to find the directory containing +# firefox.sh before we can proceed. If $0 is not a symlink, `readlink` +# will print nothing; if it is a symlink it will print the link target. + +cd $(dirname $0)/$(dirname $(readlink $0))../ + +source utils/mktemp.sh + +# dummy Jetpack addon that contains tests +TEST_ADDON_PATH=./https-everywhere-tests/ + +# We'll create a Firefox profile here and install HTTPS Everywhere into it. +PROFILE_DIRECTORY="$(mktemp -d)" +trap 'rm -r "$PROFILE_DIRECTORY"' EXIT +HTTPSE_INSTALL_DIRECTORY=$PROFILE_DIRECTORY/extensions/https-everywhere-eff@eff.org + +# Build the XPI to run all the validations in makexpi.sh, and to ensure that +# we test what is actually getting built. +./makexpi.sh +XPI_NAME="`ls -tr pkg/*-eff.xpi | tail -1`" + +# Set up a skeleton profile and then install into it. +# The skeleton contains a few files required to trick Firefox into thinking +# that the extension was fully installed rather than just unpacked. +rsync -a https-everywhere-tests/test_profile_skeleton/ $PROFILE_DIRECTORY +unzip -qd $HTTPSE_INSTALL_DIRECTORY $XPI_NAME + +die() { + echo "$@" + exit 1 +} + +if [ ! -f "addon-sdk/bin/activate" ]; then + die "Addon SDK not available. Run git submodule update." +fi + +if [ ! -d "$HTTPSE_INSTALL_DIRECTORY" ]; then + die "Firefox profile does not have HTTPS Everywhere installed" +fi + +# Activate the Firefox Addon SDK. +pushd addon-sdk +source bin/activate +popd + +if ! type cfx > /dev/null; then + die "Addon SDK failed to activiate." +fi + +pushd $TEST_ADDON_PATH + +# If you just want to run Firefox with the latest code: +if [ "$1" == "--justrun" ]; then + echo "running firefox" + shift + firefox -no-remote -profile "$PROFILE_DIRECTORY" "$@" +else + echo "running tests" + cfx test --profiledir="$PROFILE_DIRECTORY" --verbose +fi + +popd + +bash test-ruleset-coverage.sh +# Echo the version of sqlite3, since the determinism of the build depends on +# having the same version. +echo "To reproduce this build (https://wiki.debian.org/ReproducibleBuilds)," \ + "please use this version of sqlite3:" +sqlite3 -version +shasum=$(openssl sha -sha256 "$XPI_NAME") +echo -e "Git commit `git rev-parse HEAD`\n$shasum" From dd067798cd0be4c965cbca2b69bbed60bd0187f8 Mon Sep 17 00:00:00 2001 From: Amjad Mash'al Date: Mon, 31 Aug 2015 22:40:31 +0200 Subject: [PATCH 2/6] Fixing running Chromium testing through test.sh --- test.sh | 2 +- test/chromium.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test.sh b/test.sh index 76052472a889..187241495657 100755 --- a/test.sh +++ b/test.sh @@ -9,4 +9,4 @@ cd $(dirname $0)/$(dirname $(readlink $0)) ./test/firefox.sh $@ -# ./test/chromium.sh \ No newline at end of file +./test/chromium.sh $@ \ No newline at end of file diff --git a/test/chromium.sh b/test/chromium.sh index c54d225203b4..23c439f19129 100755 --- a/test/chromium.sh +++ b/test/chromium.sh @@ -24,7 +24,7 @@ if [ "$1" == "--justrun" ]; then --user-data-dir="$PROFILE_DIRECTORY" \ --load-extension=pkg/crx/ else - source makecrx.sh + ./makecrx.sh echo "running tests" CRX_NAME="`ls -tr pkg/*.crx | tail -1`" python2.7 test/chromium/script.py $CRX_NAME From f56bb54933ceb29e4717b2d28c0205bcca963048 Mon Sep 17 00:00:00 2001 From: Amjad Mash'al Date: Mon, 31 Aug 2015 22:57:39 +0200 Subject: [PATCH 3/6] Updating Travis YML --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index a5e044e63aaf..c064a20abe8b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,11 +11,13 @@ addons: - python-dev - libcurl4-openssl-dev - python-lxml + - chromium-chromedriver firefox: "37.0" virtualenv: system_site_packages: true install: - pip install -r https-everywhere-checker/requirements.txt + - pip install -r test/chromium/requirements.txt before_script: - sh -e /etc/init.d/xvfb start env: From b8baef05079026455ca0ac21e54fb39b856c08f8 Mon Sep 17 00:00:00 2001 From: Amjad Mash'al Date: Mon, 31 Aug 2015 23:11:56 +0200 Subject: [PATCH 4/6] Moving test-ruleset-coverage.sh to test/rules.sh and switching running it from firefox.sh to test.sh --- test.sh | 3 ++- test/firefox.sh | 1 - test-ruleset-coverage.sh => test/rules.sh | 2 +- utils/mktemp.sh | 0 4 files changed, 3 insertions(+), 3 deletions(-) rename test-ruleset-coverage.sh => test/rules.sh (96%) mode change 100644 => 100755 utils/mktemp.sh diff --git a/test.sh b/test.sh index 187241495657..3a255e25b36d 100755 --- a/test.sh +++ b/test.sh @@ -8,5 +8,6 @@ cd $(dirname $0)/$(dirname $(readlink $0)) +./test/rules.sh ./test/firefox.sh $@ -./test/chromium.sh $@ \ No newline at end of file +./test/chromium.sh $@ diff --git a/test/firefox.sh b/test/firefox.sh index 0ce6d30e97c9..67758dc2fbd9 100755 --- a/test/firefox.sh +++ b/test/firefox.sh @@ -65,7 +65,6 @@ fi popd -bash test-ruleset-coverage.sh # Echo the version of sqlite3, since the determinism of the build depends on # having the same version. echo "To reproduce this build (https://wiki.debian.org/ReproducibleBuilds)," \ diff --git a/test-ruleset-coverage.sh b/test/rules.sh similarity index 96% rename from test-ruleset-coverage.sh rename to test/rules.sh index b433eb6f4637..cac08eec3d62 100755 --- a/test-ruleset-coverage.sh +++ b/test/rules.sh @@ -4,7 +4,7 @@ # coverage, according to the ruleset checker. # -cd $(dirname $0) +cd $(dirname $0)/$(dirname $(readlink $0))../ source utils/mktemp.sh diff --git a/utils/mktemp.sh b/utils/mktemp.sh old mode 100644 new mode 100755 From 3ba89042dfe35f372723a83e455d92fb9cef8911 Mon Sep 17 00:00:00 2001 From: Amjad Mash'al Date: Tue, 1 Sep 2015 16:00:07 +0200 Subject: [PATCH 5/6] Removing Chromedriver's path conditions --- .travis.yml | 1 - test.sh | 2 +- test/chromium/script.py | 12 ++---------- 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/.travis.yml b/.travis.yml index c064a20abe8b..c597d5a974dc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,6 @@ addons: - python-dev - libcurl4-openssl-dev - python-lxml - - chromium-chromedriver firefox: "37.0" virtualenv: system_site_packages: true diff --git a/test.sh b/test.sh index 3a255e25b36d..e285c7bac4d2 100755 --- a/test.sh +++ b/test.sh @@ -10,4 +10,4 @@ cd $(dirname $0)/$(dirname $(readlink $0)) ./test/rules.sh ./test/firefox.sh $@ -./test/chromium.sh $@ +# ./test/chromium.sh $@ diff --git a/test/chromium/script.py b/test/chromium/script.py index 9c6ede1eec4e..2ca24ebdfa28 100644 --- a/test/chromium/script.py +++ b/test/chromium/script.py @@ -14,14 +14,6 @@ from selenium import webdriver from selenium.common.exceptions import WebDriverException -if sys.platform.startswith("linux"): - chromedriver_path = "/usr/lib/chromium-browser/chromedriver" -elif sys.platform.startswith("darwin"): - chromedriver_path = "chromedriver" -else: - print "Unsupported Operating System" - sys.exit(3) - class bcolors: HEADER = '\033[95m' OKBLUE = '\033[94m' @@ -38,14 +30,14 @@ class bcolors: # First argument is optional, if not specified will search path. try: - driver = webdriver.Chrome(chromedriver_path, chrome_options=chromeOps) + driver = webdriver.Chrome('chromedriver', chrome_options=chromeOps) except WebDriverException as e: error = e.__str__() if "executable needs to be in PATH" in e.__str__(): print "ChromeDriver isn't installed. Check test/chrome/README.md\ for instructions on how to install ChromeDriver" - sys.exit(0) + sys.exit(2) else: driver.quit() raise e From 1991398c632211cbc7a77ddc988486f6af995f1f Mon Sep 17 00:00:00 2001 From: Amjad Mash'al Date: Tue, 1 Sep 2015 16:38:16 +0200 Subject: [PATCH 6/6] Integrating Chrome testing with Travis --- .travis.yml | 11 ++++++++--- test.sh | 2 +- test/chromium/script.py | 15 +++++++++++---- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index c597d5a974dc..a5eacafc5f4b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,16 +11,22 @@ addons: - python-dev - libcurl4-openssl-dev - python-lxml + - python-software-properties + - chromium-browser firefox: "37.0" virtualenv: system_site_packages: true install: - pip install -r https-everywhere-checker/requirements.txt - pip install -r test/chromium/requirements.txt -before_script: - - sh -e /etc/init.d/xvfb start env: - DISPLAY=':99.0' +before_script: + - export DISPLAY=:99.0 + - sh -e /etc/init.d/xvfb start + - wget https://chromedriver.storage.googleapis.com/2.12/chromedriver_linux64.zip + - unzip chromedriver_linux64.zip + - mv chromedriver test/chromium/chromedriver script: - ./test.sh sudo: false @@ -34,4 +40,3 @@ notifications: - "irc.oftc.net#https-everywhere" on_success: change on_failure: change - diff --git a/test.sh b/test.sh index e285c7bac4d2..3a255e25b36d 100755 --- a/test.sh +++ b/test.sh @@ -10,4 +10,4 @@ cd $(dirname $0)/$(dirname $(readlink $0)) ./test/rules.sh ./test/firefox.sh $@ -# ./test/chromium.sh $@ +./test/chromium.sh $@ diff --git a/test/chromium/script.py b/test/chromium/script.py index 2ca24ebdfa28..5f9e6e44031a 100644 --- a/test/chromium/script.py +++ b/test/chromium/script.py @@ -10,7 +10,7 @@ # of linux is required for the script to run correctly as well. # Otherwise, use pyvirtualdisplay. -import sys +import sys, os from selenium import webdriver from selenium.common.exceptions import WebDriverException @@ -26,20 +26,27 @@ class bcolors: chromeOps = webdriver.ChromeOptions() chromeOps.add_extension(sys.argv[1]) +chromeOps.add_argument("--disable-setuid-sandbox") + +chromdriver_path = "chromedriver" + +if 'TRAVIS' in os.environ: + chromeOps.add_argument('--no-sandbox') + chromdriver_path = os.path.abspath("test/chromium/chromedriver") # First argument is optional, if not specified will search path. try: - driver = webdriver.Chrome('chromedriver', chrome_options=chromeOps) + driver = webdriver.Chrome(chromdriver_path, chrome_options=chromeOps) except WebDriverException as e: error = e.__str__() if "executable needs to be in PATH" in e.__str__(): print "ChromeDriver isn't installed. Check test/chrome/README.md\ - for instructions on how to install ChromeDriver" +for instructions on how to install ChromeDriver" + sys.exit(2) else: - driver.quit() raise e print '' #New line