aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorWojtek Kosior <koszko@koszko.org>2022-01-03 16:25:59 +0100
committerWojtek Kosior <koszko@koszko.org>2022-01-03 16:25:59 +0100
commitc71ebff86fa79b20388749dd4781fd96fcc5c63a (patch)
treeb51e2e80c25912e33ace31fd68888d8bb4a5445c /test
parent0feb9db2b57725d47a7b3cc1e84ba5b9a7553b12 (diff)
downloadbrowser-extension-c71ebff86fa79b20388749dd4781fd96fcc5c63a.tar.gz
browser-extension-c71ebff86fa79b20388749dd4781fd96fcc5c63a.zip
more general way to provide additional lines of code that compute_scripts.awk should process as part of a js file
Diffstat (limited to 'test')
-rw-r--r--test/script_loader.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/test/script_loader.py b/test/script_loader.py
index 53de779..f527d9e 100644
--- a/test/script_loader.py
+++ b/test/script_loader.py
@@ -59,13 +59,16 @@ def load_script(path, code_to_add=None):
a dependency to be substituted by a mocked value.
"""
path = make_relative_path(path)
- key = f'{str(path)}:{code_to_add}' if code_to_add is not None else str(path)
+ key = (str(path), code_to_add)
if key in script_cache:
return script_cache[key]
+ append_flags = () if code_to_add is None else ('-A', ':'.join(key))
+
awk = subprocess.run(['awk', '-f', str(awk_script), '--', '-D', 'MOZILLA',
'-D', 'MV2', '-D', 'TEST', '-D', 'UNIT_TEST',
- '-D', 'DEBUG', '--output=amalgamate-js:' + key],
+ '-D', 'DEBUG', *append_flags,
+ '--output=amalgamate-js:' + str(path)],
stdout=subprocess.PIPE, cwd=script_root, check=True)
script = awk.stdout.decode()
script_cache[key] = script