Skip to content
This repository was archived by the owner on Nov 6, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +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
before_script:
- sh -e /etc/init.d/xvfb start
- pip install -r test/chromium/requirements.txt
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
Expand All @@ -33,4 +40,3 @@ notifications:
- "irc.oftc.net#https-everywhere"
on_success: change
on_failure: change

24 changes: 0 additions & 24 deletions test-chromium.sh

This file was deleted.

69 changes: 4 additions & 65 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,70 +5,9 @@
# 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/rules.sh
./test/firefox.sh $@
./test/chromium.sh $@
31 changes: 31 additions & 0 deletions test/chromium.sh
Original file line number Diff line number Diff line change
@@ -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
./makecrx.sh
echo "running tests"
CRX_NAME="`ls -tr pkg/*.crx | tail -1`"
python2.7 test/chromium/script.py $CRX_NAME
fi
File renamed without changes.
25 changes: 12 additions & 13 deletions test/chrome/script.py → test/chromium/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,10 @@
# 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

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'
Expand All @@ -34,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_path, 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"
sys.exit(0)
for instructions on how to install ChromeDriver"

sys.exit(2)
else:
driver.quit()
raise e

print '' #New line
Expand Down
74 changes: 74 additions & 0 deletions test/firefox.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/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

# 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"
2 changes: 1 addition & 1 deletion test-ruleset-coverage.sh → test/rules.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# coverage, according to the ruleset checker.
#

cd $(dirname $0)
cd $(dirname $0)/$(dirname $(readlink $0))../

source utils/mktemp.sh

Expand Down
Empty file modified utils/mktemp.sh
100644 → 100755
Empty file.