From 201fcfadc87e21b0b10ecf3a2a9d114328a65ffb Mon Sep 17 00:00:00 2001 From: jahoti Date: Fri, 3 Dec 2021 00:00:00 +0000 Subject: Support tests outside the source directory Explicitly use certs in the build directory, and tests in the source --- Makefile.in | 12 +++--------- configure | 1 + test/misc_constants.py | 5 ++++- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/Makefile.in b/Makefile.in index e49415d..1e3cdbd 100644 --- a/Makefile.in +++ b/Makefile.in @@ -61,6 +61,7 @@ uninstall: # testing-related targets test/certs/: + [ -d test ] || mkdir test mkdir $@ test/certs/%.key: | test/certs/ @@ -71,17 +72,10 @@ test/certs/rootCA.pem: test/certs/rootCA.key -subj "/CN=Haketilo Test" test: test/certs/rootCA.pem test/certs/site.key - @echo 'Warning: if the build directory is not the same' - @echo 'as the source directory, THIS WILL NOT WORK.' - MOZ_HEADLESS=whatever $(PYTEST) + MOZ_HEADLESS=whatever $(PYTEST) "$(srcdir)" test-environment: test/certs/rootCA.pem test/certs/site.key - @echo 'Warning: if the build directory is not the same' - @echo 'as the source directory, THIS WILL NOT WORK.' - $(PYTHON) -m test - -hello: record.conf - @ls + PYTHONPATH="$(srcdir)" $(PYTHON) -m test # helper targets clean mostlyclean: diff --git a/configure b/configure index 6ac41c9..d6b51bb 100755 --- a/configure +++ b/configure @@ -119,6 +119,7 @@ rm -f testing.conf [ "x$TEST_BROWSER" != x ] && echo BINARY "$TEST_BROWSER" >> testing.conf [ "x$TEST_PROFILE" != x ] && echo TEST_PROFILE "$TEST_PROFILE" >> testing.conf [ "x$TEST_PORT" != x ] && echo TEST_PORT "$TEST_PORT" >> testing.conf +[ "$srcdir" != '.' ] && echo CERT_DIR "$PWD/test/certs" >> 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 3494293..add875d 100644 --- a/test/misc_constants.py +++ b/test/misc_constants.py @@ -43,7 +43,7 @@ default_cert_dir = here / 'certs' # Use user-specified values instead where available try: - with open(str(here.parent / 'testing.conf')) as f: + with open('testing.conf') as f: option = f.readline() while ' ' in option: key, value = option[:-1].split(' ', maxsplit=1) @@ -56,6 +56,9 @@ try: elif key == 'TEST_PORT': default_proxy_port = int(value) + elif key == 'CERT_DIR': + default_cert_dir = Path(value) + else: raise KeyError(key) -- cgit v1.2.3