Test refactoring
The testing script is getting too big and not very well organized. In this commit a new module `integration_tests` is introduced that contains parts of the original testing script split into multiple files. The content should be the same, the only difference is that now you can run the tests by invoking `python3 -m test`.
This commit is contained in:
parent
c27cdd5928
commit
ea68bb0c26
14 changed files with 204 additions and 201 deletions
38
test/integration_tests/test_case.py
Normal file
38
test/integration_tests/test_case.py
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
from dataclasses import dataclass
|
||||
from enum import Enum
|
||||
from typing import List, Callable, Any
|
||||
|
||||
from . import evaluate_test, rel_path
|
||||
from .build import run_osbuild
|
||||
from .run import boot_image, extract_image
|
||||
|
||||
|
||||
class IntegrationTestType(Enum):
|
||||
EXTRACT=0
|
||||
BOOT_WITH_QEMU=1
|
||||
|
||||
|
||||
@dataclass
|
||||
class IntegrationTestCase:
|
||||
name: str
|
||||
pipeline: str
|
||||
output_image: str
|
||||
test_cases: List[Callable[[Any], None]]
|
||||
type: IntegrationTestType
|
||||
|
||||
def run(self):
|
||||
run_osbuild(rel_path(f"pipelines/{self.pipeline}"))
|
||||
if self.type == IntegrationTestType.BOOT_WITH_QEMU:
|
||||
self.boot_and_run()
|
||||
else:
|
||||
self.extract_and_run()
|
||||
|
||||
def boot_and_run(self):
|
||||
with boot_image(self.output_image):
|
||||
for test in self.test_cases:
|
||||
evaluate_test(test)
|
||||
|
||||
def extract_and_run(self):
|
||||
with extract_image(self.output_image) as fstree:
|
||||
for test in self.test_cases:
|
||||
evaluate_test(lambda: test(fstree), name=test.__name__)
|
||||
Loading…
Add table
Add a link
Reference in a new issue