Skip to content

Commit

Permalink
cache db test uses gitcompatibledubpackage
Browse files Browse the repository at this point in the history
  • Loading branch information
rtbo authored and WebFreak001 committed May 18, 2023
1 parent 80edf40 commit cdbee12
Showing 1 changed file with 40 additions and 10 deletions.
50 changes: 40 additions & 10 deletions test/pr2642-cache-db/source/test_cache_db.d
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,29 @@ void main()
const fetchProgram = [
environment["DUB"],
"fetch",
"[email protected]",
"[email protected]",
];
auto dubFetch = spawnProcess(fetchProgram, stdin, stdout, stderr, env);
wait(dubFetch);
const buildProgram = [

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

const buildProgramExe = [
environment["DUB"],
"build",
"--build=debug",
"vibe-d:[email protected]",
"--config=exe",
"[email protected]",
];
auto dubBuild = spawnProcess(buildProgram, stdin, stdout, stderr, env);
dubBuild = spawnProcess(buildProgramExe, stdin, stdout, stderr, env);
wait(dubBuild);

scope (success)
Expand All @@ -39,12 +51,13 @@ void main()
rmdirRecurse(dubhome);
}

const buildDbPath = buildNormalizedPath(dubhome, "cache", "vibe-d", "0.9.6", "+http", "db.json");
const buildDbPath = buildNormalizedPath(dubhome, "cache", "gitcompatibledubpackage", "1.0.4", "db.json");
assert(exists(buildDbPath), buildDbPath ~ " should exist");
const buildDbStr = readText(buildDbPath);
auto json = parseJSON(buildDbStr);
assert(json.type == JSONType.array, "build db should be an array");
assert(json.array.length == 1);
assert(json.array.length == 2, "build db should have 2 entries");

auto db = json.array[0].object;

void assertArray(string field)
Expand All @@ -67,12 +80,29 @@ void main()
assertString("compiler");
assertString("compilerBinary");
assertString("compilerVersion");
assertString("configuration", "library");
assertString("package", "vibe-d:http");
assertString("configuration", "lib");
assertString("package", "gitcompatibledubpackage");
assertArray("platform");
assertString("targetBinaryPath");
assertString("version", "1.0.4");

auto binName = db["targetBinaryPath"].str;
assert(isFile(binName), "expected " ~ binName ~ " to be a file.");

db = json.array[1].object;

assertArray("architecture");
assertString("buildId");
assertString("buildType", "debug");
assertString("compiler");
assertString("compilerBinary");
assertString("compilerVersion");
assertString("configuration", "exe");
assertString("package", "gitcompatibledubpackage");
assertArray("platform");
assertString("targetBinaryPath");
assertString("version", "0.9.6");
assertString("version", "1.0.4");

const binName = db["targetBinaryPath"].str;
binName = db["targetBinaryPath"].str;
assert(isFile(binName), "expected " ~ binName ~ " to be a file.");
}

0 comments on commit cdbee12

Please sign in to comment.