We've been using a generic `osbuild-run`, which sets up the build environment (and works around bugs) for all build roots. It is already getting unwieldy, because it tries to detect the OS for some things it configures. It's also about to cause problems for RHEL, which doesn't currently support a python3 shebang without having /etc around. This patch changes the `build` key in a pipeline to not be a pipeline itself, but an object with `runner` and `pipeline` keys. `pipeline` is the build pipeline, as before. `runner` is the name of the runner to use. Runners are programs in the `runners` subdirectory. Three runners are included in this patch. They're copies of osbuild-run for now (except some additions for rhel82). The idea is that each of them only contains the minimal setup code necessary for an OS, and that we can review what's needed when updating a build root. Also modify the `--build-pipeline` command line switch to accept such a build object (instead of a pipeline) and rename it accordingly, to `--build-env`. Correspondingly, `OSBUILD_TEST_BUILD_PIPELINE` → `OSBUILD_TEST_BUILD_ENV`.
79 lines
2.5 KiB
Python
79 lines
2.5 KiB
Python
|
|
import osbuild
|
|
import unittest
|
|
|
|
|
|
class TestDescriptions(unittest.TestCase):
|
|
def test_canonical(self):
|
|
"""Degenerate case. Make sure we always return the same canonical
|
|
description when passing empty or null values."""
|
|
|
|
cases = [
|
|
{},
|
|
{ "assembler": None },
|
|
{ "stages": [] },
|
|
{ "build": {} },
|
|
{ "build": None }
|
|
]
|
|
for pipeline in cases:
|
|
with self.subTest(pipeline):
|
|
self.assertEqual(osbuild.load(pipeline).description(), {})
|
|
|
|
def test_stage(self):
|
|
name = "org.osbuild.test"
|
|
options = { "one": 1 }
|
|
cases = [
|
|
(osbuild.Stage(name, None, None, {}), {"name": name}),
|
|
(osbuild.Stage(name, None, None, None), {"name": name}),
|
|
(osbuild.Stage(name, None, None, options), {"name": name, "options": options}),
|
|
]
|
|
for stage, description in cases:
|
|
with self.subTest(description):
|
|
self.assertEqual(stage.description(), description)
|
|
|
|
def test_assembler(self):
|
|
name = "org.osbuild.test"
|
|
options = { "one": 1 }
|
|
cases = [
|
|
(osbuild.Assembler(name, None, None, {}), {"name": name}),
|
|
(osbuild.Assembler(name, None, None, None), {"name": name}),
|
|
(osbuild.Assembler(name, None, None, options), {"name": name, "options": options}),
|
|
]
|
|
for assembler, description in cases:
|
|
with self.subTest(description):
|
|
self.assertEqual(assembler.description(), description)
|
|
|
|
def test_pipeline(self):
|
|
build = osbuild.Pipeline("org.osbuild.test")
|
|
build.add_stage("org.osbuild.test", { "one": 1 })
|
|
|
|
pipeline = osbuild.Pipeline("org.osbuild.test", build)
|
|
pipeline.add_stage("org.osbuild.test", { "one": 2 })
|
|
pipeline.set_assembler("org.osbuild.test")
|
|
|
|
self.assertEqual(pipeline.description(), {
|
|
"build": {
|
|
"pipeline": {
|
|
"stages": [
|
|
{
|
|
"name": "org.osbuild.test",
|
|
"options": { "one": 1 }
|
|
}
|
|
]
|
|
},
|
|
"runner": "org.osbuild.test"
|
|
},
|
|
"stages": [
|
|
{
|
|
"name": "org.osbuild.test",
|
|
"options": { "one": 2 }
|
|
}
|
|
],
|
|
"assembler": {
|
|
"name": "org.osbuild.test"
|
|
}
|
|
})
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|