Skip to content

Commit

Permalink
tests: Use one store per class instead of per test method
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ondrejbudai committed Oct 7, 2019
1 parent 9ef91e1 commit 0fe93c8
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions test/osbuildtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit 0fe93c8

Please sign in to comment.