Unittest build now works with 'dub test'

This commit is contained in:
Ferdinand Majerech 2014-08-06 14:17:07 +02:00
parent c47714c950
commit b254e35762
12 changed files with 50 additions and 87 deletions

View file

@ -3,7 +3,6 @@
"description": "YAML parser and emitter",
"authors": [ "Ferdinand Majerech" ],
"libs": [],
"targetType": "staticLibrary",
"importPaths": ["source"],
"license": "Boost 1.0",
"dependencies": {},
@ -15,30 +14,5 @@
"debug": { "buildOptions": ["debugMode", "debugInfoC"] },
"release": { "buildOptions": ["releaseMode", "optimize", "inline", "noBoundsCheck"] },
"profile": { "buildOptions": ["releaseMode", "optimize", "noBoundsCheck", "debugInfoC"] },
"debug-unittest": { "buildOptions": ["unittests", "debugMode", "debugInfoC"] },
"release-unittest": { "buildOptions": ["unittests", "releaseMode", "optimize", "inline", "noBoundsCheck"] },
"profile-unittest": { "buildOptions": ["unittests", "releaseMode", "optimize", "noBoundsCheck", "debugInfoC"] }
},
"configurations":
[
{
"name": "unittest",
"targetName": "unittest",
"targetType": "executable",
"sourceFiles": ["unittest.d",
"test/src/common.d",
"test/src/compare.d",
"test/src/constructor.d",
"test/src/emitter.d",
"test/src/errors.d",
"test/src/inputoutput.d",
"test/src/reader.d",
"test/src/representer.d",
"test/src/resolver.d",
"test/src/tokens.d",
],
"mainSourceFile": "unittest.d",
}
]
}

View file

@ -6,6 +6,9 @@
module dyaml.testcommon;
version(unittest)
{
public import std.conv;
public import std.stdio;
public import std.stream;
@ -201,3 +204,5 @@ void display(Result[] results, const bool verbose)
if(failures > 0){writeln("FAILURES: ", failures);}
if(errors > 0) {writeln("ERRORS: ", errors);}
}
} // version(unittest)

View file

@ -7,6 +7,9 @@
module dyaml.testcompare;
version(unittest)
{
import dyaml.testcommon;
import dyaml.token;
@ -65,3 +68,5 @@ unittest
run("testParser", &testParser, ["data", "canonical"]);
run("testLoader", &testLoader, ["data", "canonical"], ["test_loader_skip"]);
}
} // version(unittest)

View file

@ -7,6 +7,9 @@
module dyaml.testconstructor;
version(unittest)
{
import std.datetime;
import std.exception;
import std.path;
@ -433,3 +436,5 @@ unittest
writeln("D:YAML Constructor unittest");
run("testConstructor", &testConstructor, ["data", "code"]);
}
} // version(unittest)

View file

@ -7,6 +7,9 @@
module dyaml.testemitter;
version(unittest)
{
import std.algorithm;
import std.file;
import std.range;
@ -197,3 +200,5 @@ unittest
run("testEmitterOnCanonical", &testEmitterOnCanonical, ["canonical"]);
run("testEmitterStyles", &testEmitterStyles, ["data", "canonical"]);
}
} // version(unittest)

View file

@ -7,6 +7,9 @@
module dyaml.testerrors;
version(unittest)
{
import std.file;
import dyaml.testcommon;
@ -91,3 +94,5 @@ unittest
run("testLoaderErrorFilename", &testLoaderErrorFilename, ["loader-error"]);
run("testLoaderErrorSingle", &testLoaderErrorSingle, ["single-loader-error"]);
}
} // version(unittest)

View file

@ -7,6 +7,9 @@
module dyaml.testinputoutput;
version(unittest)
{
import std.array;
import std.file;
import std.system;
@ -91,3 +94,5 @@ unittest
run("testUnicodeInput", &testUnicodeInput, ["unicode"]);
run("testUnicodeInputErrors", &testUnicodeInputErrors, ["unicode"]);
}
} // version(unittest)

View file

@ -7,6 +7,9 @@
module dyaml.testreader;
version(unittest)
{
import dyaml.testcommon;
import dyaml.reader;
@ -46,3 +49,5 @@ unittest
writeln("D:YAML Reader unittest");
run("testStreamError", &testStreamError, ["stream-error"]);
}
} // version(unittest)

View file

@ -7,6 +7,9 @@
module dyaml.testrepresenter;
version(unittest)
{
import std.path;
import std.exception;
import std.typecons;
@ -77,3 +80,5 @@ unittest
writeln("D:YAML Representer unittest");
run("testRepresenterTypes", &testRepresenterTypes, ["code"]);
}
} // version(unittest)

View file

@ -7,6 +7,9 @@
module dyaml.testresolver;
version(unittest)
{
import std.file;
import std.string;
@ -50,3 +53,5 @@ unittest
writeln("D:YAML Resolver unittest");
run("testImplicitResolver", &testImplicitResolver, ["data", "detect"]);
}
} // version(unittest)

View file

@ -7,6 +7,9 @@
module dyaml.testtokens;
version(unittest)
{
import std.array;
import std.file;
@ -89,3 +92,5 @@ unittest
run("testTokens", &testTokens, ["data", "tokens"]);
run("testScanner", &testScanner, ["data", "canonical"]);
}
} // version(unittest)

View file

@ -1,61 +0,0 @@
#!/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)
version(unittest)
{
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]);
}
}
}