Skip to content

lint: Detect missing TestMain in _test packages

Will Chandler (ex-GitLab) requested to merge wc/lint-testhelper-facts into master

lint: Detect missing TestMain in _test packages

With 3adbbfb5 (lint: Add linter for testhelper.Run, 2023-08-24) we added a linter to detect if a package did not contain a TestMain function. This was limited to checking non-test packages as each analysis pass is self-contained and does not allow us to cross-reference another package.

To allow us to reliably detect when a primary package does not have tests, but its _test package does, start exporting a testhelperFact that indicates if a package has a TestMain function. When analyzing a _test package, we can import the fact of its related package and prevent false positives.

Merge request reports