zeek-btest was retired from Fedora due to build failures. All test files in this package use a single `@TEST-EXEC: python3 %INPUT` directive, so a small pytest plugin (conftest.py) that collects test files and runs each as a subprocess is a complete replacement. Addresses #2485942 Drops the btest.cfg source file and the zeek-btest build dependency.
36 lines
896 B
Python
36 lines
896 B
Python
import subprocess
|
|
import sys
|
|
import pytest
|
|
|
|
|
|
def pytest_collect_file(parent, file_path):
|
|
if file_path.suffix == ".test":
|
|
return BtestFile.from_parent(parent, path=file_path)
|
|
|
|
|
|
class BtestFile(pytest.File):
|
|
def collect(self):
|
|
yield BtestItem.from_parent(self, name=self.path.stem)
|
|
|
|
|
|
class BtestItem(pytest.Item):
|
|
def runtest(self):
|
|
result = subprocess.run(
|
|
[sys.executable, str(self.parent.path)],
|
|
capture_output=True,
|
|
text=True,
|
|
)
|
|
if result.returncode != 0:
|
|
raise BtestFailure(result)
|
|
|
|
def repr_failure(self, excinfo):
|
|
exc = excinfo.value
|
|
return (exc.result.stdout + exc.result.stderr).strip()
|
|
|
|
def reportinfo(self):
|
|
return self.parent.path, None, f"btest: {self.name}"
|
|
|
|
|
|
class BtestFailure(Exception):
|
|
def __init__(self, result):
|
|
self.result = result
|