diff options
author | jahoti <jahoti@tilde.team> | 2021-12-03 00:00:00 +0000 |
---|---|---|
committer | jahoti <jahoti@tilde.team> | 2021-12-03 00:00:00 +0000 |
commit | 3fcff3382d439c0451421288f1d7d942be0de0c8 (patch) | |
tree | 33d7dd06621d544a54d7ae6acffb89f7030293ef | |
parent | d16e763e240a2aefe3d4490cddff61893a35a1ea (diff) | |
download | browser-extension-3fcff3382d439c0451421288f1d7d942be0de0c8.tar.gz browser-extension-3fcff3382d439c0451421288f1d7d942be0de0c8.zip |
Make testing configurable
Add options to configure in accordance with #97
-rw-r--r-- | Makefile.in | 6 | ||||
-rwxr-xr-x | configure | 40 | ||||
-rw-r--r-- | test/misc_constants.py | 23 |
3 files changed, 55 insertions, 14 deletions
diff --git a/Makefile.in b/Makefile.in index 5a376e1..ffbad61 100644 --- a/Makefile.in +++ b/Makefile.in @@ -70,10 +70,10 @@ test/certs/rootCA.pem: test/certs/rootCA.key -subj "/CN=Haketilo Test" test: test/certs/rootCA.pem test/certs/site.key - MOZ_HEADLESS=whatever pytest + MOZ_HEADLESS=whatever $(PYTEST) test-environment: test/certs/rootCA.pem test/certs/site.key - python3 -m test + $(PYTHON) -m test # helper targets clean mostlyclean: @@ -85,7 +85,7 @@ clean mostlyclean: rm -rf $$(find . -type d -name __pycache__) distclean: clean - rm -f Makefile config.status record.conf + rm -f Makefile config.status record.conf testing.conf maintainer-clean: distclean @echo 'This command is intended for maintainers to use; it' @@ -15,6 +15,12 @@ set -e +# Set BROWSERPATH appropriately +set_browserpath () { + BROWSERPATH="${BINARY:-$(realpath "$1")}" +} + +BINARY="$BROWSER_BIN" BROWSERPATH='' SRCDIR='' TARGET='' @@ -22,18 +28,23 @@ TARGET='' # Parse command line options while [ "x$1" != x ]; do case "$1" in - --srcdir=*) SRCDIR="$(echo "$1" | cut -c 10-)";; - --srcdir) SRCDIR="$2"; shift;; - "DESTDIR"=*) DESTDIR="$(echo "$1" | cut -c 9-)";; - "UPDATE_URL"=*) UPDATE_URL="$(echo "$1" | cut -c 12-)";; - --host=*) TARGET="$(echo "$1" | cut -c 8-)";; - --host) TARGET="$2"; shift;; + --srcdir=*) SRCDIR="$(echo "$1" | cut -c 10-)";; + --srcdir) SRCDIR="$2"; shift;; + BROWSER_BIN=*) BINARY="$(echo "$1" | cut -c 13-)";; + DESTDIR=*) DESTDIR="$(echo "$1" | cut -c 9-)";; + PYTEST=*) PYTEST="$(echo "$1" | cut -c 8-)";; + PYTHON=*) PYTHON="$(echo "$1" | cut -c 8-)";; + TEST_PORT=*) TEST_PORT="$(echo "$1" | cut -c 11-)";; + TEST_PROFILE=*) TEST_PROFILE="$(echo "$1" | cut -c 14-)";; + UPDATE_URL=*) UPDATE_URL="$(echo "$1" | cut -c 12-)";; + --host=*) TARGET="$(echo "$1" | cut -c 8-)";; + --host) TARGET="$2"; shift;; # browsers chromium | chrome | google-chrome | mozilla |\ firefox | librewolf | icecat | iceweasel | abrowser |\ - iceweasel-uxp | tor-browser) TARGET=$1;; - *) echo Ignoring option "'$1'";; + iceweasel-uxp | tor-browser) TARGET=$1;; + *) echo Ignoring option "'$1'";; esac shift done @@ -59,15 +70,15 @@ fi if [ "x$TARGET" = x ]; then echo Detecting target automatically. if [ -h /etc/alternatives/x-www-browser ]; then - BROWSERPATH="$(realpath /etc/alternatives/x-www-browser)" - TARGET="$(/etc/alternatives/x-www-browser --version 2> /dev/null | + set_browserpath /etc/alternatives/x-www-browser + TARGET="$("$BROWSERPATH" --version 2> /dev/null | tail -n 1 | awk '{ print $1 }' | tr [A-Z] [a-z])" else echo Warning: could not find target automatically. >&2 echo Some make rules may fail. >&2 fi else - BROWSERPATH="$(realpath "$(which $TARGET)")" + set_browserpath "$(which $TARGET)" fi # Check and standardize target @@ -98,8 +109,15 @@ fi echo srcdir = "$SRCDIR" > record.conf echo default_target = "$TARGET" >> record.conf echo DESTDIR = "$DESTDIR" >> record.conf +echo PYTEST = "${PYTEST:-$(which pytest)}" >> record.conf +echo PYTHON = "${PYTHON:-$(which python3)}" >> record.conf echo UPDATE_URL = "$UPDATE_URL" >> record.conf +# (Re-)write testing.conf +rm -f testing.conf +[ "x$BINARY" != x ] && echo BINARY "$BINARY" >> testing.conf +[ "x$TEST_PROFILE" != x ] && echo TEST_PROFILE "$TEST_PROFILE" >> testing.conf +[ "x$TEST_PORT" != x ] && echo TEST_PORT "$TEST_PORT" >> testing.conf # Prepare and run write_makefile.sh (as config.status) if [ ! -e config.status ]; then diff --git a/test/misc_constants.py b/test/misc_constants.py index 22432a6..55ee13e 100644 --- a/test/misc_constants.py +++ b/test/misc_constants.py @@ -41,6 +41,29 @@ default_proxy_port = 1337 default_cert_dir = here / 'certs' +# Use user-specified values instead where available +try: + with open(str(here.parent / 'testing.conf')) as f: + option = f.readline() + while ' ' in option: + key, value = option[:-1].split(' ', maxsplit=1) + if key == 'BINARY': + default_firefox_binary = value + + elif key == 'TEST_PROFILE': + default_clean_profile_dir = value + + elif key == 'TEST_PORT': + default_proxy_port = value + + else: + raise KeyError(key) + + option = f.readline() +except FileNotFoundError: + # There may be no defaults overridden; that's OK! + pass + mime_types = { "7z": "application/x-7z-compressed", "oga": "audio/ogg", "abw": "application/x-abiword", "ogv": "video/ogg", |