From 749f59cc9a359cabc24486dd0a642d767730f96d Mon Sep 17 00:00:00 2001 From: Christian Kellner Date: Thu, 11 Feb 2021 20:46:33 +0000 Subject: [PATCH] buildroot: make var a positional argument Commit d028ea5b16 introduced bug when introducing the `store` argument to `Stage.run`, instead of passing `var=var`, i.e. `var` is being passed as keyword argument, it is now being passed as a positional one. Since the `path=/run/osbuild` keyword argument comes before the `var=/var/tmp` argument, `var` is now being passed as `path` instead of var. Since `var` is always being passed in throughout the entire codebase, make it a positional argument, and move it before `path`. Adapt the tests to pass `var` as positional argument. --- osbuild/buildroot.py | 2 +- test/mod/test_buildroot.py | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/osbuild/buildroot.py b/osbuild/buildroot.py index bcce4c69..826509bd 100644 --- a/osbuild/buildroot.py +++ b/osbuild/buildroot.py @@ -59,7 +59,7 @@ class BuildRoot(contextlib.AbstractContextManager): only when exiting the context manager. """ - def __init__(self, root, runner, libdir, path="/run/osbuild", var="/var/tmp"): + def __init__(self, root, runner, libdir, var, path="/run/osbuild"): self._exitstack = None self._rootdir = root self._rundir = path diff --git a/test/mod/test_buildroot.py b/test/mod/test_buildroot.py index 9558fb2d..1c4bce8d 100644 --- a/test/mod/test_buildroot.py +++ b/test/mod/test_buildroot.py @@ -30,7 +30,7 @@ class TestBuildRoot(test.TestBase): var.mkdir() monitor = NullMonitor(sys.stderr.fileno()) - with BuildRoot("/", runner, libdir, var=var) as root: + with BuildRoot("/", runner, libdir, var) as root: r = root.run(["/usr/bin/true"], monitor) self.assertEqual(r.returncode, 0) @@ -50,7 +50,7 @@ class TestBuildRoot(test.TestBase): logfile = os.path.join(self.tmp.name, "log.txt") - with BuildRoot("/", runner, libdir, var=var) as root, \ + with BuildRoot("/", runner, libdir, var) as root, \ open(logfile, "w") as log: monitor = LogMonitor(log.fileno()) @@ -73,7 +73,7 @@ class TestBuildRoot(test.TestBase): data = "42. cats are superior to dogs" monitor = NullMonitor(sys.stderr.fileno()) - with BuildRoot("/", runner, libdir, var=var) as root: + with BuildRoot("/", runner, libdir, var) as root: r = root.run(["/usr/bin/echo", data], monitor) self.assertEqual(r.returncode, 0) @@ -93,7 +93,7 @@ class TestBuildRoot(test.TestBase): scripts = os.path.join(self.locate_test_data(), "scripts") monitor = NullMonitor(sys.stderr.fileno()) - with BuildRoot("/", runner, libdir, var=var) as root: + with BuildRoot("/", runner, libdir, var) as root: ro_binds = [f"{scripts}:/scripts"] @@ -127,7 +127,7 @@ class TestBuildRoot(test.TestBase): scripts = os.path.join(self.locate_test_data(), "scripts") monitor = NullMonitor(sys.stderr.fileno()) - with BuildRoot("/", runner, libdir, var=var) as root: + with BuildRoot("/", runner, libdir, var) as root: ro_binds = [f"{scripts}:/scripts"]