Revision 5a002642
Added by jahoti almost 2 years ago
- ID 5a0026423b61915fd2f9544456b2634505a952b1
- Parent 6d819aae
Makefile.in | ||
---|---|---|
69 | 69 |
openssl req -x509 -new -nodes -key $< -days 1024 -out $@ \ |
70 | 70 |
-subj "/CN=Haketilo Test" |
71 | 71 |
|
72 |
test: test/certs/rootCA.pem test/certs/site.key |
|
73 |
MOZ_HEADLESS=whatever pytest
|
|
72 |
test: test/certs/rootCA.pem test/certs/site.key test/config.py
|
|
73 |
MOZ_HEADLESS=whatever $(PYTEST)
|
|
74 | 74 |
|
75 |
test-environment: test/certs/rootCA.pem test/certs/site.key |
|
76 |
python3 -m test
|
|
75 |
test-environment: test/certs/rootCA.pem test/certs/site.key test/config.py
|
|
76 |
$(PYTHON) -m test
|
|
77 | 77 |
|
78 | 78 |
# helper targets |
79 | 79 |
clean mostlyclean: |
... | ... | |
85 | 85 |
rm -rf $$(find . -type d -name __pycache__) |
86 | 86 |
|
87 | 87 |
distclean: clean |
88 |
rm -f Makefile config.status record.conf |
|
88 |
rm -f Makefile config.status record.conf test/config.py
|
|
89 | 89 |
|
90 | 90 |
maintainer-clean: distclean |
91 | 91 |
@echo 'This command is intended for maintainers to use; it' |
... | ... | |
107 | 107 |
config.status: write_makefile.sh |
108 | 108 |
cp "$(srcdir)"/write_makefile.sh config.status |
109 | 109 |
|
110 |
test/config.py: |
|
111 |
@echo 'No test/config.py file was found; please re-configure' |
|
112 |
@echo 'before attempting any more make operations.' |
|
113 |
exit 1 |
|
114 |
|
|
110 | 115 |
# Unused GNU-specified targets |
111 | 116 |
install-html: |
112 | 117 |
install-dvi: |
configure | ||
---|---|---|
15 | 15 |
|
16 | 16 |
set -e |
17 | 17 |
|
18 |
# Set BROWSERPATH appropriately |
|
19 |
set_browserpath () { |
|
20 |
BROWSERPATH="${BINARY:-$(realpath "$1")}" |
|
21 |
} |
|
22 |
|
|
23 |
BINARY="$BROWSER_BIN" |
|
18 | 24 |
BROWSERPATH='' |
19 | 25 |
SRCDIR='' |
20 | 26 |
TARGET='' |
... | ... | |
22 | 28 |
# Parse command line options |
23 | 29 |
while [ "x$1" != x ]; do |
24 | 30 |
case "$1" in |
25 |
--srcdir=*) SRCDIR="$(echo "$1" | cut -c 10-)";; |
|
26 |
--srcdir) SRCDIR="$2"; shift;; |
|
27 |
"DESTDIR"=*) DESTDIR="$(echo "$1" | cut -c 9-)";; |
|
28 |
"UPDATE_URL"=*) UPDATE_URL="$(echo "$1" | cut -c 12-)";; |
|
29 |
--host=*) TARGET="$(echo "$1" | cut -c 8-)";; |
|
30 |
--host) TARGET="$2"; shift;; |
|
31 |
--srcdir=*) SRCDIR="$(echo "$1" | cut -c 10-)";; |
|
32 |
--srcdir) SRCDIR="$2"; shift;; |
|
33 |
BROWSER_BIN=*) BINARY="$(echo "$1" | cut -c 13-)";; |
|
34 |
DESTDIR=*) DESTDIR="$(echo "$1" | cut -c 9-)";; |
|
35 |
PYTEST=*) PYTEST="$(echo "$1" | cut -c 8-)";; |
|
36 |
PYTHON=*) PYTHON="$(echo "$1" | cut -c 8-)";; |
|
37 |
TEST_PORT=*) TEST_PORT="$(echo "$1" | cut -c 11-)";; |
|
38 |
TEST_PROFILE=*) TEST_PROFILE="$(echo "$1" | cut -c 14-)";; |
|
39 |
UPDATE_URL=*) UPDATE_URL="$(echo "$1" | cut -c 12-)";; |
|
40 |
--host=*) TARGET="$(echo "$1" | cut -c 8-)";; |
|
41 |
--host) TARGET="$2"; shift;; |
|
31 | 42 |
|
32 | 43 |
# browsers |
33 | 44 |
chromium | chrome | google-chrome | mozilla |\ |
34 | 45 |
firefox | librewolf | icecat | iceweasel | abrowser |\ |
35 |
iceweasel-uxp | tor-browser) TARGET=$1;; |
|
36 |
*) echo Ignoring option "'$1'";; |
|
46 |
iceweasel-uxp | tor-browser) TARGET=$1;;
|
|
47 |
*) echo Ignoring option "'$1'";;
|
|
37 | 48 |
esac |
38 | 49 |
shift |
39 | 50 |
done |
... | ... | |
59 | 70 |
if [ "x$TARGET" = x ]; then |
60 | 71 |
echo Detecting target automatically. |
61 | 72 |
if [ -h /etc/alternatives/x-www-browser ]; then |
62 |
BROWSERPATH="$(realpath /etc/alternatives/x-www-browser)"
|
|
73 |
set_browserpath /etc/alternatives/x-www-browser
|
|
63 | 74 |
TARGET="$(/etc/alternatives/x-www-browser --version 2> /dev/null | |
64 | 75 |
tail -n 1 | awk '{ print $1 }' | tr [A-Z] [a-z])" |
65 | 76 |
else |
... | ... | |
67 | 78 |
echo Some make rules may fail. >&2 |
68 | 79 |
fi |
69 | 80 |
else |
70 |
BROWSERPATH="$(realpath "$(which $TARGET)")"
|
|
81 |
set_browserpath "$(which $TARGET)"
|
|
71 | 82 |
fi |
72 | 83 |
|
73 | 84 |
# Check and standardize target |
... | ... | |
98 | 109 |
echo srcdir = "$SRCDIR" > record.conf |
99 | 110 |
echo default_target = "$TARGET" >> record.conf |
100 | 111 |
echo DESTDIR = "$DESTDIR" >> record.conf |
112 |
echo PYTEST = "${PYTEST:-$(which pytest)}" >> record.conf |
|
113 |
echo PYTHON = "${PYTHON:-$(which python3)}" >> record.conf |
|
101 | 114 |
echo UPDATE_URL = "$UPDATE_URL" >> record.conf |
102 | 115 |
|
116 |
# Write test/config.py (if testing is enabled) |
|
117 |
echo from .misc_constants import '*' > test/config.py |
|
118 |
echo default_firefox_binary = "'${BINARY:-/usr/lib/icecat/icecat}'" >> test/config.py |
|
119 |
echo default_clean_profile_dir = "'$TEST_PROFILE'" or \ |
|
120 |
default_clean_profile_dir >> test/config.py |
|
121 |
echo default_proxy_port = "${TEST_PORT:-1337}" >> test/config.py |
|
122 |
|
|
103 | 123 |
|
104 | 124 |
# Prepare and run write_makefile.sh (as config.status) |
105 | 125 |
if [ ! -e config.status ]; then |
test/__main__.py | ||
---|---|---|
32 | 32 |
import code |
33 | 33 |
|
34 | 34 |
from .server import do_an_internet |
35 |
from .misc_constants import *
|
|
35 |
from .config import *
|
|
36 | 36 |
from .profiles import firefox_safe_mode |
37 | 37 |
|
38 | 38 |
def fail(msg, error_code): |
test/profiles.py | ||
---|---|---|
29 | 29 |
from selenium.webdriver.firefox.options import Options |
30 | 30 |
import time |
31 | 31 |
|
32 |
from .misc_constants import *
|
|
32 |
from .config import *
|
|
33 | 33 |
|
34 | 34 |
def set_profile_proxy(profile, proxy_host, proxy_port): |
35 | 35 |
# proxy type 1 designates "manual" |
test/server.py | ||
---|---|---|
33 | 33 |
from threading import Thread |
34 | 34 |
|
35 | 35 |
from .proxy_core import ProxyRequestHandler, ThreadingHTTPServer |
36 |
from .misc_constants import *
|
|
36 |
from .config import *
|
|
37 | 37 |
from .world_wide_library import catalog as internet |
38 | 38 |
|
39 | 39 |
class RequestHijacker(ProxyRequestHandler): |
Also available in: Unified diff
Allow testing behavior to be customized
Adds PYTEST, PYTHON, BROWSER_BIN, TEST_PORT, and TEST_PROFILE variables
to configure.