aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjahoti <jahoti@tilde.team>2021-12-02 00:00:00 +0000
committerjahoti <jahoti@tilde.team>2021-12-02 00:00:00 +0000
commit5a0026423b61915fd2f9544456b2634505a952b1 (patch)
tree957e2ea870efd88dd987e56c6c89d2a24bcb6ee6
parent6d819aaea70756b778e71478ec6ce40a8d680841 (diff)
downloadbrowser-extension-build-sys.tar.gz
browser-extension-build-sys.zip
Allow testing behavior to be customizedbuild-sys
Adds PYTEST, PYTHON, BROWSER_BIN, TEST_PORT, and TEST_PROFILE variables to configure.
-rw-r--r--Makefile.in15
-rwxr-xr-xconfigure40
-rw-r--r--test/__main__.py2
-rwxr-xr-xtest/profiles.py2
-rwxr-xr-xtest/server.py2
5 files changed, 43 insertions, 18 deletions
diff --git a/Makefile.in b/Makefile.in
index 5a376e1..f87a816 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -69,11 +69,11 @@ test/certs/rootCA.pem: test/certs/rootCA.key
openssl req -x509 -new -nodes -key $< -days 1024 -out $@ \
-subj "/CN=Haketilo Test"
-test: test/certs/rootCA.pem test/certs/site.key
- MOZ_HEADLESS=whatever pytest
+test: test/certs/rootCA.pem test/certs/site.key test/config.py
+ MOZ_HEADLESS=whatever $(PYTEST)
-test-environment: test/certs/rootCA.pem test/certs/site.key
- python3 -m test
+test-environment: test/certs/rootCA.pem test/certs/site.key test/config.py
+ $(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 test/config.py
maintainer-clean: distclean
@echo 'This command is intended for maintainers to use; it'
@@ -107,6 +107,11 @@ Makefile: config.status Makefile.in record.conf
config.status: write_makefile.sh
cp "$(srcdir)"/write_makefile.sh config.status
+test/config.py:
+ @echo 'No test/config.py file was found; please re-configure'
+ @echo 'before attempting any more make operations.'
+ exit 1
+
# Unused GNU-specified targets
install-html:
install-dvi:
diff --git a/configure b/configure
index 06a43eb..1c17462 100755
--- a/configure
+++ b/configure
@@ -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,7 +70,7 @@ 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)"
+ set_browserpath /etc/alternatives/x-www-browser
TARGET="$(/etc/alternatives/x-www-browser --version 2> /dev/null |
tail -n 1 | awk '{ print $1 }' | tr [A-Z] [a-z])"
else
@@ -67,7 +78,7 @@ if [ "x$TARGET" = x ]; then
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,17 @@ 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
+# Write test/config.py (if testing is enabled)
+echo from .misc_constants import '*' > test/config.py
+echo default_firefox_binary = "'${BINARY:-/usr/lib/icecat/icecat}'" >> test/config.py
+echo default_clean_profile_dir = "'$TEST_PROFILE'" or \
+ default_clean_profile_dir >> test/config.py
+echo default_proxy_port = "${TEST_PORT:-1337}" >> test/config.py
+
# Prepare and run write_makefile.sh (as config.status)
if [ ! -e config.status ]; then
diff --git a/test/__main__.py b/test/__main__.py
index c3437ea..09eebd8 100644
--- a/test/__main__.py
+++ b/test/__main__.py
@@ -32,7 +32,7 @@ import time
import code
from .server import do_an_internet
-from .misc_constants import *
+from .config import *
from .profiles import firefox_safe_mode
def fail(msg, error_code):
diff --git a/test/profiles.py b/test/profiles.py
index a833097..510711f 100755
--- a/test/profiles.py
+++ b/test/profiles.py
@@ -29,7 +29,7 @@ from selenium import webdriver
from selenium.webdriver.firefox.options import Options
import time
-from .misc_constants import *
+from .config import *
def set_profile_proxy(profile, proxy_host, proxy_port):
# proxy type 1 designates "manual"
diff --git a/test/server.py b/test/server.py
index 6013955..460be60 100755
--- a/test/server.py
+++ b/test/server.py
@@ -33,7 +33,7 @@ from urllib.parse import parse_qs
from threading import Thread
from .proxy_core import ProxyRequestHandler, ThreadingHTTPServer
-from .misc_constants import *
+from .config import *
from .world_wide_library import catalog as internet
class RequestHijacker(ProxyRequestHandler):