diff options
-rw-r--r-- | Makefile.in | 50 | ||||
-rwxr-xr-x | build.sh | 2 | ||||
-rw-r--r-- | pytest.ini.in (renamed from pytest.ini) | 6 | ||||
-rw-r--r-- | test/haketilo_test/__init__.py (renamed from test/__init__.py) | 0 | ||||
-rw-r--r-- | test/haketilo_test/__main__.py (renamed from test/__main__.py) | 0 | ||||
-rw-r--r-- | test/haketilo_test/conftest.py (renamed from test/conftest.py) | 4 | ||||
-rw-r--r-- | test/haketilo_test/data/pages/gotmyowndomain.html (renamed from test/data/pages/gotmyowndomain.html) | 0 | ||||
-rw-r--r-- | test/haketilo_test/data/pages/gotmyowndomain_https.html (renamed from test/data/pages/gotmyowndomain_https.html) | 0 | ||||
-rw-r--r-- | test/haketilo_test/data/pages/scripts_to_block_1.html (renamed from test/data/pages/scripts_to_block_1.html) | 0 | ||||
-rw-r--r-- | test/haketilo_test/default_profiles/icecat_empty/extensions.json (renamed from test/default_profiles/icecat_empty/extensions.json) | 0 | ||||
-rw-r--r-- | test/haketilo_test/extension_crafting.py (renamed from test/extension_crafting.py) | 4 | ||||
-rw-r--r-- | test/haketilo_test/misc_constants.py (renamed from test/misc_constants.py) | 6 | ||||
-rwxr-xr-x | test/haketilo_test/profiles.py (renamed from test/profiles.py) | 0 | ||||
-rw-r--r-- | test/haketilo_test/proxy_core.py (renamed from test/proxy_core.py) | 0 | ||||
-rw-r--r-- | test/haketilo_test/script_loader.py (renamed from test/script_loader.py) | 4 | ||||
-rwxr-xr-x | test/haketilo_test/server.py (renamed from test/server.py) | 3 | ||||
-rw-r--r-- | test/haketilo_test/test_integration.py (renamed from test/test_integration.py) | 0 | ||||
-rw-r--r-- | test/haketilo_test/unit/__init__.py (renamed from test/unit/__init__.py) | 0 | ||||
-rw-r--r-- | test/haketilo_test/unit/test_CORS_bypass_server.py (renamed from test/unit/test_CORS_bypass_server.py) | 0 | ||||
-rw-r--r-- | test/haketilo_test/unit/test_basic.py (renamed from test/unit/test_basic.py) | 0 | ||||
-rw-r--r-- | test/haketilo_test/unit/test_broadcast.py (renamed from test/unit/test_broadcast.py) | 0 | ||||
-rw-r--r-- | test/haketilo_test/unit/test_content.py (renamed from test/unit/test_content.py) | 0 | ||||
-rw-r--r-- | test/haketilo_test/unit/test_default_policy_dialog.py (renamed from test/unit/test_default_policy_dialog.py) | 0 | ||||
-rw-r--r-- | test/haketilo_test/unit/test_dialog.py (renamed from test/unit/test_dialog.py) | 0 | ||||
-rw-r--r-- | test/haketilo_test/unit/test_indexeddb.py (renamed from test/unit/test_indexeddb.py) | 0 | ||||
-rw-r--r-- | test/haketilo_test/unit/test_indexeddb_files_server.py (renamed from test/unit/test_indexeddb_files_server.py) | 0 | ||||
-rw-r--r-- | test/haketilo_test/unit/test_install.py (renamed from test/unit/test_install.py) | 0 | ||||
-rw-r--r-- | test/haketilo_test/unit/test_item_list.py (renamed from test/unit/test_item_list.py) | 0 | ||||
-rw-r--r-- | test/haketilo_test/unit/test_item_preview.py (renamed from test/unit/test_item_preview.py) | 0 | ||||
-rw-r--r-- | test/haketilo_test/unit/test_patterns.py (renamed from test/unit/test_patterns.py) | 0 | ||||
-rw-r--r-- | test/haketilo_test/unit/test_patterns_query_manager.py (renamed from test/unit/test_patterns_query_manager.py) | 0 | ||||
-rw-r--r-- | test/haketilo_test/unit/test_patterns_query_tree.py (renamed from test/unit/test_patterns_query_tree.py) | 0 | ||||
-rw-r--r-- | test/haketilo_test/unit/test_payload_create.py (renamed from test/unit/test_payload_create.py) | 0 | ||||
-rw-r--r-- | test/haketilo_test/unit/test_policy_deciding.py (renamed from test/unit/test_policy_deciding.py) | 0 | ||||
-rw-r--r-- | test/haketilo_test/unit/test_policy_enforcing.py (renamed from test/unit/test_policy_enforcing.py) | 0 | ||||
-rw-r--r-- | test/haketilo_test/unit/test_popup.py (renamed from test/unit/test_popup.py) | 0 | ||||
-rw-r--r-- | test/haketilo_test/unit/test_repo_query.py (renamed from test/unit/test_repo_query.py) | 0 | ||||
-rw-r--r-- | test/haketilo_test/unit/test_repo_query_cacher.py (renamed from test/unit/test_repo_query_cacher.py) | 0 | ||||
-rw-r--r-- | test/haketilo_test/unit/test_settings.py (renamed from test/unit/test_settings.py) | 0 | ||||
-rw-r--r-- | test/haketilo_test/unit/test_text_entry_list.py (renamed from test/unit/test_text_entry_list.py) | 0 | ||||
-rw-r--r-- | test/haketilo_test/unit/test_webrequest.py (renamed from test/unit/test_webrequest.py) | 0 | ||||
-rw-r--r-- | test/haketilo_test/unit/utils.py (renamed from test/unit/utils.py) | 0 | ||||
-rw-r--r-- | test/haketilo_test/world_wide_library.py (renamed from test/world_wide_library.py) | 2 |
43 files changed, 38 insertions, 43 deletions
diff --git a/Makefile.in b/Makefile.in index 28ccb85..862c610 100644 --- a/Makefile.in +++ b/Makefile.in @@ -17,9 +17,10 @@ VPATH = <<VPATH>> version = <<VERSION>> extension_files = background/ common/ content/ html/ licenses/ \ - copyright default_settings.json manifest.json + icons/ copyright default_settings.json manifest.json -metafiles = build.sh configure Makefile.in process_html_file.sh README.txt \ + +metafiles = build.sh configure Makefile.in compute_scripts.awk README.txt \ re-generate_icons.sh shell_utils.sh upload_amo.sh write_makefile.sh # Configuration gets included here by write_makefile.sh @@ -47,11 +48,11 @@ chromium: chromium-build.zip unpacked: $(default_target)-unpacked Makefile all-unpacked: mozilla-unpacked chromium-unpacked %-unpacked: $(extension_files) icons/haketilo16.png - $(srcdir)/build.sh $* $(srcdir) $(UPDATE_URL) + "$(srcdir)/build.sh" $* $(srcdir) $(UPDATE_URL) install install-strip: $(default_target)-unpacked cp -R $(default_target)-unpacked \ - "$(DESTDIR)/{6fe13369-88e9-440f-b837-5012fb3bedec}" + "$(DESTDIR)/{6fe13369-88e9-440f-b837-5012fb3bedec}" uninstall: rm -r "$(DESTDIR)/{6fe13369-88e9-440f-b837-5012fb3bedec}" @@ -59,37 +60,37 @@ uninstall: %-build.zip: %-unpacked Makefile cd $< && zip -q -r ../$@ * -test/: - mkdir $@ - -test/certs/: | test/ +certs/: mkdir $@ -test/certs/%.key: | test/certs/ +certs/%.key: | certs/ openssl genrsa -out $@ 2048 -test/certs/rootCA.pem: test/certs/rootCA.key +certs/rootCA.pem: 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 $(default_target)-build.zip - MOZ_HEADLESS=whatever $(PYTHON) -m pytest +pytest.ini: pytest.ini.in + sed "s|<<SRCDIR>>|$(srcdir)|" <$< > $@ -test-environment: test/certs/rootCA.pem test/certs/site.key - python3 -m test +test: certs/rootCA.pem certs/site.key $(default_target)-build.zip \ + pytest.ini + PYTHONPYCACHEPREFIX=$$(pwd)/test__pycache__ MOZ_HEADLESS=whatever \ + "$(PYTHON)" -m pytest -test-environment-with-haketilo: test/certs/rootCA.pem test/certs/site.key \ +test-environment: certs/rootCA.pem certs/site.key + "$(PYTHON)" -m test + +test-environment-with-haketilo: certs/rootCA.pem certs/site.key \ $(default_target)-build.zip - python3 -m test --load-haketilo + "$(PYTHON)" -m test --load-haketilo # helper targets clean mostlyclean: rm -rf mozilla-unpacked chromium-unpacked haketilo-[1-9]* rm -f mozilla-build.zip chromium-build.zip exports_init.js - rm -rf test/certs - rm -rf $$(find . -name geckodriver.log) - rm -rf $$(find . -type d -name __pycache__) - rm -rf $$(find . -type d -name injected_scripts) + rm -rf pytest.ini certs injected_scripts geckodriver.log + rm -rf certs/ test__pycache__/ .pytest_cache/ distclean: clean rm -f Makefile config.status record.conf @@ -99,14 +100,6 @@ maintainer-clean: distclean @echo 'deletes files that may need special tools to rebuild.' rm -f "$(srcdir)"/icons/*.png -dist: $(extension_files) $(metafiles) icons/haketilo16.png - test -d haketilo-$(version) || mkdir haketilo-$(version) - for file in $(extension_files) $(metafiles) icons/; do \ - cp -R "$(srcdir)"/$$file haketilo-$(version); \ - done - tar cf haketilo-$(version).tar haketilo-$(version) - gzip haketilo-$(version).tar - # Files for constructing the makefile Makefile: config.status Makefile.in record.conf ./config.status @@ -115,6 +108,7 @@ config.status: write_makefile.sh cp "$(srcdir)"/write_makefile.sh config.status # Unused GNU-specified targets +dist: install-html: install-dvi: install-pdf: @@ -15,8 +15,6 @@ set -e -. ./shell_utils.sh - print_usage() { printf 'usage: %s mozilla|chromium [source directory] [update url]\n' \ "$0" >&2 diff --git a/pytest.ini b/pytest.ini.in index 1057a9a..ea0b58f 100644 --- a/pytest.ini +++ b/pytest.ini.in @@ -2,7 +2,7 @@ # This file is part of Haketilo # -# Copyright (C) 2021, Wojtek Kosior +# Copyright (C) 2021, 2022 Wojtek Kosior <koszko@koszko.org> # # This program is free software: you can redistribute it and/or modify # it under the terms of the CC0 1.0 Universal License as published by @@ -17,4 +17,6 @@ markers = ext_data: define a custom testing extension for `webextension` fixture. get_page: define a url the `driver` fixture should navigate the browser to. - second_driver: tell `driver` fixture to spawn a separate browser instance fr this test. + second_driver: tell `driver` fixture to spawn a separate browser instance for this test. +testpaths = + <<SRCDIR>>/test/haketilo_test diff --git a/test/__init__.py b/test/haketilo_test/__init__.py index 2b351bb..2b351bb 100644 --- a/test/__init__.py +++ b/test/haketilo_test/__init__.py diff --git a/test/__main__.py b/test/haketilo_test/__main__.py index 7afda55..7afda55 100644 --- a/test/__main__.py +++ b/test/haketilo_test/__main__.py diff --git a/test/conftest.py b/test/haketilo_test/conftest.py index c0ece61..9103ac8 100644 --- a/test/conftest.py +++ b/test/haketilo_test/conftest.py @@ -36,7 +36,7 @@ from .profiles import firefox_safe_mode from .server import do_an_internet from .extension_crafting import make_extension from .world_wide_library import start_serving_script, dump_scripts -from .misc_constants import here +from .misc_constants import proj_root @pytest.fixture(scope="session") def proxy(): @@ -108,7 +108,7 @@ def webextension(driver, request): @pytest.fixture() def haketilo(driver): - addon_id = driver.install_addon(str(here.parent / 'mozilla-build.zip'), + addon_id = driver.install_addon(str(Path.cwd() / 'mozilla-build.zip'), temporary=True) yield diff --git a/test/data/pages/gotmyowndomain.html b/test/haketilo_test/data/pages/gotmyowndomain.html index 390cbcc..390cbcc 100644 --- a/test/data/pages/gotmyowndomain.html +++ b/test/haketilo_test/data/pages/gotmyowndomain.html diff --git a/test/data/pages/gotmyowndomain_https.html b/test/haketilo_test/data/pages/gotmyowndomain_https.html index f602950..f602950 100644 --- a/test/data/pages/gotmyowndomain_https.html +++ b/test/haketilo_test/data/pages/gotmyowndomain_https.html diff --git a/test/data/pages/scripts_to_block_1.html b/test/haketilo_test/data/pages/scripts_to_block_1.html index 164979d..164979d 100644 --- a/test/data/pages/scripts_to_block_1.html +++ b/test/haketilo_test/data/pages/scripts_to_block_1.html diff --git a/test/default_profiles/icecat_empty/extensions.json b/test/haketilo_test/default_profiles/icecat_empty/extensions.json index 5f74ff3..5f74ff3 100644 --- a/test/default_profiles/icecat_empty/extensions.json +++ b/test/haketilo_test/default_profiles/icecat_empty/extensions.json diff --git a/test/extension_crafting.py b/test/haketilo_test/extension_crafting.py index 680c45e..97f5027 100644 --- a/test/extension_crafting.py +++ b/test/haketilo_test/extension_crafting.py @@ -106,11 +106,11 @@ class ExtraHTML: ['awk', '-f', awk_script_name, '--', *unit_test_defines, *append_flags, '-H', self.html_path, '--write-js-deps', '--output=files-to-copy', f'--output-dir={tmpdir}'], - stdout=subprocess.PIPE, cwd=script_root, check=True + stdout=subprocess.PIPE, cwd=proj_root, check=True ) for path in filter(None, awk.stdout.decode().split('\n')): - xpi.write(script_root / path, path) + xpi.write(proj_root / path, path) tmpdir = Path(tmpdir) for path in tmpdir.rglob('*'): diff --git a/test/misc_constants.py b/test/haketilo_test/misc_constants.py index 96bc9e0..9cac9dc 100644 --- a/test/misc_constants.py +++ b/test/haketilo_test/misc_constants.py @@ -31,7 +31,7 @@ import re from pathlib import Path here = Path(__file__).resolve().parent -script_root = here.parent +proj_root = here.parent.parent awk_script_name = 'compute_scripts.awk' unit_test_defines = ['-D', 'MOZILLA', '-D', 'MV2', '-D', 'TEST', @@ -39,7 +39,7 @@ unit_test_defines = ['-D', 'MOZILLA', '-D', 'MV2', '-D', 'TEST', conf_line_regex = re.compile(r'^([^=]+) = (.*)$') conf_settings = {} -with open(here.parent / 'record.conf', 'rt') as conf: +with open(Path.cwd() / 'record.conf', 'rt') as conf: for line in conf.readlines(): match = conf_line_regex.match(line) if match: @@ -48,7 +48,7 @@ with open(here.parent / 'record.conf', 'rt') as conf: default_proxy_host = '127.0.0.1' default_proxy_port = 1337 -default_cert_dir = here / 'certs' +default_cert_dir = proj_root / 'test' / 'certs' default_extension_uuid = 'a1291446-be95-48ad-a4c6-a475e389399b' default_haketilo_id = '{6fe13369-88e9-440f-b837-5012fb3bedec}' diff --git a/test/profiles.py b/test/haketilo_test/profiles.py index ae997fc..ae997fc 100755 --- a/test/profiles.py +++ b/test/haketilo_test/profiles.py diff --git a/test/proxy_core.py b/test/haketilo_test/proxy_core.py index f6bb820..f6bb820 100644 --- a/test/proxy_core.py +++ b/test/haketilo_test/proxy_core.py diff --git a/test/script_loader.py b/test/haketilo_test/script_loader.py index cc73d4c..66130bb 100644 --- a/test/script_loader.py +++ b/test/haketilo_test/script_loader.py @@ -34,7 +34,7 @@ def make_relative_path(path): path = Path(path) if path.is_absolute(): - path = path.relative_to(script_root) + path = path.relative_to(proj_root) return path @@ -65,7 +65,7 @@ def load_script(path, code_to_add=None): awk = subprocess.run(['awk', '-f', awk_script_name, '--', *unit_test_defines, *append_flags, '--output=amalgamate-js:' + str(path)], - stdout=subprocess.PIPE, cwd=script_root, check=True) + stdout=subprocess.PIPE, cwd=proj_root, check=True) script = awk.stdout.decode() script_cache[key] = script diff --git a/test/server.py b/test/haketilo_test/server.py index 0963b5b..7dc5e9e 100755 --- a/test/server.py +++ b/test/haketilo_test/server.py @@ -99,7 +99,8 @@ class RequestHijacker(ProxyRequestHandler): if resp_body: self.wfile.write(resp_body) -def do_an_internet(certdir=default_cert_dir, port=default_proxy_port): +def do_an_internet(certdir=Path.cwd() / 'certs', + port=default_proxy_port): """Start up the proxy/server""" class RequestHijackerWithCertdir(RequestHijacker): def __init__(self, *args, **kwargs): diff --git a/test/test_integration.py b/test/haketilo_test/test_integration.py index 87d1827..87d1827 100644 --- a/test/test_integration.py +++ b/test/haketilo_test/test_integration.py diff --git a/test/unit/__init__.py b/test/haketilo_test/unit/__init__.py index 2b351bb..2b351bb 100644 --- a/test/unit/__init__.py +++ b/test/haketilo_test/unit/__init__.py diff --git a/test/unit/test_CORS_bypass_server.py b/test/haketilo_test/unit/test_CORS_bypass_server.py index 45e4ebb..45e4ebb 100644 --- a/test/unit/test_CORS_bypass_server.py +++ b/test/haketilo_test/unit/test_CORS_bypass_server.py diff --git a/test/unit/test_basic.py b/test/haketilo_test/unit/test_basic.py index 6ec54cc..6ec54cc 100644 --- a/test/unit/test_basic.py +++ b/test/haketilo_test/unit/test_basic.py diff --git a/test/unit/test_broadcast.py b/test/haketilo_test/unit/test_broadcast.py index 7c2c051..7c2c051 100644 --- a/test/unit/test_broadcast.py +++ b/test/haketilo_test/unit/test_broadcast.py diff --git a/test/unit/test_content.py b/test/haketilo_test/unit/test_content.py index 8220160..8220160 100644 --- a/test/unit/test_content.py +++ b/test/haketilo_test/unit/test_content.py diff --git a/test/unit/test_default_policy_dialog.py b/test/haketilo_test/unit/test_default_policy_dialog.py index a1c825f..a1c825f 100644 --- a/test/unit/test_default_policy_dialog.py +++ b/test/haketilo_test/unit/test_default_policy_dialog.py diff --git a/test/unit/test_dialog.py b/test/haketilo_test/unit/test_dialog.py index 63af79e..63af79e 100644 --- a/test/unit/test_dialog.py +++ b/test/haketilo_test/unit/test_dialog.py diff --git a/test/unit/test_indexeddb.py b/test/haketilo_test/unit/test_indexeddb.py index c2d5427..c2d5427 100644 --- a/test/unit/test_indexeddb.py +++ b/test/haketilo_test/unit/test_indexeddb.py diff --git a/test/unit/test_indexeddb_files_server.py b/test/haketilo_test/unit/test_indexeddb_files_server.py index 6ddfba8..6ddfba8 100644 --- a/test/unit/test_indexeddb_files_server.py +++ b/test/haketilo_test/unit/test_indexeddb_files_server.py diff --git a/test/unit/test_install.py b/test/haketilo_test/unit/test_install.py index f4bc483..f4bc483 100644 --- a/test/unit/test_install.py +++ b/test/haketilo_test/unit/test_install.py diff --git a/test/unit/test_item_list.py b/test/haketilo_test/unit/test_item_list.py index 35ed1d5..35ed1d5 100644 --- a/test/unit/test_item_list.py +++ b/test/haketilo_test/unit/test_item_list.py diff --git a/test/unit/test_item_preview.py b/test/haketilo_test/unit/test_item_preview.py index fe9a98e..fe9a98e 100644 --- a/test/unit/test_item_preview.py +++ b/test/haketilo_test/unit/test_item_preview.py diff --git a/test/unit/test_patterns.py b/test/haketilo_test/unit/test_patterns.py index f2eeaf8..f2eeaf8 100644 --- a/test/unit/test_patterns.py +++ b/test/haketilo_test/unit/test_patterns.py diff --git a/test/unit/test_patterns_query_manager.py b/test/haketilo_test/unit/test_patterns_query_manager.py index 9fbc438..9fbc438 100644 --- a/test/unit/test_patterns_query_manager.py +++ b/test/haketilo_test/unit/test_patterns_query_manager.py diff --git a/test/unit/test_patterns_query_tree.py b/test/haketilo_test/unit/test_patterns_query_tree.py index 80bf554..80bf554 100644 --- a/test/unit/test_patterns_query_tree.py +++ b/test/haketilo_test/unit/test_patterns_query_tree.py diff --git a/test/unit/test_payload_create.py b/test/haketilo_test/unit/test_payload_create.py index 9689c37..9689c37 100644 --- a/test/unit/test_payload_create.py +++ b/test/haketilo_test/unit/test_payload_create.py diff --git a/test/unit/test_policy_deciding.py b/test/haketilo_test/unit/test_policy_deciding.py index 75b35ac..75b35ac 100644 --- a/test/unit/test_policy_deciding.py +++ b/test/haketilo_test/unit/test_policy_deciding.py diff --git a/test/unit/test_policy_enforcing.py b/test/haketilo_test/unit/test_policy_enforcing.py index 4b7c173..4b7c173 100644 --- a/test/unit/test_policy_enforcing.py +++ b/test/haketilo_test/unit/test_policy_enforcing.py diff --git a/test/unit/test_popup.py b/test/haketilo_test/unit/test_popup.py index 1fc262c..1fc262c 100644 --- a/test/unit/test_popup.py +++ b/test/haketilo_test/unit/test_popup.py diff --git a/test/unit/test_repo_query.py b/test/haketilo_test/unit/test_repo_query.py index c8c4875..c8c4875 100644 --- a/test/unit/test_repo_query.py +++ b/test/haketilo_test/unit/test_repo_query.py diff --git a/test/unit/test_repo_query_cacher.py b/test/haketilo_test/unit/test_repo_query_cacher.py index 5fbc5cd..5fbc5cd 100644 --- a/test/unit/test_repo_query_cacher.py +++ b/test/haketilo_test/unit/test_repo_query_cacher.py diff --git a/test/unit/test_settings.py b/test/haketilo_test/unit/test_settings.py index 7cdb76f..7cdb76f 100644 --- a/test/unit/test_settings.py +++ b/test/haketilo_test/unit/test_settings.py diff --git a/test/unit/test_text_entry_list.py b/test/haketilo_test/unit/test_text_entry_list.py index 3135a59..3135a59 100644 --- a/test/unit/test_text_entry_list.py +++ b/test/haketilo_test/unit/test_text_entry_list.py diff --git a/test/unit/test_webrequest.py b/test/haketilo_test/unit/test_webrequest.py index fb24b3d..fb24b3d 100644 --- a/test/unit/test_webrequest.py +++ b/test/haketilo_test/unit/test_webrequest.py diff --git a/test/unit/utils.py b/test/haketilo_test/unit/utils.py index b27a209..b27a209 100644 --- a/test/unit/utils.py +++ b/test/haketilo_test/unit/utils.py diff --git a/test/world_wide_library.py b/test/haketilo_test/world_wide_library.py index 1e802ab..1eb826e 100644 --- a/test/world_wide_library.py +++ b/test/haketilo_test/world_wide_library.py @@ -75,7 +75,7 @@ def serve_script(command, get_params, post_params): return 200, {'Content-Type': 'application/javascript'}, script -def dump_scripts(directory='./injected_scripts'): +def dump_scripts(directory=(Path.cwd() / 'injected_scripts')): """ Write all scripts that have been registered with start_serving_script() under the provided directory. If the directory already exists, it is wiped |