Skip to content

Commit

Permalink
Tests: Move root FSEntry from PackageManager to TestDub
Browse files Browse the repository at this point in the history
This way we can extend its use to all of TestDub.
  • Loading branch information
Geod24 authored and dlang-bot committed Feb 12, 2024
1 parent 1c174ef commit b8d9ae5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion source/dub/dub.d
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
12 changes: 8 additions & 4 deletions source/dub/test/base.d
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -158,6 +160,7 @@ public class TestDub : Dub
PackageSupplier[] extras = null,
SkipPackageSuppliers skip = SkipPackageSuppliers.none)
{
this.fs = new FSEntry();
super(root, extras, skip);
}

Expand All @@ -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
Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit b8d9ae5

Please sign in to comment.