Skip to content

Commit

Permalink
Fail unittests on DMD parsing errors (#154)
Browse files Browse the repository at this point in the history
  • Loading branch information
Vladiwostok authored Oct 8, 2024
1 parent 1363070 commit 2f46a00
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/dscanner/analysis/helpers.d
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ import dsymbol.modulecache : ModuleCache;
import std.experimental.allocator;
import std.experimental.allocator.mallocator;

import dmd.parse : Parser;
import dmd.astbase : ASTBase;
import dmd.astcodegen;
import dmd.frontend;
import dmd.parse : Parser;

S between(S)(S value, S before, S after) if (isSomeString!S)
{
Expand Down Expand Up @@ -390,6 +390,7 @@ void assertAnalyzerWarningsDMD(string code, const StaticAnalysisConfig config, b
import std.stdio : File;
import dscanner.analysis.rundmd : analyzeDmd, parseDmdModule;
import dscanner.utils : getModuleName;
import dmd.globals : global;

auto testFileName = "test.d";
File f = File(testFileName, "w");
Expand All @@ -403,6 +404,10 @@ void assertAnalyzerWarningsDMD(string code, const StaticAnalysisConfig config, b
f.close();

auto dmdModule = parseDmdModule(file, code);

if (global.errors > 0)
throw new AssertError("Failed to parse DMD module", file);

if (semantic)
dmdModule.fullSemantic();

Expand Down
1 change: 1 addition & 0 deletions src/dscanner/analysis/rundmd.d
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ private void setupDmd()
global.path = Strings();
global.path.push(dmdDirPath.ptr);
global.path.push(druntimeDirPath.ptr);
global.errors = 0;
initDMD();
}

Expand Down

0 comments on commit 2f46a00

Please sign in to comment.