test: use OSBUILD_TEST_STORE in test_assemblers.py too

Use the OSBUILD_TEST_STORE in the test_assemblers.py file too
and re-use already downloaded sources.
This commit is contained in:
Michael Vogt 2024-03-04 16:02:30 +01:00 committed by Simon de Vlieger
parent 95c1b90d33
commit 4d2476a26d
2 changed files with 14 additions and 5 deletions

View file

@ -62,5 +62,6 @@ jobs:
with:
image: ghcr.io/osbuild/osbuild-ci:latest-202308241910
run: |
export OSBUILD_TEST_STORE=/var/tmp/osbuild-test-store
TEST_CATEGORY="test.run.test_assemblers" \
tox -e "py36"
tox -e "py36"

View file

@ -20,7 +20,9 @@ MEBIBYTE = 1024 * 1024
@pytest.fixture(name="osbuild")
def osbuild_fixture():
yield test.OSBuild()
store = os.getenv("OSBUILD_TEST_STORE")
osb = test.OSBuild(cache_from=store)
yield osb
def assertImageFile(filename, fmt, expected_size):
@ -307,6 +309,12 @@ def run_assembler(osb, name, options, output_path):
assert treeid
with tempfile.TemporaryDirectory(dir="/var/tmp") as output_dir:
osb.compile(data, output_dir=output_dir, exports=["assembler", "tree"], checkpoints=["tree"])
tree = os.path.join(output_dir, "tree")
yield tree, os.path.join(output_dir, "assembler", output_path)
try:
osb.compile(data, output_dir=output_dir, exports=["assembler", "tree"], checkpoints=["tree"])
tree = os.path.join(output_dir, "tree")
yield tree, os.path.join(output_dir, "assembler", output_path)
finally:
# re-use downloaded sources
store = os.getenv("OSBUILD_TEST_STORE")
if store:
osb.copy_source_data(store, "org.osbuild.files")