Skip to content

Commit

Permalink
add test for describe cacheArtifactPath
Browse files Browse the repository at this point in the history
  • Loading branch information
rtbo committed May 21, 2023
1 parent 8da5aa4 commit 2092047
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 0 deletions.
2 changes: 2 additions & 0 deletions test/pr2644-describe-artifact-path/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dubhome/
pr2644-describe-artifact-path
Empty file.
2 changes: 2 additions & 0 deletions test/pr2644-describe-artifact-path/dub.sdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
name "pr2644-describe-artifact-path";
targetType "executable";
61 changes: 61 additions & 0 deletions test/pr2644-describe-artifact-path/source/describe_artifact_path.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
module describe_artifact_path;

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

void main()
{
const dubhome = __FILE_FULL_PATH__.dirName().dirName().buildNormalizedPath("dubhome");
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,
];
const fetchProgram = [
environment["DUB"],
"fetch",
"[email protected]",
];
auto dubFetch = spawnProcess(fetchProgram, stdin, stdout, stderr, env);
wait(dubFetch);


const describeProgram = [
environment["DUB"],
"describe",
"--compiler=" ~ environment["DC"],
"--build=debug",
"--config=lib",
"[email protected]",
];
auto result = execute(describeProgram, env);
assert(result.status == 0, "expected dub describe to return zero");
auto json = parseJSON(result.output);

auto cacheFile = json["targets"][0]["cacheArtifactPath"].str;
assert(!exists(cacheFile), "found cache file in virgin dubhome");

const buildProgram = [
environment["DUB"],
"build",
"--compiler=" ~ environment["DC"],
"--build=debug",
"--config=lib",
"[email protected]",
];
auto dubBuild = spawnProcess(buildProgram, stdin, stdout, stderr, env);
wait(dubBuild);

assert(exists(cacheFile), "did not find cache file after build");
}

0 comments on commit 2092047

Please sign in to comment.