From 1ded3a9f722d2eb8f385bf174e5835a51597d9b2 Mon Sep 17 00:00:00 2001 From: Mathias Lang Date: Mon, 12 Feb 2024 09:56:26 +0100 Subject: [PATCH] Tests: Move root FSEntry from PackageManager to TestDub This way we can extend its use to all of TestDub. --- source/dub/dub.d | 2 +- source/dub/test/base.d | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/source/dub/dub.d b/source/dub/dub.d index 1f3c1f3d0..a36ac5324 100644 --- a/source/dub/dub.d +++ b/source/dub/dub.d @@ -212,7 +212,7 @@ class Dub { * generally in a library setup, one may wish to provide a custom * implementation, which can be done by overriding this method. */ - protected PackageManager makePackageManager() const + protected PackageManager makePackageManager() { return new PackageManager(m_rootPath, m_dirs.userPackages, m_dirs.systemSettings, false); } diff --git a/source/dub/test/base.d b/source/dub/test/base.d index cdef9e8cb..1f6207f4d 100644 --- a/source/dub/test/base.d +++ b/source/dub/test/base.d @@ -142,6 +142,8 @@ public void disableLogging() */ public class TestDub : Dub { + /// The virtual filesystem that this instance acts on + public FSEntry fs; /// Convenience constants for use in unittets public static immutable ProjectPath = NativePath("/dub/project/"); /// Ditto @@ -158,6 +160,7 @@ public class TestDub : Dub PackageSupplier[] extras = null, SkipPackageSuppliers skip = SkipPackageSuppliers.none) { + this.fs = new FSEntry(); super(root, extras, skip); } @@ -169,9 +172,10 @@ public class TestDub : Dub } /// - protected override PackageManager makePackageManager() const + protected override PackageManager makePackageManager() { - return new TestPackageManager(); + assert(this.fs !is null); + return new TestPackageManager(this.fs); } /// See `MockPackageSupplier` documentation for this class' implementation @@ -280,12 +284,12 @@ package class TestPackageManager : PackageManager /// The virtual filesystem that this PackageManager acts on protected FSEntry fs; - this() + this(FSEntry filesystem) { NativePath local = TestDub.ProjectPath; NativePath user = TestDub.Paths.userSettings; NativePath system = TestDub.Paths.systemSettings; - this.fs = new FSEntry(); + this.fs = filesystem; super(local, user, system, false); }