Fail unittests on DMD parsing errors (#154)

This commit is contained in:
Vladiwostok 2024-10-08 15:09:33 +03:00 committed by Albert24GG
parent cc40e684cf
commit bb68206f38
2 changed files with 7 additions and 1 deletions

View File

@ -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();

View File

@ -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();
} }