From 7ae4a7e7858f1ffd1936711966048e76bc9e0b75 Mon Sep 17 00:00:00 2001 From: Christian Kellner Date: Tue, 17 Aug 2021 09:07:42 +0000 Subject: [PATCH] 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. --- test/run/test_assemblers.py | 10 +++++----- test/run/test_boot.py | 4 ++-- test/run/test_noop.py | 17 ++++++++++++----- test/test.py | 3 +++ 4 files changed, 22 insertions(+), 12 deletions(-) diff --git a/test/run/test_assemblers.py b/test/run/test_assemblers.py index a475a123..880c3dfd 100644 --- a/test/run/test_assemblers.py +++ b/test/run/test_assemblers.py @@ -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) diff --git a/test/run/test_boot.py b/test/run/test_boot.py index c66e1303..5e0c0073 100644 --- a/test/run/test_boot.py +++ b/test/run/test_boot.py @@ -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", diff --git a/test/run/test_noop.py b/test/run/test_noop.py index 9af0cc3c..9add5fb1 100644 --- a/test/run/test_noop.py +++ b/test/run/test_noop.py @@ -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"]) diff --git a/test/test.py b/test/test.py index 897d5a25..d21de79d 100644 --- a/test/test.py +++ b/test/test.py @@ -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: