Skip to content

Commit b009fe7

Browse files
committed
fix(tests): run handlers integration tests in landlock sandbox
1 parent 963f868 commit b009fe7

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

tests/test_handlers.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from unblob import handlers
1616
from unblob.models import Handler
1717
from unblob.processing import ExtractionConfig, process_file
18+
from unblob.sandbox import AccessFS, Sandbox
1819
from unblob.testing import (
1920
check_output_is_the_same,
2021
check_result,
@@ -29,10 +30,28 @@
2930
"input_dir, output_dir", gather_integration_tests(TEST_DATA_PATH)
3031
)
3132
def test_all_handlers(
32-
input_dir: Path, output_dir: Path, extraction_config: ExtractionConfig
33+
input_dir: Path,
34+
output_dir: Path,
35+
extraction_config: ExtractionConfig,
36+
request: pytest.FixtureRequest,
3337
):
38+
log_path = Path("/dev/null") # no logging
39+
report_file = None # no reporting
40+
41+
passthrough = [
42+
# .pytest_cache
43+
AccessFS.read_write(request.config.rootpath),
44+
]
45+
junit_xmlpath = request.config.getvalue("xmlpath")
46+
if junit_xmlpath:
47+
passthrough += [
48+
# junit reports are written to the argument of --junit-xml
49+
AccessFS.read_write(junit_xmlpath) # type: ignore
50+
]
51+
52+
sandbox = Sandbox(extraction_config, log_path, report_file, passthrough)
3453
for input_file in input_dir.iterdir():
35-
reports = process_file(extraction_config, input_file)
54+
reports = sandbox.run(process_file, extraction_config, input_file)
3655
check_result(reports)
3756

3857
check_output_is_the_same(output_dir, extraction_config.extract_root)

0 commit comments

Comments
 (0)