Skip to content

Commit 5b9ba0a

Browse files
authored
Merge pull request #319 from atilaneves/fix-316
Fix #316 - run tests in private structs
2 parents 40a51ad + 4f12fc4 commit 5b9ba0a

File tree

3 files changed

+37
-7
lines changed

3 files changed

+37
-7
lines changed

subpackages/runner/source/unit_threaded/runner/reflection.d

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -271,14 +271,7 @@ private TestData[] moduleUnitTests_(alias module_)() {
271271

272272
foreach(member; __traits(allMembers, composite)) {
273273

274-
// isPrivate can't be used here. I don't know why.
275-
static if(__traits(compiles, __traits(getProtection, __traits(getMember, module_, member))))
276-
enum notPrivate = __traits(getProtection, __traits(getMember, module_, member)) != "private";
277-
else
278-
enum notPrivate = false;
279-
280274
static if (
281-
notPrivate &&
282275
// If visibility of the member is deprecated, the next line still returns true
283276
// and yet spills deprecation warning. If deprecation is turned into error,
284277
// all works as intended.

tests/unit_threaded/ut/issues.d

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,3 +357,29 @@ else {
357357
const(int[]) arr;
358358
arr.shouldBeEmpty;
359359
}
360+
361+
362+
version(unitThreadedLight) {}
363+
else {
364+
365+
@("316")
366+
@system unittest {
367+
368+
import unit_threaded.runner.factory: createTestCases;
369+
import std.algorithm: find, canFind;
370+
import std.array: front;
371+
372+
enum testModule = "unit_threaded.ut.modules.issue316";
373+
374+
const testData = allTestData!testModule;
375+
auto tests = createTestCases(testData);
376+
377+
auto external = tests.find!(a => a.getPath.canFind("L4")).front;
378+
// opCall returns an array of failures
379+
external().length.should == 0;
380+
381+
auto internal = tests.find!(a => a.getPath.canFind("L9")).front;
382+
// opCall returns an array of internalures
383+
internal().length.should == 0;
384+
}
385+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module unit_threaded.ut.modules.issue316;
2+
3+
4+
unittest {
5+
assert(true, "outside");
6+
}
7+
8+
private struct PrivateStruct {
9+
unittest {
10+
}
11+
}

0 commit comments

Comments
 (0)