From b254e357621f34c11e0be6c3870b27f26fe2f1c0 Mon Sep 17 00:00:00 2001 From: Ferdinand Majerech Date: Wed, 6 Aug 2014 14:17:07 +0200 Subject: [PATCH] Unittest build now works with 'dub test' --- package.json | 26 -------- .../src/common.d => source/dyaml/testcommon.d | 5 ++ .../compare.d => source/dyaml/testcompare.d | 5 ++ .../dyaml/testconstructor.d | 5 ++ .../emitter.d => source/dyaml/testemitter.d | 5 ++ .../src/errors.d => source/dyaml/testerrors.d | 5 ++ .../dyaml/testinputoutput.d | 5 ++ .../src/reader.d => source/dyaml/testreader.d | 5 ++ .../dyaml/testrepresenter.d | 5 ++ .../resolver.d => source/dyaml/testresolver.d | 5 ++ .../src/tokens.d => source/dyaml/testtokens.d | 5 ++ unittest.d | 61 ------------------- 12 files changed, 50 insertions(+), 87 deletions(-) rename test/src/common.d => source/dyaml/testcommon.d (99%) rename test/src/compare.d => source/dyaml/testcompare.d (97%) rename test/src/constructor.d => source/dyaml/testconstructor.d (99%) rename test/src/emitter.d => source/dyaml/testemitter.d (99%) rename test/src/errors.d => source/dyaml/testerrors.d (98%) rename test/src/inputoutput.d => source/dyaml/testinputoutput.d (98%) rename test/src/reader.d => source/dyaml/testreader.d (96%) rename test/src/representer.d => source/dyaml/testrepresenter.d (98%) rename test/src/resolver.d => source/dyaml/testresolver.d (96%) rename test/src/tokens.d => source/dyaml/testtokens.d (98%) delete mode 100755 unittest.d diff --git a/package.json b/package.json index d085ef5..3f1b72a 100644 --- a/package.json +++ b/package.json @@ -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", - } - ] } diff --git a/test/src/common.d b/source/dyaml/testcommon.d similarity index 99% rename from test/src/common.d rename to source/dyaml/testcommon.d index 30900f7..57e0b19 100644 --- a/test/src/common.d +++ b/source/dyaml/testcommon.d @@ -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) diff --git a/test/src/compare.d b/source/dyaml/testcompare.d similarity index 97% rename from test/src/compare.d rename to source/dyaml/testcompare.d index 213f596..befd652 100644 --- a/test/src/compare.d +++ b/source/dyaml/testcompare.d @@ -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) diff --git a/test/src/constructor.d b/source/dyaml/testconstructor.d similarity index 99% rename from test/src/constructor.d rename to source/dyaml/testconstructor.d index 85c6527..eb6df0f 100644 --- a/test/src/constructor.d +++ b/source/dyaml/testconstructor.d @@ -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) diff --git a/test/src/emitter.d b/source/dyaml/testemitter.d similarity index 99% rename from test/src/emitter.d rename to source/dyaml/testemitter.d index 8fe50b0..1ed8932 100644 --- a/test/src/emitter.d +++ b/source/dyaml/testemitter.d @@ -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) diff --git a/test/src/errors.d b/source/dyaml/testerrors.d similarity index 98% rename from test/src/errors.d rename to source/dyaml/testerrors.d index b4ddc9c..265e792 100644 --- a/test/src/errors.d +++ b/source/dyaml/testerrors.d @@ -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) diff --git a/test/src/inputoutput.d b/source/dyaml/testinputoutput.d similarity index 98% rename from test/src/inputoutput.d rename to source/dyaml/testinputoutput.d index 6da55de..c16aa28 100644 --- a/test/src/inputoutput.d +++ b/source/dyaml/testinputoutput.d @@ -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) diff --git a/test/src/reader.d b/source/dyaml/testreader.d similarity index 96% rename from test/src/reader.d rename to source/dyaml/testreader.d index 19cf8bd..d85c4f9 100644 --- a/test/src/reader.d +++ b/source/dyaml/testreader.d @@ -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) diff --git a/test/src/representer.d b/source/dyaml/testrepresenter.d similarity index 98% rename from test/src/representer.d rename to source/dyaml/testrepresenter.d index f19d37d..ee60ec9 100644 --- a/test/src/representer.d +++ b/source/dyaml/testrepresenter.d @@ -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) diff --git a/test/src/resolver.d b/source/dyaml/testresolver.d similarity index 96% rename from test/src/resolver.d rename to source/dyaml/testresolver.d index ac079c2..1fb2ced 100644 --- a/test/src/resolver.d +++ b/source/dyaml/testresolver.d @@ -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) diff --git a/test/src/tokens.d b/source/dyaml/testtokens.d similarity index 98% rename from test/src/tokens.d rename to source/dyaml/testtokens.d index 02dd329..c686c60 100644 --- a/test/src/tokens.d +++ b/source/dyaml/testtokens.d @@ -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) diff --git a/unittest.d b/unittest.d deleted file mode 100755 index d8b1320..0000000 --- a/unittest.d +++ /dev/null @@ -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]); - } - } -} -