Skip to content

Commit

Permalink
add test for the --deep switch
Browse files Browse the repository at this point in the history
  • Loading branch information
rtbo authored and WebFreak001 committed Aug 16, 2023
1 parent 39b97fa commit 1ef555e
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 0 deletions.
2 changes: 2 additions & 0 deletions test/pr2647-build-deep/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dubhome/
pr2647-build-deep
Empty file added test/pr2647-build-deep/.no_test
Empty file.
2 changes: 2 additions & 0 deletions test/pr2647-build-deep/dub.sdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
name "pr2647-build-deep";
targetType "executable";
3 changes: 3 additions & 0 deletions test/pr2647-build-deep/pack/dub.sdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
name "pack"
targetType "staticLibrary"
dependency "urld" version="==2.1.1"
14 changes: 14 additions & 0 deletions test/pr2647-build-deep/pack/source/lib.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module lib;

import url;

string getDlangUrl()
{
URL url;
with(url)
{
scheme = "https";
host = "dlang.org";
}
return url.toString();
}
53 changes: 53 additions & 0 deletions test/pr2647-build-deep/source/test_build_deep.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
module test_build_deep;

import std.array;
import std.file;
import std.path;
import std.process;
import std.stdio;

void main()
{
const dubhome = __FILE_FULL_PATH__.dirName().dirName().buildNormalizedPath("dubhome");
const packdir = __FILE_FULL_PATH__.dirName().dirName().buildNormalizedPath("pack");
const dub = absolutePath(environment["DUB"]);

if (exists(dubhome))
{
rmdirRecurse(dubhome);
}

scope (success)
{
// leave dubhome in the tree for analysis in case of failure
rmdirRecurse(dubhome);
}

const string[string] env = [
"DUB_HOME": dubhome,
];

// testing the regular way first: `dub build` only builds what is needed
// (urld is downloaded but not built)
const dubBuildProg = [dub, "build"];
writefln("running %s ...", dubBuildProg.join(" "));
auto dubBuild = spawnProcess(dubBuildProg, stdin, stdout, stderr, env, Config.none, packdir);
wait(dubBuild);
assert(exists(buildPath(dubhome, "cache", "pack")));
assert(isDir(buildPath(dubhome, "cache", "pack")));
assert(exists(buildPath(dubhome, "packages", "urld")));
assert(isDir(buildPath(dubhome, "packages", "urld")));
assert(!exists(buildPath(dubhome, "cache", "urld")));

// now testing the --deep switch: `dub build --deep` will build urld
const dubBuildDeepProg = [dub, "build", "--deep"];
writefln("running %s ...", dubBuildDeepProg.join(" "));
auto dubBuildDeep = spawnProcess(dubBuildDeepProg, stdin, stdout, stderr, env, Config.none, packdir);
wait(dubBuildDeep);
assert(exists(buildPath(dubhome, "cache", "pack")));
assert(isDir(buildPath(dubhome, "cache", "pack")));
assert(exists(buildPath(dubhome, "packages", "urld")));
assert(isDir(buildPath(dubhome, "packages", "urld")));
assert(exists(buildPath(dubhome, "cache", "urld")));
assert(isDir(buildPath(dubhome, "cache", "urld")));
}

0 comments on commit 1ef555e

Please sign in to comment.