From a23cc9be5cbf64c568c6e41d30d8c7d2f7b19512 Mon Sep 17 00:00:00 2001 From: Ferdinand Majerech Date: Fri, 1 Aug 2014 20:12:49 +0200 Subject: [PATCH] unittest.d builds itself with correct dub buildtype/conf if built incorrectly. --- unittest.d | 59 +++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 52 insertions(+), 7 deletions(-) mode change 100644 => 100755 unittest.d diff --git a/unittest.d b/unittest.d old mode 100644 new mode 100755 index c59fca2..d8b1320 --- a/unittest.d +++ b/unittest.d @@ -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]); + } + } }