test: use and require explicit exports
Require all the tests that compile a manifest to either specify checkpoints or exports. Convert all the tests that were relying on implicit exports with v1 manifests to use explicit exports.
This commit is contained in:
parent
22d1d46ec1
commit
7ae4a7e785
4 changed files with 22 additions and 12 deletions
|
|
@ -41,9 +41,9 @@ class TestAssemblers(test.TestBase):
|
|||
assert treeid
|
||||
|
||||
with tempfile.TemporaryDirectory(dir="/var/tmp") as output_dir:
|
||||
osb.compile(data, output_dir=output_dir, checkpoints=[treeid])
|
||||
osb.compile(data, output_dir=output_dir, checkpoints=[treeid], exports=["assembler"])
|
||||
with osb.map_object(treeid) as tree:
|
||||
yield tree, os.path.join(output_dir, output_path)
|
||||
yield tree, os.path.join(output_dir, "assembler", output_path)
|
||||
|
||||
def assertImageFile(self, filename, fmt, expected_size=None):
|
||||
info = json.loads(subprocess.check_output(["qemu-img", "info", "--output", "json", filename]))
|
||||
|
|
@ -118,9 +118,9 @@ class TestAssemblers(test.TestBase):
|
|||
|
||||
data = json.dumps(manifest)
|
||||
with tempfile.TemporaryDirectory(dir="/var/tmp") as output_dir:
|
||||
result = osb.compile(data, output_dir=output_dir)
|
||||
compose_file = os.path.join(output_dir, "compose.json")
|
||||
repo = os.path.join(output_dir, "repo")
|
||||
result = osb.compile(data, output_dir=output_dir, exports=["assembler"])
|
||||
compose_file = os.path.join(output_dir, "assembler", "compose.json")
|
||||
repo = os.path.join(output_dir, "assembler", "repo")
|
||||
|
||||
with open(compose_file) as f:
|
||||
compose = json.load(f)
|
||||
|
|
|
|||
|
|
@ -26,8 +26,8 @@ class TestBoot(test.TestBase):
|
|||
|
||||
with self.osbuild as osb:
|
||||
with tempfile.TemporaryDirectory(dir="/var/tmp") as temp_dir:
|
||||
osb.compile_file(manifest, output_dir=temp_dir)
|
||||
qcow2 = os.path.join(temp_dir, "fedora-boot.qcow2")
|
||||
osb.compile_file(manifest, output_dir=temp_dir, exports=["assembler"])
|
||||
qcow2 = os.path.join(temp_dir, "assembler", "fedora-boot.qcow2")
|
||||
output_file = os.path.join(temp_dir, "output")
|
||||
|
||||
subprocess.run(["qemu-system-x86_64",
|
||||
|
|
|
|||
|
|
@ -1,12 +1,14 @@
|
|||
#
|
||||
# Runtime Tests for No-op Pipelines
|
||||
#
|
||||
|
||||
import json
|
||||
import tempfile
|
||||
import pytest
|
||||
|
||||
from .. import test
|
||||
|
||||
|
||||
@pytest.fixture(name="jsondata", scope="module")
|
||||
def jsondata_fixture():
|
||||
return json.dumps({
|
||||
|
|
@ -33,6 +35,7 @@ def jsondata_fixture():
|
|||
]
|
||||
})
|
||||
|
||||
|
||||
@pytest.fixture(name="tmpdir", scope="module")
|
||||
def tmpdir_fixture():
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
|
|
@ -52,14 +55,18 @@ def osbuild_fixture():
|
|||
# Then run the entire thing again, to verify our own `osbuild` executor
|
||||
# tears things down properly and allows to be executed multiple times.
|
||||
#
|
||||
|
||||
|
||||
def test_noop(osb):
|
||||
osb.compile("{}")
|
||||
osb.compile("{}")
|
||||
osb.compile("{}", checkpoints=[])
|
||||
osb.compile("{}", checkpoints=[])
|
||||
|
||||
|
||||
def test_noop2(osb):
|
||||
osb.compile("{}")
|
||||
osb.compile("{}")
|
||||
osb.compile("{}", checkpoints=[])
|
||||
osb.compile("{}", checkpoints=[])
|
||||
|
||||
|
||||
@pytest.mark.skipif(not test.TestBase.can_bind_mount(), reason="root-only")
|
||||
def test_noop_v2(osb, tmpdir, jsondata):
|
||||
osb.compile(jsondata, output_dir=tmpdir)
|
||||
osb.compile(jsondata, output_dir=tmpdir, exports=["noop"])
|
||||
|
|
|
|||
|
|
@ -288,6 +288,9 @@ class OSBuild(contextlib.AbstractContextManager):
|
|||
Returns the build result as dictionary.
|
||||
"""
|
||||
|
||||
if checkpoints is None and exports is None:
|
||||
raise ValueError("Need `checkpoints` or `exports` argument")
|
||||
|
||||
if output_dir is None:
|
||||
output_dir_context = tempfile.TemporaryDirectory(dir="/var/tmp")
|
||||
else:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue