Skip to content

Don't allow testsignal to pick up non-stdlib dependencies - #1343

Merged
brandur merged 1 commit into
masterfrom
brandur-no-non-stdlib-deps
Aug 6, 2026
Merged

Don't allow testsignal to pick up non-stdlib dependencies#1343
brandur merged 1 commit into
masterfrom
brandur-no-non-stdlib-deps

Conversation

@brandur

@brandur brandur commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

This one's aimed at producing a more permanent structural fix for #1342
by keeping an eye out for the same problematic condition using the
depguard lint. As a summary of the problem corrected by #1342:

  • We use the testsignal package in all kinds of non-test code, so
    packages including River always build against it.

  • testsignal was importing riversharedtest, which imports Testify,
    Goleak, YAML (through Testify).

  • This was causing all packages built against River to pick up an extra
    ~10 kB worth of dependencies in their production builds, which is bad.

Here, add some new rules for depguard:

  • Don't allow test packages like Goleak or Testify to be imported by any
    non-test Go files. We make an exception for internal test support
    packages like riverdbtest and riverdrivertest.

  • Don't allow testsignal to have any dependencies beyond stdlib and
    testutil.

  • Don't allow testutil to have any non-stdlib dependencies. This rule
    is so that testsignal doesn't pick up unexpected dependencies
    transitively through testutil.

@brandur

brandur commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

Lint currently failing due to #1342 not being merged yet.

@brandur
brandur requested a review from bgentry August 4, 2026 21:13
@brandur
brandur force-pushed the brandur-no-non-stdlib-deps branch from a2c522a to fdc7371 Compare August 6, 2026 06:18
This one's aimed at producing a more permanent structural fix for #1342
by keeping an eye out for the same problematic condition using the
depguard lint. As a summary of the problem corrected by #1342:

* We use the `testsignal` package in all kinds of non-test code, so
  packages including River always build against it.

* `testsignal` was importing `riversharedtest`, which imports Testify,
  Goleak, YAML (through Testify).

* This was causing all packages built against River to pick up an extra
  ~10 kB worth of dependencies in their production builds, which is bad.

Here, add some new rules for depguard:

* Don't allow test packages like Goleak or Testify to be imported by any
  non-test Go files. We make an exception for internal test support
  packages like `riverdbtest` and `riverdrivertest`.

* Don't allow `testsignal` to have any dependencies beyond stdlib and
  `testutil`.

* Don't allow `testutil` to have any non-stdlib dependencies. This rule
  is so that `testsignal` doesn't pick up unexpected dependencies
  transitively through `testutil`.
@brandur
brandur force-pushed the brandur-no-non-stdlib-deps branch from fdc7371 to 52a3ba5 Compare August 6, 2026 06:48
@brandur
brandur merged commit 238776f into master Aug 6, 2026
15 checks passed
@brandur
brandur deleted the brandur-no-non-stdlib-deps branch August 6, 2026 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants