D-Scanner icon indicating copy to clipboard operation
D-Scanner copied to clipboard

add test for ignored & templated unittests

Open WebFreak001 opened this issue 2 years ago • 1 comments

in DMD it seems to be a syntax error to have unittests in functions or other unittests, but in libdparse it's allowed, so this dscanner check adds a warning/error for that.

In the same check it implements a warning for unittests which are used in templates. However as unittests in templates could be there just for documentation, no warning is issued if annotated with a doc comment.

Mixin templates are not regarded as templates in this check as they might be used for automatically generating unittests outside templates.

WebFreak001 avatar Mar 17 '22 12:03 WebFreak001

In the same check it implements a warning for unittests which are used in templates. However as unittests in templates could be there just for documentation, no warning is issued if annotated with a doc comment.

Unittests should run in the binary that initialized them. If this isn't happening that is a bug.

That should probably be removed.

Error for this causing CI failures.

std/experimental/allocator/building_blocks/bitmapped_block.d std/experimental/allocator/building_blocks/bitmapped_block.d(1370:17)[warn]: unittest blocks in templates may not be run and can only serve for documentation purpose. Document with a ddoc-comment or move unittest block out of template. std/experimental/allocator/building_blocks/bitmapped_block.d(1645:17)[warn]: unittest blocks in templates may not be run and can only serve for documentation purpose. Document with a ddoc-comment or move unittest block out of template. std/experimental/allocator/building_blocks/bitmapped_block.d(2176:13)[warn]: unittest blocks in templates may not be run and can only serve for documentation purpose. Document with a ddoc-comment or move unittest block out of template.

rikkimax avatar May 17 '22 14:05 rikkimax