Skip to content

Commit

Permalink
Merge both TestDub constructors
Browse files Browse the repository at this point in the history
Those constructors had different but non-overlapping functionalities.
In the event one wanted to set one of the parameters passed to Dub
constructor but also initialize the FS, one was out of luck.
  • Loading branch information
Geod24 authored and dlang-bot committed Feb 22, 2024
1 parent f70dfca commit 203a3ca
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 17 deletions.
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

0 comments on commit 203a3ca

Please sign in to comment.