Skip to content

Commit

Permalink
Switch to custom unit test build.
Browse files Browse the repository at this point in the history
For some reason, as evidenced by
#2, projects that depend on dxml
that then do their own unit test builds get linker errors due to stuff
in the unit tests. Those tests really shouldn't even be being built when
dxml is used as a dependency anyway, but for whatever reason, dub builds
all dependencies with the unittest target when a project is built with
the unittest target.

To fix that, dxml now has a separate "doTests" build type which defines
the version dxmlTests, and all unittest blocks are versioned with
dxmlTests. So, unfortunately, dub test will not run the tests anymore,
but we're stuck it seems.
  • Loading branch information
jmdavis committed Feb 13, 2018
1 parent 0b982c5 commit 05bf9f7
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 62 deletions.
10 changes: 9 additions & 1 deletion dub.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,13 @@
"description": "An XML parser and writer written in D.",
"copyright": "Copyright © 2017 - 2018, Jonathan M Davis",
"license": "BSL-1.0",
"targetType": "library"
"targetType": "library",
"buildTypes":
{
"doTests":
{
"buildOptions": ["unittests", "debugMode", "debugInfo"],
"versions": ["dxmlTests"]
}
}
}
14 changes: 7 additions & 7 deletions source/dxml/dom.d
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
module dxml.dom;

///
unittest
version(dxmlTests) unittest
{
auto xml = "<!-- comment -->\n" ~
"<root>\n" ~
Expand Down Expand Up @@ -812,11 +812,11 @@ private struct DOMCompileTests
@property typeof(this) save() @safe pure nothrow @nogc { assert(0); }
}

version(unittest)
version(dxmlTests)
DOMEntity!DOMCompileTests _domTests;

/// parseDOM with the dault Config and a range of characters
@safe unittest
version(dxmlTests) @safe unittest
{
import std.range.primitives;

Expand Down Expand Up @@ -864,7 +864,7 @@ version(unittest)
}

/// parseDOM with simpleXML and a range of characters
unittest
version(dxmlTests) unittest
{
auto xml = "<root>\n" ~
" <!-- no comment -->\n" ~
Expand Down Expand Up @@ -908,7 +908,7 @@ unittest
}

/// parseDOM with simpleXML and an EntityRange
unittest
version(dxmlTests) unittest
{
import dxml.parser : parseXML;

Expand Down Expand Up @@ -957,7 +957,7 @@ unittest
}

/// parseDOM with an EntityRange which is not at the start of the document.
unittest
version(dxmlTests) unittest
{
import dxml.parser : parseXML, skipToPath;

Expand Down Expand Up @@ -1061,7 +1061,7 @@ void _parseDOM(ER, DE)(ref ER range, ref DE parent, ER.SliceOfR[] path = null)
parent._children = children.data;
}

unittest
version(dxmlTests) unittest
{
import std.algorithm.comparison : equal;
import dxml.internal : testRangeFuncs;
Expand Down
6 changes: 3 additions & 3 deletions source/dxml/internal.d
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ bool equalCU(R)(R range, string text)
return range.empty;
}

unittest
version(dxmlTests) unittest
{
import std.algorithm : filter;
import std.meta : AliasSeq;
Expand Down Expand Up @@ -87,7 +87,7 @@ pragma(inline, true) auto stripBCU(Orig, R)(R range)
return range;
}

unittest
version(dxmlTests) unittest
{
import std.algorithm : equal, filter;
import std.range : takeExactly;
Expand Down Expand Up @@ -123,7 +123,7 @@ pragma(inline, true) auto checkedSave(R)(ref R range)
// Unit test helpers
//------------------------------------------------------------------------------

version(unittest):
version(dxmlTests):

struct FwdCharRange(C)
{
Expand Down
Loading

0 comments on commit 05bf9f7

Please sign in to comment.