[elbe-devel] [PATCH v2 2/4] tests: Create test case for pbuilder
Bastian Germann
bage at linutronix.de
Tue Aug 4 13:57:52 CEST 2020
Am 03.08.20 um 18:39 schrieb Olivier Dion:
> Files under tests/ matching pbuilder*.xml are used for testing
> pbuilder.
>
> A pbuilder project is first created then build. Any error will result
> in an exception and thus in the test case failing.
>
> Signed-off-by: Olivier Dion <dion at linutronix.de>
> ---
> elbepack/tests/test_xml.py | 30 ++++++++++++++++++++++++++++++
> 1 file changed, 30 insertions(+)
>
> diff --git a/elbepack/tests/test_xml.py b/elbepack/tests/test_xml.py
> index f397a90b..17cc21cf 100644
> --- a/elbepack/tests/test_xml.py
> +++ b/elbepack/tests/test_xml.py
> @@ -52,3 +52,33 @@ class TestSimpleXML(ElbeTestCase):
> system('%s control del_project %s' % (elbe_exe, uuid),
> allow_fail=True)
>
> + at unittest.skipIf(ElbeTestCase.level < ElbeTestLevel.INITVM,
> + "Test level not set to INITVM")
> +class TestPbuilder(ElbeTestCase):
> +
> + params = [os.path.join(elbe_dir, "tests", fname)
> + for fname
> + in os.listdir(os.path.join(elbe_dir, "tests"))
> + if fname.startswith("pbuilder") and fname.endswith(".xml")]
> +
> + def test_pbuilder_build(self):
> +
> + with tempfile.TemporaryDirectory(prefix="elbe-test-pbuilder-xml-") as build_dir:
> +
> + prj = os.path.join(build_dir, "uuid.prj")
> + uuid = None
> +
> + try:
> + system('%s pbuilder create --xmlfile "%s" --writeproject "%s"' %
> + (elbe_exe, self.param, prj))
> +
> + with open(prj, "r") as f:
> + uuid = f.read()
> + os.chdir(build_dir)
> + system('%s pbuilder build --project %s' % (elbe_exe, uuid))
> + # pylint: disable=try-except-raise
> + except:
> + raise
Why do we need this? Can't you just leave out the try-except?
This goes also for the previous patch.
> + else:
> + system('%s control del_project %s' % (elbe_exe, uuid),
> + allow_fail=True)
>
More information about the elbe-devel
mailing list