tests: Use one store per class instead of per test method
For stages testing it is too slow to rebuild the a image containing @Core packages every time. Let's just reuse the a image for all tests. This should speed up the test running time a LOT.
This commit is contained in:
parent
85ebb084b5
commit
2be0530047
1 changed files with 10 additions and 7 deletions
|
|
@ -13,21 +13,24 @@ class TestCase(unittest.TestCase):
|
|||
"""A TestCase to test running the osbuild program.
|
||||
|
||||
Each test case can use `self.run_osbuild()` to run osbuild. A temporary
|
||||
store is used, which can be accessed through `self.store`.
|
||||
store is used, which can be accessed through `self.store`. The store is
|
||||
persistent for whole test class due to performance concerns.
|
||||
|
||||
To speed up local development, OSBUILD_TEST_STORE can be set to an existing
|
||||
store. Note that this might make tests dependant of each other. Do not use
|
||||
it for actual testing.
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
self.store = os.getenv("OSBUILD_TEST_STORE")
|
||||
if not self.store:
|
||||
self.store = tempfile.mkdtemp(dir="/var/tmp")
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.store = os.getenv("OSBUILD_TEST_STORE")
|
||||
if not cls.store:
|
||||
cls.store = tempfile.mkdtemp(dir="/var/tmp")
|
||||
|
||||
def tearDown(self):
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
if not os.getenv("OSBUILD_TEST_STORE"):
|
||||
shutil.rmtree(self.store)
|
||||
shutil.rmtree(cls.store)
|
||||
|
||||
def run_osbuild(self, pipeline, input=None):
|
||||
osbuild_cmd = ["python3", "-m", "osbuild", "--json", "--store", self.store, "--libdir", ".", pipeline]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue