Skip to content

Commit 6c0fb4d

Browse files
authored
[tools/dspec_tester.d] Test articles directory (#4203)
Also find RUNNABLE_EXAMPLE_COMPILE and RUNNABLE_EXAMPLE_FAIL tests in `std`.
1 parent db5496b commit 6c0fb4d

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

articles/cpptod.dd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -928,7 +928,7 @@ void main()
928928

929929
auto d2 = gallery[0];
930930
d2.id = 1;
931-
assert(d2.id == gallery[0].id, "neither ref nor pointer");
931+
assert(d2.id != gallery[0].id); // d2 is neither ref nor pointer
932932
}
933933
------
934934
)

tools/dspec_tester.d

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,10 @@ unittest
7272

7373
auto findDdocMacro(R)(R text, string ddocKey)
7474
{
75-
return text.splitter(ddocKey).map!untilClosingParentheses.dropOne;
75+
auto sr = text.splitter(ddocKey);
76+
// don't let RUNNABLE_EXAMPLE match RUNNABLE_EXAMPLE_FOO
77+
auto fr = sr.filter!(s => s.length ? s[0] != '_' : true);
78+
return fr.map!untilClosingParentheses.dropOne;
7679
}
7780

7881
auto ddocMacroToCode(R)(R text)
@@ -95,6 +98,7 @@ int main(string[] args)
9598

9699
const rootDir = __FILE_FULL_PATH__.dirName.dirName;
97100
const specDir = rootDir.buildPath("spec");
101+
const articlesDir = rootDir.buildPath("articles");
98102
const stdDir = rootDir.buildPath("..", "phobos", "std");
99103

100104
config.dmdBinPath = environment.get("DMD", "dmd");
@@ -117,9 +121,12 @@ int main(string[] args)
117121
SpecType("$(SPEC_RUNNABLE_EXAMPLE_COMPILE", CompileConfig.TestMode.compile),
118122
SpecType("$(SPEC_RUNNABLE_EXAMPLE_RUN", CompileConfig.TestMode.run),
119123
SpecType("$(SPEC_RUNNABLE_EXAMPLE_FAIL", CompileConfig.TestMode.fail),
124+
SpecType("$(RUNNABLE_EXAMPLE_COMPILE", CompileConfig.TestMode.compile),
120125
SpecType("$(RUNNABLE_EXAMPLE", CompileConfig.TestMode.run),
126+
SpecType("$(RUNNABLE_EXAMPLE_FAIL", CompileConfig.TestMode.fail),
121127
];
122128
auto files = chain(specDir.dirEntries("*.dd", SpanMode.depth),
129+
articlesDir.dirEntries("*.dd", SpanMode.depth),
123130
stdDir.dirEntries("*.d", SpanMode.depth));
124131
shared bool hasFailed;
125132
foreach (file; files.parallel(1))

0 commit comments

Comments
 (0)