From 845148993c0c4483811f09bb827d4924b37f1cb6 Mon Sep 17 00:00:00 2001 From: David Rheinsberg Date: Wed, 20 May 2020 11:14:07 +0200 Subject: [PATCH] test: add `tree-diff` accessor The `tree-diff` tool currently requires access to our local checkout, since we do not install the tool. Provide accessors in `TestBase` so we do not hard-code the path everywhere. --- test/test.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/test/test.py b/test/test.py index 8feedac7..8b1da354 100644 --- a/test/test.py +++ b/test/test.py @@ -136,6 +136,29 @@ class TestBase(): return r.returncode == 0 and "compose" in r.stdout + @staticmethod + def have_tree_diff() -> bool: + """Check for tree-diff Tool + + Check whether the current test-run has access to the `tree-diff` tool. + We currently use the one from a checkout, so it is available whenever + a checkout is available. + """ + + return TestBase.have_test_checkout() + + @staticmethod + def tree_diff(path1, path2): + """Compare File-System Trees + + Run the `tree-diff` tool from the osbuild checkout. It produces a JSON + output that describes the difference between 2 file-system trees. + """ + + checkout = TestBase.locate_test_checkout() + output = subprocess.check_output([os.path.join(checkout, "tree-diff"), path1, path2]) + return json.loads(output) + class OSBuild(contextlib.AbstractContextManager): """OSBuild Executor