unittest.d builds itself with correct dub buildtype/conf if built incorrectly.

This commit is contained in:
Ferdinand Majerech 2014-08-01 20:12:49 +02:00
parent db1f1fb4cd
commit a23cc9be5c

59
unittest.d Normal file → Executable file
View file

@ -1,16 +1,61 @@
#!/usr/bin/rdmd
// Copyright Ferdinand Majerech 2011.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
import dyaml.all;
import std.stdio;
void main()
version(unittest)
{
writeln("Done");
import dyaml.all;
import dyaml.testcompare;
import dyaml.testconstructor;
import dyaml.testemitter;
import dyaml.testerrors;
import dyaml.testinputoutput;
import dyaml.testreader;
import dyaml.testrepresenter;
import dyaml.testresolver;
import dyaml.testtokens;
}
void main(string[] args)
{
import std.stdio;
version(unittest)
{
writeln("Done");
}
else
{
writeln("This is not a unittest build. Trying to build one.");
void build(string type)
{
import std.process;
const processArgs = ["dub", "build", "-c=unittest", "-b=" ~ type ~ "-unittest"];
if(spawnProcess(processArgs).wait() != 0)
{
writeln("Build failed!");
}
}
import std.algorithm;
import std.array;
args.popFront();
if(args.empty)
{
build("debug");
}
else if(["debug", "release", "profile"].canFind(args[0]))
{
build(args[0]);
}
else
{
writeln("Unknown unittest build type: ", args[0]);
}
}
}