test: pin the production receive limits, split the vacuous drain test, harden the lint-gate test (review of #55)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -53,12 +53,17 @@ func hasSkipNotice(out string) bool {
|
||||
|
||||
// runLint runs `task lint` in dir with the given PATH and returns its combined output and exit code.
|
||||
func runLint(t *testing.T, dir, path string) (string, int) {
|
||||
t.Helper()
|
||||
return runTask(t, dir, path, "lint")
|
||||
}
|
||||
|
||||
func runTask(t *testing.T, dir, path string, args ...string) (string, int) {
|
||||
t.Helper()
|
||||
taskBin, err := exec.LookPath("task")
|
||||
if err != nil {
|
||||
t.Skip("task not installed")
|
||||
}
|
||||
cmd := exec.Command(taskBin, "lint")
|
||||
cmd := exec.Command(taskBin, args...)
|
||||
cmd.Dir = dir
|
||||
cmd.Env = append(os.Environ(), "PATH="+path)
|
||||
var out bytes.Buffer
|
||||
@@ -87,6 +92,20 @@ func TestTaskLint_ExitsNonZeroWhenGolangciLintReportsAFinding(t *testing.T) {
|
||||
if hasSkipNotice(out) {
|
||||
t.Fatalf("task lint blamed a missing binary for a lint failure; output:\n%s", out)
|
||||
}
|
||||
if !strings.Contains(out, "errcheck") {
|
||||
t.Fatalf("a non-zero exit without the finding means the linter crashed, not that it found something; output:\n%s", out)
|
||||
}
|
||||
}
|
||||
|
||||
// The lint step only gates anything if `task check` runs it.
|
||||
func TestTaskCheck_RunsTheLintStep(t *testing.T) {
|
||||
out, code := runTask(t, scratchModule(t), os.Getenv("PATH"), "--dry", "check")
|
||||
if code != 0 {
|
||||
t.Fatalf("task --dry check exited %d; output:\n%s", code, out)
|
||||
}
|
||||
if !strings.Contains(out, "task: [lint]") {
|
||||
t.Fatalf("task check no longer runs the lint step; output:\n%s", out)
|
||||
}
|
||||
}
|
||||
|
||||
func TestTaskLint_SkipsWithANoticeWhenGolangciLintIsAbsent(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user