-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathruntests.d
739 lines (673 loc) · 24 KB
/
runtests.d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
import core.sync.mutex;
import std.algorithm;
import std.conv;
import std.datetime.stopwatch;
import std.file;
import std.parallelism;
import std.path;
import std.process;
import std.range;
import std.regex;
import std.stdio;
import std.string;
static import std.system;
version (Windows)
{
enum os = "win";
enum exeExt = ".exe";
}
else
{
enum os = text(std.system.os);
enum exeExt = "";
}
enum Verbosity
{
none,
outputOnError = 1,
outputCommandAlways = 2,
outputAlways = 4,
showTime = 8,
expectFailue = 16,
github = 32,
}
version (linux)
{
import core.stdc.errno;
import core.sys.posix.sys.wait;
import core.sys.posix.sys.resource;
extern (C) pid_t wait4(pid_t, int*, int, rusage*);
int waitMem(Pid pid, ref long maxrss)
{
auto processID = pid.processID;
int exitCode;
rusage usage;
while (true)
{
int status;
auto check = wait4(processID, &status, 0, &usage);
if (check == -1)
{
if (errno == ECHILD)
{
throw new ProcessException("Process does not exist or is not a child process.");
}
else
{
assert(errno == EINTR);
continue;
}
}
if (WIFEXITED(status))
{
exitCode = WEXITSTATUS(status);
break;
}
else if (WIFSIGNALED(status))
{
exitCode = -WTERMSIG(status);
break;
}
}
maxrss = usage.ru_maxrss;
return exitCode;
}
}
immutable IGNORE_OUTPUT = "IGNORE_OUTPUT";
bool runCommand(string[] args, string desc, Verbosity verbosity, Mutex outputMutex,
string* output = null, string expectedOutput = IGNORE_OUTPUT, string input = "")
{
auto sw = StopWatch(AutoStart.yes);
auto pipes = pipeProcess(args, Redirect.stdin | Redirect.stdout | Redirect.stderrToStdout);
pipes.stdin.write(input);
pipes.stdin.close();
Appender!string app;
foreach (ubyte[] chunk; pipes.stdout.byChunk(4096))
app.put(chunk);
auto processId = pipes.pid.processID;
string memText;
version (linux)
{
long maxrss;
auto status = waitMem(pipes.pid, maxrss);
memText = format(", %d MB", (maxrss + 512) / 1024);
}
else
auto status = pipes.pid.wait();
if (output !is null)
*output = app.data;
sw.stop();
string extraText;
bool r = true;
bool wrongOutput;
if (status && (verbosity & Verbosity.expectFailue) == 0)
{
extraText = "Failure: ";
r = false;
}
else if (expectedOutput != IGNORE_OUTPUT && app.data.replace("\r", "")
.strip() != expectedOutput.replace("\r", ""))
{
extraText = "Wrong output: ";
r = false;
wrongOutput = true;
}
bool hasOutput;
if (!r && (verbosity & Verbosity.outputOnError))
hasOutput = true;
if (verbosity & Verbosity.outputCommandAlways)
hasOutput = true;
if ((verbosity & Verbosity.outputAlways) && (app.data.length || wrongOutput))
hasOutput = true;
bool anyOutput;
if (verbosity & Verbosity.showTime)
anyOutput = true;
if (hasOutput)
anyOutput = true;
outputMutex.lock();
if (anyOutput)
{
stderr.writefln("%s[%d.%03d s%s] %s%s", (hasOutput && (verbosity & Verbosity.github))
? "::group::" : "", sw.peek.total!"msecs" / 1000,
sw.peek.total!"msecs" % 1000, memText, extraText, desc);
}
if ((verbosity & Verbosity.outputCommandAlways) || (!r && (verbosity & Verbosity.outputOnError)))
{
stderr.writeln(escapeShellCommand(args));
}
if ((verbosity & Verbosity.outputAlways) || (!r && (verbosity & Verbosity.outputOnError)))
{
if (app.data.length)
stderr.writeln(app.data.replace("\r", "").strip());
if (wrongOutput)
{
stderr.writeln((verbosity & Verbosity.github)
? "::endgroup::\n::group::" : "", "Expected:");
stderr.writeln(expectedOutput.stripRight);
}
}
if (hasOutput && (verbosity & Verbosity.github))
stderr.writeln("::endgroup::");
if (anyOutput && !r && (verbosity & Verbosity.github))
stderr.writeln("::error::", extraText, desc);
outputMutex.unlock();
return r;
}
immutable variants = ["normal", "optdescent", "glr"];
enum TestType
{
all,
compileOnly,
generateOnly
}
struct Test
{
string name;
TestType testType;
string[] excludedVariants;
string testName;
string[] generatorOpts;
string[] extraDmdArgs;
string[] runtimeArgs;
string runtimeInput;
string runtimeOutput;
string[variants.length] expectedOutput;
string expectedOutputLexer;
}
struct TestInstance
{
size_t index;
string variant;
bool failed;
bool shouldExclude;
}
void parseGrammarComments(ref Test test, string filename)
{
string inputText = readText(filename);
foreach (line; inputText.splitter("\n"))
{
if (line.startsWith("//"))
line = line[2 .. $];
else if (line.startsWith("/*"))
line = line[2 .. $];
line = line.strip();
if (line.startsWith("GENPARSER_OPTS:"))
{
test.generatorOpts ~= line["GENPARSER_OPTS:".length .. $].splitter()
.filter!(m => m.length)
.map!(m => m.idup)
.array;
}
else if (line.startsWith("EXCLUDE_VARIANT:"))
{
test.excludedVariants ~= line["EXCLUDE_VARIANT:".length .. $].splitter()
.filter!(m => m.length)
.map!(m => m.idup)
.array;
}
}
auto testOutputRegex = regex(
r"GENERATOR_OUTPUT(\(([^()]*)\))?: *\r?\n?----*\r?\n(([^-]|--?[^-])*)-?-?\n----*");
foreach (c; matchAll(inputText, testOutputRegex))
{
auto filters = c.captures[2].split(",").map!(s => s.strip)
.filter!(s => s.length != 0)
.array;
foreach (filter; filters)
{
if (filter != "lexer" && !variants.canFind(filter))
stderr.writeln("Unknown filter \"", filter, "\" in file ", filename);
}
foreach (i, variant; variants)
{
if (filters.length == 0 || filters.canFind(variant))
{
if (test.expectedOutput[i].length)
test.expectedOutput[i] ~= "\n";
test.expectedOutput[i] ~= c.captures[3].strip();
}
}
if (filters.length == 0 || filters.canFind("lexer"))
{
if (test.expectedOutputLexer.length)
test.expectedOutputLexer ~= "\n";
test.expectedOutputLexer ~= c.captures[3].strip();
}
}
}
bool compareFiles(string file1, string file2, Verbosity verbosity, Mutex outputMutex)
{
string text1 = readText(file1).replace("\r", "");
string text2 = readText(file2).replace("\r", "");
if (text1 != text2)
{
string diff;
runCommand(["diff", file1, file2], "", Verbosity.expectFailue, outputMutex, &diff);
stderr.writeln((verbosity & Verbosity.github) ? "::group::" : "",
"Files differ: ", file1, " ", file2);
stderr.writeln(diff.stripRight);
if (verbosity & Verbosity.github)
stderr.writeln("::endgroup::");
if (verbosity & Verbosity.github)
stderr.writeln("::error::", "Files differ: ", file1, " ", file2);
return false;
}
return true;
}
bool runGrammarTests(Test[] tests, string model, Verbosity verbosity,
string compiler, string generator, bool parallelCompiling, Mutex outputMutex)
{
immutable variantArgs = [
"normal": [], "optdescent": ["--optdescent"], "glr": ["--glr"]
];
bool anyFailure;
TestInstance[] testInstances;
foreach (i, ref test; tests)
{
const dir = buildPath("test_results", os ~ model, dirName(test.name));
mkdirRecurse(dir);
Verbosity verbosity2 = verbosity;
if (test.testType == TestType.generateOnly)
{
verbosity2 &= ~(Verbosity.outputAlways | Verbosity.outputCommandAlways);
verbosity2 |= Verbosity.expectFailue;
}
bool lexerFailed;
if (!runCommand([
generator, test.name ~ ".ebnf", "--lexer",
buildPath("test_results", os ~ model, test.name ~ "_lexer.d")
], "Generating lexer for " ~ test.name, verbosity2, outputMutex,
null, test.expectedOutputLexer))
{
lexerFailed = true;
anyFailure = true;
}
foreach (variant; variants)
{
if (test.excludedVariants.canFind(variant))
continue;
testInstances ~= TestInstance(i, variant);
if (lexerFailed)
testInstances[$ - 1].failed = true;
}
}
foreach (ref instance; parallel(testInstances, 1))
{
auto test = tests[instance.index];
auto variant = instance.variant;
Verbosity verbosity2 = verbosity;
if (test.testType == TestType.generateOnly)
{
verbosity2 &= ~(Verbosity.outputAlways | Verbosity.outputCommandAlways);
verbosity2 |= Verbosity.expectFailue;
}
string output;
if (!runCommand([
generator, test.name ~ ".ebnf",
"-o", buildPath("test_results", os ~ model, test.name ~ "_" ~ variant ~ ".d"),
"--module", baseName(test.name),
] ~ variantArgs[variant] ~ test.generatorOpts, "Generating parser for " ~ test.name ~ " variant " ~ variant,
verbosity2, outputMutex, null, test.expectedOutput[variants.countUntil(variant)]))
{
instance.shouldExclude = true;
instance.failed = true;
}
}
foreach (ref instance; testInstances)
{
if (instance.failed)
anyFailure = true;
if (instance.shouldExclude)
tests[instance.index].excludedVariants ~= instance.variant;
}
size_t maxTestBundleSize = 20;
struct TestBundle
{
string[] dmdArgs;
string[] tests;
string[] runtimeArgs;
string runtimeInput;
string runtimeOutput;
TestType testType;
string filename;
bool failed;
}
string versionArg = "-version";
if (compiler.endsWith("ldc2"))
versionArg = "--d-version";
TestBundle[] testBundles;
foreach (variant; variants)
{
TestBundle testBundle;
foreach (ref test; tests)
{
if (test.testType == TestType.generateOnly)
continue;
if (test.excludedVariants.canFind(variant))
continue;
bool needsOwnBundle = test.name.startsWith("examples")
|| test.runtimeArgs.length || test.runtimeInput.length;
if (testBundle.tests.length >= maxTestBundleSize
|| (testBundle.tests.length && needsOwnBundle))
{
testBundles ~= testBundle;
testBundle = TestBundle.init;
}
if (testBundle.tests.length == 0)
{
string name;
if (test.name.startsWith("examples"))
name = text(test.testName, "_", variant);
else
name = text("tests", testBundles.length, "_", variant);
testBundle.filename = buildPath("test_results", os ~ model, text(name, exeExt));
testBundle.dmdArgs = [
compiler, "-g", "-w", "-m" ~ model, "-i=dparsergen", "-Icore",
versionArg ~ "=" ~ variant, "-I" ~ dirName(test.name),
"-of" ~ testBundle.filename,
] ~ test.extraDmdArgs;
testBundle.runtimeArgs = test.runtimeArgs;
testBundle.runtimeInput = test.runtimeInput;
testBundle.runtimeOutput = test.runtimeOutput;
testBundle.testType = test.testType;
}
testBundle.dmdArgs ~= test.testName ~ ".d";
testBundle.dmdArgs ~= buildPath("test_results", os ~ model,
test.name ~ "_" ~ variant ~ ".d");
testBundle.dmdArgs ~= buildPath("test_results", os ~ model, test.name ~ "_lexer.d");
if (test.name == "examples/cpp/grammarcpp")
{
testBundle.dmdArgs ~= buildPath("test_results", os ~ model,
"examples/cpp/grammarcpreproc_normal.d");
testBundle.dmdArgs ~= buildPath("test_results", os ~ model,
"examples/cpp/grammarcpreproc_lexer.d");
}
testBundle.tests ~= test.name;
if (needsOwnBundle)
{
testBundles ~= testBundle;
testBundle = TestBundle.init;
}
}
if (testBundle.tests.length)
{
testBundles ~= testBundle;
}
}
testBundles.sort!((a, b) => a.filename < b.filename);
if (parallelCompiling)
{
foreach (ref testBundle; parallel(testBundles, 1))
{
if (!runCommand(testBundle.dmdArgs,
"Compiling " ~ testBundle.filename, verbosity | Verbosity.outputAlways, outputMutex))
testBundle.failed = true;
}
}
else
{
foreach (ref testBundle; testBundles)
{
if (!runCommand(testBundle.dmdArgs,
"Compiling " ~ testBundle.filename, verbosity | Verbosity.outputAlways, outputMutex))
testBundle.failed = true;
}
}
foreach (ref testBundle; testBundles)
{
if (testBundle.failed)
{
anyFailure = true;
continue;
}
if (testBundle.testType == TestType.compileOnly)
continue;
Verbosity verbosity2 = verbosity;
if (testBundle.runtimeOutput.length == 0)
verbosity2 |= Verbosity.outputAlways;
string output;
if (!runCommand([testBundle.filename] ~ testBundle.runtimeArgs, "Running " ~ testBundle.filename,
verbosity2, outputMutex, null, testBundle.runtimeOutput.length
? testBundle.runtimeOutput : IGNORE_OUTPUT, testBundle.runtimeInput))
{
anyFailure = true;
}
}
return anyFailure;
}
int main(string[] args)
{
bool anyFailure;
Verbosity verbosity = Verbosity.showTime | Verbosity.outputOnError;
string model;
static if (size_t.sizeof == 8)
model = "64";
else static if (size_t.sizeof == 4)
model = "32";
else
static assert("Unknown size of size_t");
string compiler = "dmd";
string jsonTestDir = absolutePath("examples/json/JSONTestSuite/test_parsing");
string dmdDir = absolutePath("dmd");
string pythonTestDir = absolutePath("cpython/Lib/test/");
bool skipSlowExamples;
bool avoidParallelMemoryUsage;
Mutex outputMutex = new Mutex();
for (size_t i = 1; i < args.length; i++)
{
auto arg = args[i];
if (arg.startsWith("-m"))
{
model = arg[2 .. $];
}
else if (arg == "--compiler")
{
if (i + 1 >= args.length)
{
stderr.writeln("Missing argument for ", arg);
return 1;
}
i++;
compiler = args[i];
}
else if (arg == "--json-test-dir")
{
if (i + 1 >= args.length)
{
stderr.writeln("Missing argument for ", arg);
return 1;
}
i++;
jsonTestDir = absolutePath(args[i]);
}
else if (arg == "--dmd-dir")
{
if (i + 1 >= args.length)
{
stderr.writeln("Missing argument for ", arg);
return 1;
}
i++;
dmdDir = absolutePath(args[i]);
}
else if (arg == "--python-test-dir")
{
if (i + 1 >= args.length)
{
stderr.writeln("Missing argument for ", arg);
return 1;
}
i++;
pythonTestDir = absolutePath(args[i]);
}
else if (arg == "--skip-slow-examples")
{
skipSlowExamples = true;
}
else if (arg == "--avoid-parallel-memory-usage")
{
avoidParallelMemoryUsage = true;
}
else if (arg == "-v")
{
verbosity |= Verbosity.outputAlways | Verbosity.outputCommandAlways;
}
else if (arg == "--github")
{
verbosity |= Verbosity.github;
}
else
{
stderr.writeln("Unknown argument ", arg);
return 1;
}
}
version (Windows)
{
import core.sys.windows.winbase : SetErrorMode, SEM_NOGPFAULTERRORBOX;
uint dwMode = SetErrorMode(SEM_NOGPFAULTERRORBOX);
SetErrorMode(dwMode | SEM_NOGPFAULTERRORBOX);
}
const string generator = buildPath("test_results", os ~ model, "dparsergen" ~ exeExt);
const string generatortests = buildPath("test_results", os ~ model, "generatortests" ~ exeExt);
Test[] tests;
Test[] testsLate;
foreach (DirEntry e; dirEntries("tests/grammars", "*.ebnf", SpanMode.shallow))
{
tests ~= Test(e.name[0 .. $ - 5].replace("\\", "/"), TestType.all);
tests[$ - 1].testName = tests[$ - 1].name ~ "_test";
tests[$ - 1].extraDmdArgs = [
"-unittest", "-main", "tests/grammars/testhelpers.d"
];
parseGrammarComments(tests[$ - 1], e.name);
}
foreach (DirEntry e; dirEntries("tests/fail_grammars", "*.ebnf", SpanMode.shallow))
{
tests ~= Test(e.name[0 .. $ - 5].replace("\\", "/"), TestType.generateOnly);
parseGrammarComments(tests[$ - 1], e.name);
}
tests ~= Test("examples/calc/grammarcalc", TestType.all, ["glr"],
"examples/calc/testgrammarcalc", [], [], [], "1+2\n", ">>> 3\n>>>");
tests ~= Test("examples/json/grammarjson", skipSlowExamples ? TestType.compileOnly : TestType.all, [], "examples/json/testgrammarjson",
["--mergesimilarstates"], [], ["--test-dir", jsonTestDir]);
if (!skipSlowExamples)
{
testsLate ~= Test("examples/d/grammard", TestType.all, ["glr"],
"examples/d/testgrammard", [
"--optempty", "--mergesimilarstates", "--combinedreduce"
], ["-lowmem"], [
"--test-dir", absolutePath("examples/d/testgrammard-extra"),
"--test-dir-fail",
absolutePath("examples/d/testgrammard-extra-failure"),
"--test-dir", buildPath(dmdDir, "compiler/test/compilable"),
"--test-dir", buildPath(dmdDir, "compiler/test/runnable"),
"--test-dir", buildPath(dmdDir, "compiler/test/runnable_cxx"),
"--test-dir-fail-dmd",
buildPath(dmdDir, "compiler/test/fail_compilation"),
"--test-dir", buildPath(dmdDir, "druntime/src"),
"--test-dir", buildPath(dmdDir, "compiler/src"),
]);
version (Windows)
{
testsLate[$ - 1].extraDmdArgs ~= "-L/STACK:8388608";
}
}
tests ~= Test("examples/d/grammarddoc", TestType.compileOnly, [], "examples/d/grammardgen");
if (!skipSlowExamples)
{
testsLate ~= Test("examples/cpp/grammarcpp", TestType.all, [
"normal", "optdescent"
], "examples/cpp/testcpp", [
"--mergesimilarstates", "--optempty"
], [], ["examples/cpp/test.cpp"], "",
readText("examples/cpp/test-output.txt").strip());
}
tests ~= Test("examples/cpp/grammarcpreproc", TestType.generateOnly);
tests ~= Test("examples/python/grammarpeg", TestType.compileOnly, [], "examples/python/grammarpythongen");
if (!skipSlowExamples)
{
testsLate ~= Test("examples/python/grammarpython", TestType.all, ["glr"],
"examples/python/testpython", [], [], ["--test-dir", pythonTestDir]);
version (Windows)
{
testsLate[$ - 1].extraDmdArgs ~= "-L/STACK:10485760";
}
}
tests.sort!((a, b) => a.name < b.name);
if (!runCommand([
compiler, "-g", "-w", "-m" ~ model, "-i=dparsergen", "-Icore",
"-Igenerator", "generator/dparsergen/generator/generator.d",
"-of" ~ generator
], "Compiling dparsergen", verbosity | Verbosity.outputAlways, outputMutex))
return 1;
if (!runCommand([
generator, "generator/dparsergen/generator/grammarebnf.ebnf",
"-o", buildPath("test_results", os ~ model, "grammarebnf.d"),
"--module", "dparsergen.generator.grammarebnf"
], "Generating parser for grammarebnf", verbosity, outputMutex))
return 1;
if (!runCommand([
generator, "generator/dparsergen/generator/grammarebnf.ebnf",
"--package", "dparsergen.generator", "--lexer",
buildPath("test_results", os ~ model, "grammarebnf_lexer.d")
], "Generating lexer for grammarebnf", verbosity, outputMutex))
return 1;
if (!compareFiles(buildPath("test_results", os ~ model, "grammarebnf.d"),
"generator/dparsergen/generator/grammarebnf.d", verbosity, outputMutex))
anyFailure = true;
if (!compareFiles(buildPath("test_results", os ~ model, "grammarebnf_lexer.d"),
"generator/dparsergen/generator/grammarebnf_lexer.d", verbosity, outputMutex))
anyFailure = true;
{
string generatorHelp;
if (!runCommand([generator, "--help"], "Generating help for generator",
verbosity, outputMutex, &generatorHelp))
anyFailure = true;
std.file.write(buildPath("test_results", os ~ model, "help.txt"), generatorHelp);
string helpExpected = readText("docs/generator.md").replace("\r", "")
.findSplit("```\n")[2].findSplit("```\n")[0];
std.file.write(buildPath("test_results", os ~ model, "help-expected.txt"), helpExpected);
if (!compareFiles(buildPath("test_results", os ~ model, "help.txt"),
buildPath("test_results", os ~ model, "help-expected.txt"), verbosity, outputMutex))
anyFailure = true;
}
if (!runCommand([
generator, "generator/dparsergen/generator/grammarebnf.ebnf",
"--doc-html", buildPath("test_results", os ~ model, "grammarebnf.html"),
"--doc-md", buildPath("test_results", os ~ model, "grammarebnf.md")
], "Generating documentation for generator", verbosity, outputMutex))
anyFailure = true;
if (!compareFiles(buildPath("test_results", os ~ model, "grammarebnf.md"),
"docs/syntax.md", verbosity, outputMutex))
anyFailure = true;
string[] dmdArgsGeneratortests = [
compiler, "-g", "-w", "-m" ~ model, "-unittest", "-main", "-Icore",
"-Igenerator", "-of" ~ generatortests, "tests/generator/generatortests.d"
];
foreach (DirEntry e; dirEntries("core/dparsergen", "*.d", SpanMode.depth))
{
dmdArgsGeneratortests ~= e.name;
}
foreach (DirEntry e; dirEntries("generator/dparsergen", "*.d", SpanMode.depth))
{
dmdArgsGeneratortests ~= e.name;
}
if (!runCommand(dmdArgsGeneratortests, "Compiling generatortests", verbosity | Verbosity.outputAlways, outputMutex))
{
anyFailure = true;
}
else
{
if (!runCommand([generatortests], "Running generatortests",
verbosity | Verbosity.outputAlways, outputMutex))
{
anyFailure = true;
}
}
if (runGrammarTests(tests, model, verbosity, compiler, generator, true, outputMutex))
anyFailure = true;
if (!anyFailure && runGrammarTests(testsLate, model, verbosity, compiler,
generator, !avoidParallelMemoryUsage, outputMutex))
anyFailure = true;
return anyFailure;
}