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

Merge both TestDub constructors #2874

Merged
merged 1 commit into from
Feb 22, 2024
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
10 changes: 5 additions & 5 deletions source/dub/dub.d
Original file line number Diff line number Diff line change
Expand Up @@ -368,15 +368,15 @@ class Dub {
import dub.test.base : TestDub;

scope (exit) environment.remove("DUB_REGISTRY");
auto dub = new TestDub(".", null, SkipPackageSuppliers.configured);
auto dub = new TestDub(null, ".", null, SkipPackageSuppliers.configured);
assert(dub.packageSuppliers.length == 0);
environment["DUB_REGISTRY"] = "http://example.com/";
dub = new TestDub(".", null, SkipPackageSuppliers.configured);
dub = new TestDub(null, ".", null, SkipPackageSuppliers.configured);
assert(dub.packageSuppliers.length == 1);
environment["DUB_REGISTRY"] = "http://example.com/;http://foo.com/";
dub = new TestDub(".", null, SkipPackageSuppliers.configured);
dub = new TestDub(null, ".", null, SkipPackageSuppliers.configured);
assert(dub.packageSuppliers.length == 2);
dub = new TestDub(".", [new RegistryPackageSupplier(URL("http://bar.com/"))], SkipPackageSuppliers.configured);
dub = new TestDub(null, ".", [new RegistryPackageSupplier(URL("http://bar.com/"))], SkipPackageSuppliers.configured);
assert(dub.packageSuppliers.length == 3);

dub = new TestDub();
Expand Down Expand Up @@ -1648,7 +1648,7 @@ class Dub {
import dub.test.base : TestDub;
import std.path: buildPath, absolutePath;

auto dub = new TestDub(".", null, SkipPackageSuppliers.configured);
auto dub = new TestDub(null, ".", null, SkipPackageSuppliers.configured);
immutable olddc = environment.get("DC", null);
immutable oldpath = environment.get("PATH", null);
immutable testdir = "test-determineDefaultCompiler";
Expand Down
21 changes: 9 additions & 12 deletions source/dub/test/base.d
Original file line number Diff line number Diff line change
Expand Up @@ -181,15 +181,6 @@ public class TestDub : Dub
cache: Root ~ "user/" ~ "cache/",
};

/// Forward to base constructor
public this (string root = ProjectPath.toNativeString(),
PackageSupplier[] extras = null,
SkipPackageSuppliers skip = SkipPackageSuppliers.none)
{
this.fs = new FSEntry();
super(root, extras, skip);
}

/***************************************************************************

Instantiate a new `TestDub` instance with the provided filesystem state
Expand All @@ -200,14 +191,20 @@ public class TestDub : Dub
Params:
dg = Delegate to be called with the filesystem, before `TestDub`
instantiation is performed;
root = The root path for this instance (forwarded to Dub)
extras = Extras `PackageSupplier`s (forwarded to Dub)
skip = What `PackageSupplier`s to skip (forwarded to Dub)

***************************************************************************/

public this (scope void delegate(scope FSEntry root) dg)
public this (scope void delegate(scope FSEntry root) dg = null,
string root = ProjectPath.toNativeString(),
PackageSupplier[] extras = null,
SkipPackageSuppliers skip = SkipPackageSuppliers.none)
{
this.fs = new FSEntry();
dg(this.fs);
super(ProjectPath.toNativeString(), null, SkipPackageSuppliers.none);
if (dg !is null) dg(this.fs);
super(root, extras, skip);
}

/// Avoid loading user configuration
Expand Down
Loading