Skip to content

Commit

Permalink
Respect "skip unittest" user configuration (#139)
Browse files Browse the repository at this point in the history
  • Loading branch information
Vladiwostok authored Sep 29, 2024
1 parent 2e3b6b0 commit 02384a9
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/dscanner/analysis/explicitly_annotated_unittests.d
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ extern(C++) class ExplicitlyAnnotatedUnittestCheck(AST) : BaseAnalyzerDmd
{
import dmd.astenums : STC;

if (skipTests)
return;

if (!(d.storage_class & STC.safe || d.storage_class & STC.system))
addErrorMessage(cast(ulong) d.loc.linnum, cast(ulong) d.loc.charnum,
KEY, MESSAGE);
Expand Down
3 changes: 3 additions & 0 deletions src/dscanner/analysis/has_public_example.d
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ extern (C++) class HasPublicExampleCheck(AST) : BaseAnalyzerDmd

override void visit(AST.UnitTestDeclaration unitTestDecl)
{
if (skipTests)
return;

if (unitTestDecl.comment() !is null)
isDocumented = true;
}
Expand Down
23 changes: 22 additions & 1 deletion src/dscanner/analysis/label_var_same_name_check.d
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ extern (C++) class LabelVarNameCheck(AST) : BaseAnalyzerDmd

mixin FunctionVisit!(AST.FuncDeclaration);
mixin FunctionVisit!(AST.TemplateDeclaration);
mixin FunctionVisit!(AST.UnitTestDeclaration);
mixin FunctionVisit!(AST.FuncLiteralDeclaration);

mixin AggregateVisit!(AST.ClassDeclaration);
Expand Down Expand Up @@ -134,6 +133,28 @@ extern (C++) class LabelVarNameCheck(AST) : BaseAnalyzerDmd
popAggregateName();
}

override void visit(AST.UnitTestDeclaration unitTestDecl)
{
if (skipTests)
return;

auto oldIsInFunction = isInFunction;
auto oldIsInLocalFunction = isInLocalFunction;

pushScope();

if (isInFunction)
isInLocalFunction = true;
else
isInFunction = true;

super.visit(unitTestDecl);
popScope();

isInFunction = oldIsInFunction;
isInLocalFunction = oldIsInLocalFunction;
}

private:
extern (D) Thing[string][] stack;
int conditionalDepth;
Expand Down

0 comments on commit 02384a9

Please sign in to comment.