Skip to content

Commit

Permalink
Merge pull request #319 from atilaneves/fix-316
Browse files Browse the repository at this point in the history
Fix #316 - run tests in private structs
  • Loading branch information
atilaneves authored Feb 20, 2025
2 parents 40a51ad + 4f12fc4 commit 5b9ba0a
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 7 deletions.
7 changes: 0 additions & 7 deletions subpackages/runner/source/unit_threaded/runner/reflection.d
Original file line number Diff line number Diff line change
Expand Up @@ -271,14 +271,7 @@ private TestData[] moduleUnitTests_(alias module_)() {

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

// isPrivate can't be used here. I don't know why.
static if(__traits(compiles, __traits(getProtection, __traits(getMember, module_, member))))
enum notPrivate = __traits(getProtection, __traits(getMember, module_, member)) != "private";
else
enum notPrivate = false;

static if (
notPrivate &&
// If visibility of the member is deprecated, the next line still returns true
// and yet spills deprecation warning. If deprecation is turned into error,
// all works as intended.
Expand Down
26 changes: 26 additions & 0 deletions tests/unit_threaded/ut/issues.d
Original file line number Diff line number Diff line change
Expand Up @@ -357,3 +357,29 @@ else {
const(int[]) arr;
arr.shouldBeEmpty;
}


version(unitThreadedLight) {}
else {

@("316")
@system unittest {

import unit_threaded.runner.factory: createTestCases;
import std.algorithm: find, canFind;
import std.array: front;

enum testModule = "unit_threaded.ut.modules.issue316";

const testData = allTestData!testModule;
auto tests = createTestCases(testData);

auto external = tests.find!(a => a.getPath.canFind("L4")).front;
// opCall returns an array of failures
external().length.should == 0;

auto internal = tests.find!(a => a.getPath.canFind("L9")).front;
// opCall returns an array of internalures
internal().length.should == 0;
}
}
11 changes: 11 additions & 0 deletions tests/unit_threaded/ut/modules/issue316.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module unit_threaded.ut.modules.issue316;


unittest {
assert(true, "outside");
}

private struct PrivateStruct {
unittest {
}
}

0 comments on commit 5b9ba0a

Please sign in to comment.