Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test framework: Return fully typed TestPackageManager from TestDub #2761

Merged
merged 1 commit into from
Dec 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions source/dub/packagemanager.d
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
26 changes: 26 additions & 0 deletions source/dub/test/base.d
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down Expand Up @@ -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
WebFreak001 marked this conversation as resolved.
Show resolved Hide resolved
* 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;
}
}

/**
Expand Down
Loading