diff --git a/source/dub/packagemanager.d b/source/dub/packagemanager.d index 5e05208d6..75298690e 100644 --- a/source/dub/packagemanager.d +++ b/source/dub/packagemanager.d @@ -243,21 +243,6 @@ class PackageManager { return this.lookup(name, ver); } - /** - * Adds a `Package` to this `PackageManager` - * - * This is currently only available in unittests as it is a convenience - * function used by `TestDub`, but could be generalized once IO has been - * abstracted away from this class. - */ - version (unittest) Package add(Package pkg) - { - // See `PackageManager.addPackages` for inspiration. - assert(!pkg.subPackages.length, "Subpackages are not yet supported"); - this.m_internal.fromPath ~= pkg; - return pkg; - } - /// ditto deprecated("Use the overload that accepts a `Version` as second argument") Package getPackage(string name, string ver, bool enable_overrides = true) diff --git a/source/dub/test/base.d b/source/dub/test/base.d index efc6478a8..2883493ab 100644 --- a/source/dub/test/base.d +++ b/source/dub/test/base.d @@ -82,6 +82,17 @@ public class TestDub : Dub /// Reintroduce parent overloads public alias loadPackage = Dub.loadPackage; + /** + * Returns a fully typed `TestPackageManager` + * + * This exposes the fully typed `PackageManager`, so that client + * can call convenience functions on it directly. + */ + public override @property inout(TestPackageManager) packageManager() inout + { + return cast(inout(TestPackageManager)) this.m_packageManager; + } + /** * Creates a package with the provided recipe * @@ -212,6 +223,21 @@ package class TestPackageManager : PackageManager return null; } + + /** + * Adds a `Package` to this `PackageManager` + * + * This is currently only available in unittests as it is a convenience + * function used by `TestDub`, but could be generalized once IO has been + * abstracted away from this class. + */ + public Package add(Package pkg) + { + // See `PackageManager.addPackages` for inspiration. + assert(!pkg.subPackages.length, "Subpackages are not yet supported"); + this.m_internal.fromPath ~= pkg; + return pkg; + } } /**