Project

General

Profile

« Previous | Next » 

Revision 3fcff338

Added by jahoti almost 2 years ago

Make testing configurable

Add options to configure in accordance with #97

View differences:

Makefile.in
70 70
		 -subj "/CN=Haketilo Test"
71 71

  
72 72
test: test/certs/rootCA.pem test/certs/site.key
73
	MOZ_HEADLESS=whatever pytest
73
	MOZ_HEADLESS=whatever $(PYTEST)
74 74

  
75 75
test-environment: test/certs/rootCA.pem test/certs/site.key
76
	python3 -m test
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 testing.conf
89 89

  
90 90
maintainer-clean: distclean
91 91
	@echo 'This command is intended for maintainers to use; it'
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)"
63
	TARGET="$(/etc/alternatives/x-www-browser --version 2> /dev/null |
73
	set_browserpath /etc/alternatives/x-www-browser
74
	TARGET="$("$BROWSERPATH" --version 2> /dev/null |
64 75
	    tail -n 1 | awk '{ print $1 }' | tr [A-Z] [a-z])"
65 76
    else
66 77
    	echo Warning: could not find target automatically. >&2
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
# (Re-)write testing.conf
117
rm -f testing.conf
118
[ "x$BINARY" != x ] && echo BINARY "$BINARY" >> testing.conf
119
[ "x$TEST_PROFILE" != x ] && echo TEST_PROFILE "$TEST_PROFILE" >> testing.conf
120
[ "x$TEST_PORT" != x ] && echo TEST_PORT "$TEST_PORT" >> testing.conf
103 121

  
104 122
# Prepare and run write_makefile.sh (as config.status)
105 123
if [ ! -e config.status ]; then
test/misc_constants.py
41 41

  
42 42
default_cert_dir = here / 'certs'
43 43

  
44
# Use user-specified values instead where available
45
try:
46
	with open(str(here.parent / 'testing.conf')) as f:
47
		option = f.readline()
48
		while ' ' in option:
49
			key, value = option[:-1].split(' ', maxsplit=1)
50
			if key == 'BINARY':
51
				default_firefox_binary = value
52
			
53
			elif key == 'TEST_PROFILE':
54
				default_clean_profile_dir = value
55
			
56
			elif key == 'TEST_PORT':
57
				default_proxy_port = value
58
			
59
			else:
60
				raise KeyError(key)
61
			
62
			option = f.readline()
63
except FileNotFoundError:
64
	# There may be no defaults overridden; that's OK!
65
	pass
66

  
44 67
mime_types = {
45 68
	"7z": "application/x-7z-compressed",	"oga": "audio/ogg",
46 69
	"abw": "application/x-abiword",		"ogv": "video/ogg",

Also available in: Unified diff