Skip to content

Commit

Permalink
Merge pull request dlang#387 from PetarKirov/merge_stable
Browse files Browse the repository at this point in the history
Merge stable
merged-on-behalf-of: Sebastian Wilzbach <[email protected]>
dlang-bot authored Nov 13, 2019

Verified

This commit was signed with the committer’s verified signature.
sdispater Sébastien Eustace
2 parents 94a9391 + 1db5548 commit 69a119f
Showing 2 changed files with 14 additions and 8 deletions.
9 changes: 5 additions & 4 deletions test/tests_extractor/betterc.d.ext
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# line 2
unittest
void unittest_line_2()
{
import betterc;

@@ -8,7 +8,7 @@ unittest
}

# line 9
unittest
void unittest_line_9()
{
import betterc;

@@ -19,6 +19,7 @@ unittest

extern(C) void main()
{
static foreach(u; __traits(getUnitTests, __traits(parent, main)))
u();
static foreach(test; __traits(allMembers, mixin(__MODULE__)))
static if (test.length > 8 && test[0..8] == "unittest")
mixin(test)();
}
13 changes: 9 additions & 4 deletions tests_extractor.d
Original file line number Diff line number Diff line change
@@ -61,8 +61,9 @@ class TestVisitor : ASTVisitor
{
outFile.writeln(q{extern(C) void main()
{
static foreach(u; __traits(getUnitTests, __traits(parent, main)))
u();
static foreach(test; __traits(allMembers, mixin(__MODULE__)))
static if (test.length > 8 && test[0..8] == "unittest")
mixin(test)();
}});
}
}
@@ -125,7 +126,8 @@ private:
subtract two lines from it as we add "import <current.module>\n\n" at
the top of the unittest.
*/
outFile.writefln("# line %d", u.line > 2 ? u.line - 2 : 0);
const line = u.line > 2 ? u.line - 2 : 0;
outFile.writefln("# line %d", line);

static immutable predefinedAttributes = ["nogc", "system", "nothrow", "safe", "trusted", "pure"];

@@ -154,7 +156,10 @@ private:
}

// write the unittest block
outFile.write("unittest\n{\n");
if (config.betterCOutput)
outFile.writef("void unittest_line_%s()\n{\n", line);
else
outFile.write("unittest\n{\n");
scope(exit) outFile.writeln("}\n");

// add an import to the current module

0 comments on commit 69a119f

Please sign in to comment.