Fail unittests on DMD parsing errors (#154)
This commit is contained in:
parent
444f4e20b6
commit
65253f6121
|
|
@ -20,10 +20,10 @@ import dsymbol.modulecache : ModuleCache;
|
||||||
import std.experimental.allocator;
|
import std.experimental.allocator;
|
||||||
import std.experimental.allocator.mallocator;
|
import std.experimental.allocator.mallocator;
|
||||||
|
|
||||||
import dmd.parse : Parser;
|
|
||||||
import dmd.astbase : ASTBase;
|
import dmd.astbase : ASTBase;
|
||||||
import dmd.astcodegen;
|
import dmd.astcodegen;
|
||||||
import dmd.frontend;
|
import dmd.frontend;
|
||||||
|
import dmd.parse : Parser;
|
||||||
|
|
||||||
S between(S)(S value, S before, S after) if (isSomeString!S)
|
S between(S)(S value, S before, S after) if (isSomeString!S)
|
||||||
{
|
{
|
||||||
|
|
@ -390,6 +390,7 @@ void assertAnalyzerWarningsDMD(string code, const StaticAnalysisConfig config, b
|
||||||
import std.stdio : File;
|
import std.stdio : File;
|
||||||
import dscanner.analysis.rundmd : analyzeDmd, parseDmdModule;
|
import dscanner.analysis.rundmd : analyzeDmd, parseDmdModule;
|
||||||
import dscanner.utils : getModuleName;
|
import dscanner.utils : getModuleName;
|
||||||
|
import dmd.globals : global;
|
||||||
|
|
||||||
auto testFileName = "test.d";
|
auto testFileName = "test.d";
|
||||||
File f = File(testFileName, "w");
|
File f = File(testFileName, "w");
|
||||||
|
|
@ -403,6 +404,10 @@ void assertAnalyzerWarningsDMD(string code, const StaticAnalysisConfig config, b
|
||||||
f.close();
|
f.close();
|
||||||
|
|
||||||
auto dmdModule = parseDmdModule(file, code);
|
auto dmdModule = parseDmdModule(file, code);
|
||||||
|
|
||||||
|
if (global.errors > 0)
|
||||||
|
throw new AssertError("Failed to parse DMD module", file);
|
||||||
|
|
||||||
if (semantic)
|
if (semantic)
|
||||||
dmdModule.fullSemantic();
|
dmdModule.fullSemantic();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -85,6 +85,7 @@ private void setupDmd()
|
||||||
global.path = Strings();
|
global.path = Strings();
|
||||||
global.path.push(dmdDirPath.ptr);
|
global.path.push(dmdDirPath.ptr);
|
||||||
global.path.push(druntimeDirPath.ptr);
|
global.path.push(druntimeDirPath.ptr);
|
||||||
|
global.errors = 0;
|
||||||
initDMD();
|
initDMD();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue