From 4c9587c4c607ef59fe019d313534e75e92170949 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Tue, 16 Jul 2024 14:53:27 -0700 Subject: [PATCH] unittests: use `property` for rarely used directories This avoids having to set them up in cases we don't use them, or override them in cases where we change the build directory --- unittests/baseplatformtests.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/unittests/baseplatformtests.py b/unittests/baseplatformtests.py index 9be2cb2651d9..935e01639604 100644 --- a/unittests/baseplatformtests.py +++ b/unittests/baseplatformtests.py @@ -102,12 +102,18 @@ def setUp(self): self.meson_cross_files = [] self.new_builddir() + @property + def privatedir(self) -> str: + return os.path.join(self.builddir, 'meson-private') + + @property + def distdir(self) -> str: + return os.path.join(self.builddir, 'meson-dist') + def change_builddir(self, newdir): self.builddir = newdir - self.privatedir = os.path.join(self.builddir, 'meson-private') self.logdir = os.path.join(self.builddir, 'meson-logs') self.installdir = os.path.join(self.builddir, 'install') - self.distdir = os.path.join(self.builddir, 'meson-dist') self.mtest_command = self.meson_command + ['test', '-C', self.builddir] if os.path.islink(newdir): self.addCleanup(os.unlink, self.builddir) @@ -199,7 +205,6 @@ def init(self, srcdir, *, args += ['--native-file', f] for f in self.meson_cross_files: args += ['--cross-file', f] - self.privatedir = os.path.join(self.builddir, 'meson-private') if inprocess: try: returncode, out, err = run_configure_inprocess(['setup'] + self.meson_args + args + extra_args + build_and_src_dir_args, override_envvars)