beads/cmd/bd/max_rows_embedded_test.go
Julian Knutsen 1137aeb70d
ci(bazel): embedded-Dolt tier 20/5 → 50/15 duration-balanced Bazel shards (F1) (#7156)
* ci(bazel): embedded-Dolt tier 20/5 -> 40/14 duration-balanced shards (F1)

Give the Bazel-only bazel-embedded job its own duration-balanced manifest
blocks for //cmd/bd:bd_embedded_test (20 -> 40 shards) and
//internal/storage/embeddeddolt:embeddeddolt_embedded_test (5 -> 14
shards), decoupled from PR Risk's/main.yml's legacy frozen 20/5-shard
fork/push jobs, mirroring F2's bd_proxied_test precedent.

- Measured every TestEmbedded* / embeddeddolt test's wall time in
  isolation; split 21 cmd-tier and 1 storage-tier single top-level test
  over 180s into disjoint sub-tests (3 irreducible exceptions left:
  TestEmbeddedUpdateConcurrent 475s, TestEmbeddedCloseConcurrent 308s,
  TestLargeBatchApplyStatementCounts712_Embedded 261s).
- New scripts/ci/gen_embedded_{cmd,storage}_shard_manifest.py +
  _embedded_shard_manifest_lib.py generate/check duration-balanced
  manifest blocks (LPT packing, incremental --write/--repack, exact-once
  --check), chosen at N=40/M=14 where the heaviest shard reaches the
  irreducible-test floor.
- Fixed 18 stale legacy 20-shard cmd manifest entries (and 1 storage
  entry) left over from earlier test splits, which would have hard-failed
  every shard of PR Risk's real test-embedded-cmd jobs on their next run.
- New scripts/embedded_shard_count_test.go policy tests tie the
  Bazel-only block's shard count to bazel.yml's check_shard_coverage.py
  argument and catch generator staleness; generalized
  TestBazelRetiredLanesCheckListedTestsRan's live-shard-count dispatch
  from bd_proxied_test-only to a map covering both embedded targets;
  removed TestBazelEmbeddedJobMirrorsEmbeddedTier's now-invalid
  BUILD.bazel-shard-count-equals-PR-Risk-matrix assertion.
- Verified: go test ./scripts/..., bazel test //scripts:scripts_test,
  actionlint, make ci-pr-policy, make bazel-sync-check all pass; full
  local bazel test of both targets at 40/14 shards passes 2/2; mutation
  testing confirms each new/changed policy test fails exactly when it
  should.

See ~/beads-bazel-plan/f1/impl-report.md for full detail.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(embedded-dolt): skip 712-item statement-count assertion under -race (F1)

TestLargeBatchApplyStatementCounts712_Embedded genuinely costs ~260-300s
under -race (confirmed by solo re-measurement: 298.60s) -- 14014 real SQL
statement round-trips through the race-instrumented in-process Dolt engine,
not an artifact and not splittable (one indivisible ApplyBatchInTx
transaction). It was the storage tier's single-test floor for CI shard
packing.

Apply the exact precedent TestLargeBatchApplyWallClock_Embedded already set
for its 1000-item shape: skip this assertion under raceEnabled (the cost is
race-instrumentation overhead on the Dolt engine's own internal
goroutine/lock machinery, not this test's own logic) and extend nightly.yml's
"Embedded Dolt batch-apply suite (non-race)" step's -run regex so the full
pinned 14014-statement baseline still runs, non-race, every night. Verified
directly: under -race the assertion now skips in 0.00s; without -race it
still runs and asserts Total=14015 (within the existing +/-2 tolerance) in
36.76s.

Updates scripts/ci_workflow_test.go's
TestNightlyFullTestRunsEmbeddedDoltBatchApplySuite to match the extended
regex.

Storage tier's new single-test ceiling under the per-PR -race lane drops
from ~260.7s to 152.38s (TestBatchApplyContract).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* ci(bazel): correct cmd-tier long-pole durations, re-pack embedded manifolds (F1)

Investigated coordinator item 2 (single-test long poles): TestEmbeddedUpdateConcurrent
(recorded 475.39s) and TestEmbeddedCloseConcurrent (recorded 308.06s), plus
the two other >180s cmd-tier entries from the same capture
(TestEmbeddedInitA 196.94s, TestEmbeddedEpicCloseEligibleReason 192.47s).

Root cause: NOT host contention, NOT backoff/retry sleeps (bdRunWithFlockRetry
contributes negligibly), NOT race-instrumented-subprocess overhead alone.
These numbers were captured via `bazel --nohome_rc test --config=embedded`
with the then-current 20-shard legacy manifest (~10-11 tests/shard) and
`-test.parallel=4`. Go's t.Parallel() starts each parallel test's elapsed
clock when its function is invoked, before the Parallel() call blocks it
waiting for a free one-of-4 slot -- so a test queued behind several other
heavy shard-mates has that queueing wait baked into its own recorded
`--- PASS: TestX (Ys)` time. This is shard-composition-dependent scheduling
delay, not a cost intrinsic to the test.

Confirmed two ways in an isolated clone (not this worktree, per the
no-plain-go-test-from-a-beads-checkout rule):
- Solo (no rivals at all): 151.83s / 106.48s / 63.58s / 66.08s.
- All four together with the real -race -test.parallel=4 flags and exactly
  4 tests requested (so nobody queues -- parallel slots == test count):
  141.34s / 113.80s / 69.79s / 74.63s.
Both agree closely and both are far below the capture-time numbers.

F1's LPT packer already isolates the heaviest tests into shards with few or
no other heavy rivals (TestEmbeddedUpdateConcurrent lands alone in its own
40-shard-block shard), so under the new manifest these tests see little to
no queueing delay in real CI. None of the four needed splitting, parallel
subtests, or raceEnabled-scaled N: once correctly measured, none exceeds the
180s single-test guideline (new corrected weights: 155.0 / 115.0 / 72.0 /
77.0s). Corrected scripts/ci/embedded_cmd_test_durations.json accordingly
(with a doc-comment explaining the methodology and both confirmations) and
re-packed the 40-shard Bazel-only block (--repack --write); --check passes
(exact-once coverage of all 241 discovered tests). The frozen legacy 20-shard
block is untouched and independently re-verified exact-once by simulating
embedded-test-shard.sh across all 20 shards (241/241 tests, no
duplicates/misses/errors).

New cmd-tier single-test ceiling: 179.47s (TestEmbeddedCloseAlreadyClosed,
likely itself somewhat inflated by the same mechanism but already under the
180s line as recorded, so no action needed).

Also updates scripts/ci/embedded_storage_test_durations.json: the prior
commit's raceEnabled-skip for TestLargeBatchApplyStatementCounts712_Embedded
means it now costs ~0s in the per-PR -race lane bazel-embedded actually
packs for (not its real ~260-300s non-race cost, which nightly.yml still
exercises) -- weight set to 1.0 with a doc comment tying it to the skip in
large_batch_apply_measure_test.go. Re-packed the 14-shard Bazel-only block
accordingly; --check passes (exact-once coverage of all 387 discovered
tests, excluding TestMain/TestConformance per that file's existing
convention). The frozen legacy 5-shard block is untouched and independently
re-verified exact-once via embedded-storage-test-shard.sh simulation
(388/388 tests, no duplicates/misses/errors).

Verification: go test ./scripts/... (includes the nightly.yml policy test),
make ci-pr-policy, make bazel-sync-check, actionlint all pass. Real local
`bazel --nohome_rc test --config=embedded //cmd/bd:bd_embedded_test
//internal/storage/embeddeddolt:embeddeddolt_embedded_test`
(--local_test_jobs=8, both targets together, on a shared/noisy sandbox host)
passes both targets; per-shard wall time from each shard's test.xml: cmd/bd
max 218.9s (shard 23/40, min 20.6s), storage max 251.1s (shard 5/14, min
0.98s) -- down from the prior oversubscribed sweep's 783.41s / 351.94s and
well under the single-test-floor-based ~475s projection this slice started
from. Projected tier lane time (max of the two targets, real dedicated CI
runners should do at least this well): ~251s, under the 5-minute target.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* test(embedded): un-vacuous TestEmbeddedDepB edges, split epic-close test, trim concurrency stress N (F1 review)

Coordinator review follow-ups on the F1 embedded-Dolt resharding slice:

- TestEmbeddedDepB (one of TestEmbeddedDep's two CI-speed split halves) was
  asserting its tree_* subtests against an edgeless graph, passing
  vacuously; restores the same parent-child/blocks edges TestEmbeddedDepA
  builds so those subtests exercise real multi-node traversal (review S2).
- TestEmbeddedEpicCloseEligibleReason split into
  TestEmbeddedEpicCloseEligibleReasonFlag/...Output for CI shard balance,
  matching the project's established single-concern split pattern.
- TestEmbeddedUpdateConcurrent/TestEmbeddedCloseConcurrent's
  issuesPerWorker reduced 5->2: under real concurrent-shard-load
  measurement these were genuine (not queueing-artifact) serialized-write
  costs; 2 preserves every invariant the test checks (duplicate-ID
  detection across all workers, one non-decreasing-list-count check per
  worker) at a fraction of the serialized work.
- large712ShapeName: the 712-shape's race skip and its zero-match guard now
  share one named constant instead of two independent literal shape-name
  strings, so a future rename of the shape can't silently skip the pinned
  statement-count assertion under race (review N2).
- Comment-only fixes (review N5) in files referencing test names since
  renamed/split by this slice's earlier work: close_proxied_integration_test.go,
  graph_apply_test.go, storage_class_proxied_integration_test.go,
  tests/regression/discovery_test.go, plus doc-comment path cleanups (N1:
  drop unverified ~/beads-bazel-plan paths/bead ids in favor of the
  committed duration JSON files and engdocs/TESTING.md).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* ci(bazel): re-derive embedded-Dolt durations under concurrent load; cap cmd shards at Bazel's 50-shard limit (F1 round 2)

Coordinator review required re-deriving every per-test duration weight from
a single, consistent, CI-realistic measurement (all shards running
concurrently, -test.parallel=4, race-enabled) instead of the prior pass's
mix of crowded-shard captures and solo/4-together spot-corrections, and
required measuring per-shard wall time via BEP testAttemptDuration rather
than a shard's outer test.xml <testsuites time> (which can include a
different, already-finished shard-mate's setup/teardown).

- scripts/ci/embedded_cmd_test_durations.json (242 tests) and
  scripts/ci/embedded_storage_test_durations.json (387 tests) rewritten in
  full from one consistent sweep. Every entry is now a fresh measurement;
  none is a carried-over capture-time value or an unverified estimate. Both
  files' _comment blocks retract the earlier "queueing delay baked into a
  test's own reported elapsed time" theory (testing.go's (*T).Parallel does
  not add wait time to a blocked test's own clock) and document the real
  methodology.
- Only one cmd-tier test remains over 200s (TestEmbeddedListFiltering,
  239.70s), already under the ~240s ceiling; no further top-level splits
  were needed this round.
- New finding: Bazel hard-caps shard_count at 50 per sh_test-like rule
  ("Having more than 50 shards is indicative of poor test organization";
  a native analysis-time limit, not configurable). The previous 88-shard
  plan for //cmd/bd:bd_embedded_test (chosen as the LPT-packed floor before
  this limit was discovered) is reverted to 50, Bazel's real ceiling.
  Repacking the fresh weights at 50 shards gives a heaviest shard of
  409.6s -- above the single-test floor of 239.7s, because 50 bins is not
  enough headroom over the suite's ~20145 measured test-seconds to flatten
  every bin to that floor. This makes the <=5 min lane target unreachable
  for the cmd tier via resharding alone within Bazel's native per-rule
  limit; see ~/beads-bazel-plan/f1/impl-report.md section 3c for the full
  writeup and the two remaining levers (suite-wide speedups or a
  multi-Bazel-rule split), neither attempted in this slice.
- internal/storage/embeddeddolt gets 15 Bazel-only shards (unaffected by
  the 50-shard cap): LPT-packed heaviest shard 225.3s, within target.
- cmd/bd/BUILD.bazel, internal/storage/embeddeddolt/BUILD.bazel,
  .github/workflows/bazel.yml, engdocs/CI_REQUIRED_CHECK_TOPOLOGY.md,
  scripts/embedded_shard_count_test.go, scripts/pr_risk_bazel_coverage_test.go,
  scripts/ci/gen_embedded_cmd_shard_manifest.py updated to the corrected
  50/15 shard counts (and, for the generator, N3: --write without an
  explicit total_shards now errors instead of silently regenerating the
  frozen legacy 20-shard block).
- .github/scripts/embedded-{cmd,storage}-test-shards.txt: re-packed
  Bazel-only blocks at 50/15; frozen legacy 20/5 blocks untouched except for
  N5 fixes to stale entries left by this slice's earlier test splits
  (TestShardScriptsListOnlyRealTests catches this class of bug; both
  legacy blocks reconfirmed exact-once).
- .github/workflows/nightly.yml / scripts/ci_workflow_test.go (N4): the
  embedded-dolt batch-apply nightly step now runs with `if: ${{
  !cancelled() }}` and its own explicit `-timeout 20m`, independent of the
  job-level timeout, with both halves now asserted by
  TestNightlyFullTestRunsEmbeddedDoltBatchApplySuite.

Verified: gofmt -l clean, go vet ./scripts/... clean, go test ./scripts/...
green, both generators' --check pass at 50/15 (and legacy 20/5 remain
exact-once via the frozen-block invariant).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* test(ci): rename embedded manifest staleness tests out of the ^TestEmbedded skip

The allowlisted go-test leg runs with -skip ^TestEmbedded, so tests named
TestEmbedded*ShardManifestGeneratorNotStale never ran there and the leg
failed with "matched no test that ran".

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Gas City Adopt-PR <adopt-pr@gascity.local>
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-03 21:30:03 -07:00

758 lines
30 KiB
Go

//go:build cgo
// be-u8z9: CLI-layer behavioral tests for BEADS_MAX_ROWS / --max-rows on the
// command paths beyond `bd list`. Each subtest:
// - inits a fresh rig (own DB so the row counts are exact)
// - exercises the command via exec.Command(bd, ...)
// - asserts the process exited with code 2 (cap exceeded) and that stderr
// names the source ("--max-rows=N" or "BEADS_MAX_ROWS=N").
//
// Gating matches the other embedded-dolt CLI tests: requires
// BEADS_TEST_EMBEDDED_DOLT=1 to opt in.
package main
import (
"fmt"
"os"
"os/exec"
"strings"
"testing"
)
func bdRunRaw(t *testing.T, bd, dir string, envExtras []string, args ...string) (string, int) {
t.Helper()
cmd := exec.Command(bd, args...)
cmd.Dir = dir
env := bdEnv(dir)
env = append(env, envExtras...)
cmd.Env = env
out, err := cmd.CombinedOutput()
if err == nil {
return string(out), 0
}
if exitErr, ok := err.(*exec.ExitError); ok {
return string(out), exitErr.ExitCode()
}
t.Fatalf("bd %s unexpected non-exit error: %v\n%s", strings.Join(args, " "), err, out)
return string(out), -1
}
// seedReadyIssues creates n top-level (no-dep, no-blocker) issues that all
// appear in `bd ready`. Useful for tests that need exactly n ready rows.
func seedReadyIssues(t *testing.T, bd, dir string, n int) []string {
t.Helper()
ids := make([]string, n)
for i := 0; i < n; i++ {
iss := bdCreate(t, bd, dir, fmt.Sprintf("max-rows seed %d", i), "--type", "task")
ids[i] = iss.ID
}
return ids
}
// TestEmbeddedMaxRowsNonListPaths covered the non-list CLI paths wired up in
// be-x42v.2: ready, dep tree, find-duplicates, graph --all, plus the env-only
// doctor family (lint, doctor --check=conventions, doctor --check=pollution),
// and config show emission of BEADS_MAX_ROWS.
//
// This test was split into five top-level tests (TestEmbeddedMaxRowsReady,
// TestEmbeddedMaxRowsReadyMerge, TestEmbeddedMaxRowsDepTreeAndDuplicates,
// TestEmbeddedMaxRowsGraph, TestEmbeddedMaxRowsDoctorAndConfig) below so the
// Bazel embedded-cmd shard script (a top-level-function-name sharder) can
// spread this ~564s single-process long pole across up to five shards
// instead of pinning it to one. Every t.Run subtest name and body is
// unchanged from the original single function; only the grouping into
// separate top-level funcs (each gated and built the same way) changed. See
// scripts/ci/embedded_cmd_test_durations.json for the before/after subtest-name
// equivalence proof.
// ----------- bd ready -----------
func TestEmbeddedMaxRowsReady(t *testing.T) {
if os.Getenv("BEADS_TEST_EMBEDDED_DOLT") != "1" {
t.Skip("set BEADS_TEST_EMBEDDED_DOLT=1 to run embedded dolt integration tests")
}
t.Parallel()
bd := buildEmbeddedBD(t)
t.Run("ReadyMaxRows_FlagOverCap_Exits2", func(t *testing.T) {
dir, _, _ := bdInit(t, bd, "--prefix", "mrrdf")
seedReadyIssues(t, bd, dir, 6)
out, code := bdRunRaw(t, bd, dir, nil, "ready", "--max-rows", "3")
if code != 2 {
t.Fatalf("expected exit 2 (cap exceeded), got %d\n%s", code, out)
}
if !strings.Contains(out, "too many rows") {
t.Errorf("stderr missing 'too many rows':\n%s", out)
}
if !strings.Contains(out, "--max-rows=3") {
t.Errorf("stderr missing source --max-rows=3:\n%s", out)
}
})
t.Run("ReadyMaxRows_EnvOverCap_Exits2", func(t *testing.T) {
dir, _, _ := bdInit(t, bd, "--prefix", "mrrde")
seedReadyIssues(t, bd, dir, 6)
out, code := bdRunRaw(t, bd, dir, []string{"BEADS_MAX_ROWS=3"}, "ready")
if code != 2 {
t.Fatalf("expected exit 2 (cap exceeded), got %d\n%s", code, out)
}
if !strings.Contains(out, "BEADS_MAX_ROWS=3") {
t.Errorf("stderr missing source BEADS_MAX_ROWS=3:\n%s", out)
}
})
// `bd ready --json` and `bd list --ready --json` route through
// GetReadyWorkWithCountsInTx, a separate query path from the plain
// `bd ready` above (GetReadyWorkInTx). Mirrors
// TestEmbeddedMaxRowsListBasic/Flag_OverCap's --json coverage for `bd list`.
t.Run("ReadyMaxRowsJSON_FlagOverCap_Exits2", func(t *testing.T) {
dir, _, _ := bdInit(t, bd, "--prefix", "mrrjf")
seedReadyIssues(t, bd, dir, 6)
out, code := bdRunRaw(t, bd, dir, nil, "ready", "--json", "--max-rows", "3")
if code != 2 {
t.Fatalf("expected exit 2 (cap exceeded), got %d\n%s", code, out)
}
if !strings.Contains(out, "too many rows") {
t.Errorf("stderr missing 'too many rows':\n%s", out)
}
if !strings.Contains(out, "--max-rows=3") {
t.Errorf("stderr missing source --max-rows=3:\n%s", out)
}
if idx := strings.Index(out, "Error: too many rows"); idx >= 0 {
if strings.Contains(out[:idx], "[") {
t.Errorf("stdout JSON output leaked before error message:\nfull=%s", out)
}
}
})
t.Run("ListReadyMaxRowsJSON_FlagOverCap_Exits2", func(t *testing.T) {
dir, _, _ := bdInit(t, bd, "--prefix", "mrrjl")
seedReadyIssues(t, bd, dir, 6)
out, code := bdRunRaw(t, bd, dir, nil, "list", "--ready", "--json", "--max-rows", "3")
if code != 2 {
t.Fatalf("expected exit 2 (cap exceeded), got %d\n%s", code, out)
}
if !strings.Contains(out, "too many rows") {
t.Errorf("stderr missing 'too many rows':\n%s", out)
}
if !strings.Contains(out, "--max-rows=3") {
t.Errorf("stderr missing source --max-rows=3:\n%s", out)
}
})
}
// ----------- bd ready (--include-ephemeral merge paths) -----------
func TestEmbeddedMaxRowsReadyMerge(t *testing.T) {
if os.Getenv("BEADS_TEST_EMBEDDED_DOLT") != "1" {
t.Skip("set BEADS_TEST_EMBEDDED_DOLT=1 to run embedded dolt integration tests")
}
t.Parallel()
bd := buildEmbeddedBD(t)
// be-x42v.4 follow-up (review SHOULD-FIX 8): confirms the cap still
// fires end-to-end for --include-ephemeral after propagating MaxRows
// into getReadyWispsInTx's wisp query (internal/storage/issueops/
// ready_work.go) — that change bounds the query itself but must not
// change whether the post-merge cap check in GetReadyWorkInTx trips.
t.Run("ReadyIncludeEphemeralMaxRows_FlagOverCap_Exits2", func(t *testing.T) {
dir, _, _ := bdInit(t, bd, "--prefix", "mrre")
for i := 0; i < 6; i++ {
bdCreate(t, bd, dir, fmt.Sprintf("Ephemeral ready %d", i), "--type", "task", "--ephemeral")
}
out, code := bdRunRaw(t, bd, dir, nil, "ready", "--include-ephemeral", "--max-rows", "3")
if code != 2 {
t.Fatalf("expected exit 2 (cap exceeded), got %d\n%s", code, out)
}
if !strings.Contains(out, "too many rows") {
t.Errorf("stderr missing 'too many rows':\n%s", out)
}
if !strings.Contains(out, "--max-rows=3") {
t.Errorf("stderr missing source --max-rows=3:\n%s", out)
}
})
// be-x42v.4 round-3 follow-up: GetReadyWorkWithCountsInTx (the `--json`
// path) independently bounds each of the issues and wisps queries by
// EffectiveSearchLimit(Limit, MaxRows), so with --include-ephemeral the
// PRE-TRIM merge of two tables can hold up to ~2x that per-table bound
// even though the caller's own --limit already keeps the DELIVERED page
// well within the cap. limit=2, cap=3, 2 ready rows in each table: each
// table's query returns 2 (2<=limit, no overage sniff at the per-table
// level — EffectiveSearchLimit(2,3)=2), the pre-trim merge is 4>cap=3,
// but the page actually handed back to the caller is trimmed to 2<=cap.
// Must exit 0, not trip the cap on the untrimmed merge.
t.Run("ReadyIncludeEphemeralMaxRowsJSON_MergedUnderLimit_NoError", func(t *testing.T) {
dir, _, _ := bdInit(t, bd, "--prefix", "mrrm")
for i := 0; i < 2; i++ {
bdCreate(t, bd, dir, fmt.Sprintf("Plain ready %d", i), "--type", "task")
}
for i := 0; i < 2; i++ {
bdCreate(t, bd, dir, fmt.Sprintf("Ephemeral ready %d", i), "--type", "task", "--ephemeral")
}
out, code := bdRunRaw(t, bd, dir, nil, "ready", "--json", "--include-ephemeral",
"--limit", "2", "--max-rows", "3")
if code != 0 {
t.Fatalf("expected exit 0 (delivered page under cap despite pre-trim merge overage), got %d\n%s", code, out)
}
if strings.Contains(out, "too many rows") {
t.Errorf("delivered-page-under-cap should not emit cap error:\n%s", out)
}
})
}
// ----------- bd dep tree, bd find-duplicates -----------
func TestEmbeddedMaxRowsDepTreeAndDuplicates(t *testing.T) {
if os.Getenv("BEADS_TEST_EMBEDDED_DOLT") != "1" {
t.Skip("set BEADS_TEST_EMBEDDED_DOLT=1 to run embedded dolt integration tests")
}
t.Parallel()
bd := buildEmbeddedBD(t)
t.Run("DepTreeMaxRows_TreeNodes_Exits2", func(t *testing.T) {
dir, _, _ := bdInit(t, bd, "--prefix", "mrdt")
// All tasks: default "blocks" dep type rejects epic→task, but task→task
// is fine and produces a tree with the same shape for cap purposes.
root := bdCreate(t, bd, dir, "Tree root", "--type", "task")
// Add 5 children so the dep tree has 6 nodes total (root + 5).
for i := 0; i < 5; i++ {
child := bdCreate(t, bd, dir, fmt.Sprintf("Tree dep %d", i), "--type", "task")
// `bd dep add A B` makes A depend on B (default dep type is "blocks").
bdDepAdd(t, bd, dir, root.ID, child.ID)
}
// Sanity: tree of size 6, cap of 2 → must exit 2 with source attribution.
out, code := bdRunRaw(t, bd, dir, nil, "dep", "tree", root.ID, "--max-rows", "2")
if code != 2 {
t.Fatalf("expected exit 2 (tree size > cap), got %d\n%s", code, out)
}
if !strings.Contains(out, "too many rows") {
t.Errorf("stderr missing 'too many rows':\n%s", out)
}
if !strings.Contains(out, "--max-rows=2") {
t.Errorf("stderr missing source --max-rows=2:\n%s", out)
}
})
// ----------- bd find-duplicates -----------
t.Run("FindDuplicatesMaxRows_Exits2", func(t *testing.T) {
dir, _, _ := bdInit(t, bd, "--prefix", "mrfd")
seedReadyIssues(t, bd, dir, 6)
out, code := bdRunRaw(t, bd, dir, nil, "find-duplicates", "--max-rows", "3")
if code != 2 {
t.Fatalf("expected exit 2 (cap exceeded), got %d\n%s", code, out)
}
if !strings.Contains(out, "--max-rows=3") {
t.Errorf("stderr missing source --max-rows=3:\n%s", out)
}
})
}
// ----------- bd graph --all, bd graph <issue> -----------
func TestEmbeddedMaxRowsGraph(t *testing.T) {
if os.Getenv("BEADS_TEST_EMBEDDED_DOLT") != "1" {
t.Skip("set BEADS_TEST_EMBEDDED_DOLT=1 to run embedded dolt integration tests")
}
t.Parallel()
bd := buildEmbeddedBD(t)
t.Run("GraphAllMaxRows_Exits2", func(t *testing.T) {
dir, _, _ := bdInit(t, bd, "--prefix", "mrgr")
seedReadyIssues(t, bd, dir, 6)
out, code := bdRunRaw(t, bd, dir, nil, "graph", "--all", "--max-rows", "3")
if code != 2 {
t.Fatalf("expected exit 2 (cap exceeded), got %d\n%s", code, out)
}
if !strings.Contains(out, "--max-rows=3") {
t.Errorf("stderr missing source --max-rows=3:\n%s", out)
}
})
// be-x42v.4 follow-up (review SHOULD-FIX 7): `bd graph <issue>` without
// --all never resolved the cap at all before the fix — loadGraphSubgraph
// is a BFS over per-ID GetDependents/GetDependencies lookups with no
// IssueFilter to thread MaxRows through, so this checks the final
// connected-component node count post-hoc, mirroring dep tree.
t.Run("GraphSingleIssueMaxRows_NodeCount_Exits2", func(t *testing.T) {
dir, _, _ := bdInit(t, bd, "--prefix", "mrgs")
root := bdCreate(t, bd, dir, "Graph root", "--type", "task")
for i := 0; i < 5; i++ {
child := bdCreate(t, bd, dir, fmt.Sprintf("Graph dep %d", i), "--type", "task")
bdDepAdd(t, bd, dir, root.ID, child.ID)
}
// Connected component of size 6 (root + 5), cap of 2 → exit 2.
out, code := bdRunRaw(t, bd, dir, nil, "graph", root.ID, "--max-rows", "2")
if code != 2 {
t.Fatalf("expected exit 2 (subgraph size > cap), got %d\n%s", code, out)
}
if !strings.Contains(out, "too many rows") {
t.Errorf("stderr missing 'too many rows':\n%s", out)
}
if !strings.Contains(out, "--max-rows=2") {
t.Errorf("stderr missing source --max-rows=2:\n%s", out)
}
})
t.Run("GraphSingleIssueMaxRows_UnderCap_NoError", func(t *testing.T) {
dir, _, _ := bdInit(t, bd, "--prefix", "mrgu")
root := bdCreate(t, bd, dir, "Graph root under cap", "--type", "task")
out, code := bdRunRaw(t, bd, dir, nil, "graph", root.ID, "--max-rows", "5")
if code != 0 {
t.Fatalf("expected exit 0 (single-node subgraph under cap), got %d\n%s", code, out)
}
if strings.Contains(out, "too many rows") {
t.Errorf("under-cap single-issue graph should not emit cap error:\n%s", out)
}
})
}
// ----------- bd lint, bd doctor (env-only), bd config show -----------
func TestEmbeddedMaxRowsDoctorAndConfig(t *testing.T) {
if os.Getenv("BEADS_TEST_EMBEDDED_DOLT") != "1" {
t.Skip("set BEADS_TEST_EMBEDDED_DOLT=1 to run embedded dolt integration tests")
}
t.Parallel()
bd := buildEmbeddedBD(t)
t.Run("LintMaxRows_EnvOnly_Exits2", func(t *testing.T) {
dir, _, _ := bdInit(t, bd, "--prefix", "mrln")
seedReadyIssues(t, bd, dir, 6)
out, code := bdRunRaw(t, bd, dir, []string{"BEADS_MAX_ROWS=3"}, "lint")
if code != 2 {
t.Fatalf("expected exit 2 (cap exceeded via env), got %d\n%s", code, out)
}
if !strings.Contains(out, "BEADS_MAX_ROWS=3") {
t.Errorf("stderr missing source BEADS_MAX_ROWS=3:\n%s", out)
}
})
t.Run("LintMaxRows_NoFlagAccepted", func(t *testing.T) {
// Designer §4: doctor family is env-opt-in only. The --max-rows
// flag must NOT be registered on `bd lint`; cobra should reject
// it as unknown.
dir, _, _ := bdInit(t, bd, "--prefix", "mrlnf")
out, code := bdRunRaw(t, bd, dir, nil, "lint", "--max-rows", "1")
if code == 0 {
t.Fatalf("expected non-zero exit (cobra rejects unknown flag), got 0\n%s", out)
}
if !strings.Contains(out, "unknown flag") {
t.Errorf("stderr missing 'unknown flag' rejection:\n%s", out)
}
// Defense against false positives: if `--max-rows` is wired on lint
// by mistake, this assertion would not trip — but the unknown-flag
// check above already covers it.
})
// ----------- bd doctor --check=conventions (env-only) -----------
//
// bd doctor is hard-gated to server mode (doctor.go:188 prints "not yet
// supported in embedded mode" and exits 0 before reaching the check
// dispatch). The embedded-Dolt test rig used here cannot exercise those
// code paths. The cap logic itself runs through the shared SearchIssues +
// EnforceMaxRowsCap path already covered by:
// - TestEnforceMaxRowsCap_* (internal/storage/issueops/search_test.go)
// - TestGetReadyWork_MaxRowsSuite (cmd/bd/ready_max_rows_test.go)
// - be-x42v.3 storage parity tests (bd list/search backend matrix)
// What's _not_ covered without server mode is the env-only resolver
// (resolveMaxRowsEnvOnly) on these specific commands. doctor_conventions.go
// and doctor_pollution.go both call it and pipe through handleMaxRowsError
// identically to lint.go, which IS covered above by LintMaxRows_EnvOnly_Exits2.
// A server-mode follow-up should add behavioral coverage here.
t.Run("ConventionsMaxRows_EnvOnly_Exits2", func(t *testing.T) {
t.Skip("bd doctor requires server mode (doctor.go:188); server-mode parity covered by separate validator bead")
})
t.Run("PollutionMaxRows_EnvOnly_Exits2", func(t *testing.T) {
t.Skip("bd doctor requires server mode (doctor.go:188); server-mode parity covered by separate validator bead")
})
// ----------- bd config show -----------
t.Run("ConfigShow_ListsBeadsMaxRows", func(t *testing.T) {
dir, _, _ := bdInit(t, bd, "--prefix", "mrcs")
// When BEADS_MAX_ROWS is set in the environment, `bd config show`
// must surface it in the standalone-env entries (config_show.go
// collectStandaloneEnvEntries).
out, code := bdRunRaw(t, bd, dir, []string{"BEADS_MAX_ROWS=42"}, "config", "show")
if code != 0 {
t.Fatalf("expected exit 0 from `bd config show`, got %d\n%s", code, out)
}
if !strings.Contains(out, "BEADS_MAX_ROWS") {
t.Errorf("expected `bd config show` to list BEADS_MAX_ROWS in output:\n%s", out)
}
if !strings.Contains(out, "42") {
t.Errorf("expected `bd config show` to display the value 42:\n%s", out)
}
// When the env var is unset, the entry must be absent (designer §4:
// opt-in only; default-disabled).
out2, code2 := bdRunRaw(t, bd, dir, nil, "config", "show")
if code2 != 0 {
t.Fatalf("expected exit 0 from `bd config show` (unset), got %d\n%s", code2, out2)
}
if strings.Contains(out2, "BEADS_MAX_ROWS") {
t.Errorf("expected BEADS_MAX_ROWS to be absent when env is unset:\n%s", out2)
}
})
}
// countListIDs returns the number of issue IDs of the form "<prefix>-<n>"
// observed in the combined `bd list` output. Used to verify that --limit
// actually clipped the result set without depending on JSON parsing of the
// pretty-printed array (which spans many lines).
func countListIDs(out, prefix string) int {
// Each list row prints the issue ID once; counting prefix occurrences in
// raw stdout is a robust enough check for our small fixtures.
return strings.Count(out, prefix+"-")
}
// TestEmbeddedMaxRowsList{Basic,LimitInteraction} were split from
// TestEmbeddedMaxRowsList (measured ~209.67s under --config=embedded) into 2
// top-level tests over disjoint subtest groups, for CI shard balance (see
// scripts/ci/embedded_cmd_test_durations.json and engdocs/TESTING.md). Every original
// subtest is preserved exactly once. Both cover the 10 designer §6.1
// behavioral scenarios for `bd list`. Builder bead: be-x42v.2 (CLI wiring).
// Each redoes the original's shared rig of 21 open task issues — the
// dataset size from the designer's fixture — independently.
func TestEmbeddedMaxRowsListBasic(t *testing.T) {
if os.Getenv("BEADS_TEST_EMBEDDED_DOLT") != "1" {
t.Skip("set BEADS_TEST_EMBEDDED_DOLT=1 to run embedded dolt integration tests")
}
t.Parallel()
bd := buildEmbeddedBD(t)
dir, _, _ := bdInit(t, bd, "--prefix", "mrl")
const totalRows = 21
for i := 0; i < totalRows; i++ {
bdCreate(t, bd, dir, fmt.Sprintf("List max-rows %d", i), "--type", "task")
}
t.Run("Disabled_NoEnv", func(t *testing.T) {
// Baseline: with no flag and no env var, `bd list` returns all rows.
out, code := bdRunRaw(t, bd, dir, nil, "list")
if code != 0 {
t.Fatalf("expected exit 0 (no cap), got %d\n%s", code, out)
}
if strings.Contains(out, "too many rows") {
t.Errorf("baseline `bd list` should not emit cap error:\n%s", out)
}
if got := countListIDs(out, "mrl"); got < totalRows {
t.Errorf("expected at least %d rows in output, got %d", totalRows, got)
}
})
t.Run("Flag_UnderCap", func(t *testing.T) {
// 21 rows under cap=100: success.
out, code := bdRunRaw(t, bd, dir, nil, "list", "--max-rows", "100")
if code != 0 {
t.Fatalf("expected exit 0 (under cap), got %d\n%s", code, out)
}
if strings.Contains(out, "too many rows") {
t.Errorf("under-cap `bd list` should not emit cap error:\n%s", out)
}
})
t.Run("Flag_OverCap", func(t *testing.T) {
// 21 rows over cap=5: exit 2, stderr includes --max-rows=5, stdout
// empty (designer §2.3: stdout is suppressed so `jq` downstream
// doesn't trip on partial JSON).
out, code := bdRunRaw(t, bd, dir, nil, "list", "--json", "--max-rows", "5")
if code != 2 {
t.Fatalf("expected exit 2 (cap exceeded), got %d\n%s", code, out)
}
if !strings.Contains(out, "too many rows") {
t.Errorf("expected 'too many rows' in stderr:\n%s", out)
}
if !strings.Contains(out, "--max-rows=5") {
t.Errorf("expected source `--max-rows=5` in stderr:\n%s", out)
}
// stdout-emptiness check: there should be no JSON `[` array opener
// in the merged output before the error. Cap-exceeded must not emit
// a partial array.
if idx := strings.Index(out, "Error: too many rows"); idx >= 0 {
before := out[:idx]
if strings.Contains(before, "[") {
t.Errorf("stdout JSON output leaked before error message:\nbefore=%q\nfull=%s", before, out)
}
}
})
t.Run("Env_OverCap", func(t *testing.T) {
out, code := bdRunRaw(t, bd, dir, []string{"BEADS_MAX_ROWS=5"}, "list")
if code != 2 {
t.Fatalf("expected exit 2 (cap exceeded via env), got %d\n%s", code, out)
}
if !strings.Contains(out, "BEADS_MAX_ROWS=5") {
t.Errorf("expected source `BEADS_MAX_ROWS=5` in stderr:\n%s", out)
}
})
t.Run("Flag_OverridesEnv", func(t *testing.T) {
// env says cap=5, flag says cap=100 — flag wins, expect success.
out, code := bdRunRaw(t, bd, dir, []string{"BEADS_MAX_ROWS=5"},
"list", "--max-rows", "100")
if code != 0 {
t.Fatalf("expected exit 0 (flag overrides env), got %d\n%s", code, out)
}
if strings.Contains(out, "too many rows") {
t.Errorf("flag-override should not emit cap error:\n%s", out)
}
})
t.Run("Flag_Zero_OverridesEnv", func(t *testing.T) {
// Explicit `--max-rows 0` disables the cap even when env is set
// (designer §2.1: ops shells with a global env can run a known-
// unbounded query without unsetting).
out, code := bdRunRaw(t, bd, dir, []string{"BEADS_MAX_ROWS=5"},
"list", "--max-rows", "0")
if code != 0 {
t.Fatalf("expected exit 0 (--max-rows 0 disables), got %d\n%s", code, out)
}
if strings.Contains(out, "too many rows") {
t.Errorf("explicit `--max-rows 0` should disable the cap:\n%s", out)
}
})
t.Run("BadEnv_LogsAndIgnores", func(t *testing.T) {
// env=banana → warning to stderr, normal output, exit 0
// (designer §2.1: fail-open on bad env so a typo in a global shell
// doesn't break automation).
out, code := bdRunRaw(t, bd, dir, []string{"BEADS_MAX_ROWS=banana"}, "list")
if code != 0 {
t.Fatalf("expected exit 0 (bad env ignored), got %d\n%s", code, out)
}
// max_rows.go:79 emits a "Warning: BEADS_MAX_ROWS=\"banana\" is not
// a non-negative integer; ignoring." line.
if !strings.Contains(out, "Warning") || !strings.Contains(out, "BEADS_MAX_ROWS") {
t.Errorf("expected warning about bad env in stderr:\n%s", out)
}
if strings.Contains(out, "too many rows") {
t.Errorf("bad env should not trigger cap error:\n%s", out)
}
})
t.Run("Negative_FlagRejected", func(t *testing.T) {
// max_rows.go:55 calls FatalError on negative — exit 1 with message.
out, code := bdRunRaw(t, bd, dir, nil, "list", "--max-rows", "-1")
if code != 1 {
t.Fatalf("expected exit 1 (usage error), got %d\n%s", code, out)
}
if !strings.Contains(out, "must be non-negative") {
t.Errorf("expected 'must be non-negative' in stderr:\n%s", out)
}
})
}
func TestEmbeddedMaxRowsListLimitInteraction(t *testing.T) {
if os.Getenv("BEADS_TEST_EMBEDDED_DOLT") != "1" {
t.Skip("set BEADS_TEST_EMBEDDED_DOLT=1 to run embedded dolt integration tests")
}
t.Parallel()
bd := buildEmbeddedBD(t)
dir, _, _ := bdInit(t, bd, "--prefix", "mrl")
const totalRows = 21
for i := 0; i < totalRows; i++ {
bdCreate(t, bd, dir, fmt.Sprintf("List max-rows %d", i), "--type", "task")
}
t.Run("LimitSet_CapTighter", func(t *testing.T) {
// limit=100, cap=5: 21 rows are scanned (LIMIT cap+1=6 sniffs
// overage), cap fires, exit 2. The --limit flag does not protect
// callers who set a generous limit but also opt into the cap.
out, code := bdRunRaw(t, bd, dir, nil, "list",
"--limit", "100", "--max-rows", "5")
if code != 2 {
t.Fatalf("expected exit 2 (cap tighter than limit), got %d\n%s", code, out)
}
if !strings.Contains(out, "--max-rows=5") {
t.Errorf("expected source `--max-rows=5` in stderr:\n%s", out)
}
})
t.Run("LimitSet_CapLooser", func(t *testing.T) {
// limit=5, cap=100: EffectiveSearchLimit returns 5 (limit wins when
// under cap), no overage detection, 5 rows returned, exit 0.
out, code := bdRunRaw(t, bd, dir, nil, "list",
"--limit", "5", "--max-rows", "100")
if code != 0 {
t.Fatalf("expected exit 0 (limit under cap), got %d\n%s", code, out)
}
if strings.Contains(out, "too many rows") {
t.Errorf("limit-under-cap should not emit cap error:\n%s", out)
}
if got := countListIDs(out, "mrl"); got != 5 {
t.Errorf("expected exactly 5 issue IDs in output, got %d:\n%s", got, out)
}
})
// be-x42v.4 follow-up (review MUST-FIX 4, revised round-3): --limit N
// --max-rows N with more than N matches must truncate to N and exit 0
// (the standard >N-matches truncation semantics), not error.
//
// Round-2 fix (regressed, since replaced): unconditionally skipped the
// workapi.WithFetchOneExtra probe-row bump when Limit>=MaxRows. That avoided
// the false cap error but also stopped fetching the extra row entirely,
// so len(results) could never exceed effectiveLimit and the GH#3212
// truncation notice silently stopped firing for this case — a partial
// result started presenting as complete.
//
// Round-3 fix: still fetch the probe row (Limit bumps to N+1 as
// normal), but when Limit==MaxRows exactly, bump MaxRows to N+1 too, in
// lockstep, so EnforceMaxRowsCap's comparison excludes the probe row
// from the cap check while the CLI's own len(results)>effectiveLimit
// truncation detection still sees it. See workapi.WithFetchOneExtra's doc
// comment in list.go for why this can't false-negative a real
// violation. Covered directly (bump values, not exit behavior) by
// TestWithFetchOneExtra_LimitEqualsCap_BumpsBothForTruncationProbe
// below, since printTruncationHint's text is gated on
// ui.IsStderrTerminal() and unconditionally suppressed for this
// subprocess harness's piped stderr (see list_embedded_test.go's
// limit_truncation_hint subtest) — these end-to-end subtests can only
// assert the absence of the false cap error and the delivered count.
t.Run("LimitEqualsCap_TruncatesNotErrors", func(t *testing.T) {
out, code := bdRunRaw(t, bd, dir, nil, "list",
"--limit", "5", "--max-rows", "5")
if code != 0 {
t.Fatalf("expected exit 0 (limit==cap truncates, does not error), got %d\n%s", code, out)
}
if strings.Contains(out, "too many rows") {
t.Errorf("limit==cap should not emit cap error:\n%s", out)
}
if got := countListIDs(out, "mrl"); got != 5 {
t.Errorf("expected exactly 5 issue IDs in output, got %d:\n%s", got, out)
}
})
t.Run("LimitEqualsCap_JSON_TruncatesNotErrors", func(t *testing.T) {
out, code := bdRunRaw(t, bd, dir, nil, "list", "--json",
"--limit", "5", "--max-rows", "5")
if code != 0 {
t.Fatalf("expected exit 0 (limit==cap truncates under --json), got %d\n%s", code, out)
}
if strings.Contains(out, "too many rows") {
t.Errorf("limit==cap under --json should not emit cap error:\n%s", out)
}
})
// be-x42v.4 round-4 follow-up: the round-3 fix to
// finishReadyWorkWithCounts (trim to Limit before EnforceMaxRowsCap)
// wasn't mirrored onto the sibling bd list search paths
// (searchInTx in search.go, finishSearchIssuesWithCounts in
// search_counts.go), which still capped the pre-trim merged
// issues+wisps set. `--include-infra` disables the default SkipWisps
// escape hatch, so the wisps merge actually runs. limit=2, cap=5, 3
// durable + 3 wisp issues: each leg's query is independently bounded
// by EffectiveSearchLimit, so the merge can produce up to 6 rows
// pre-trim (>cap=5) even though the delivered page (trimmed to 2) is
// well within the cap. Covers both bd list output modes (opus's live
// repro found both non-JSON and --json tripping the false cap error).
t.Run("IncludeInfraMergedUnderLimit_NoError", func(t *testing.T) {
mDir, _, _ := bdInit(t, bd, "--prefix", "mrii")
for i := 0; i < 3; i++ {
bdCreate(t, bd, mDir, fmt.Sprintf("Durable infra %d", i), "--type", "task")
}
for i := 0; i < 3; i++ {
bdCreate(t, bd, mDir, fmt.Sprintf("Wisp infra %d", i), "--type", "task", "--ephemeral")
}
out, code := bdRunRaw(t, bd, mDir, nil, "list", "--include-infra",
"--limit", "2", "--max-rows", "5")
if code != 0 {
t.Fatalf("expected exit 0 (delivered page under cap despite pre-trim merge overage), got %d\n%s", code, out)
}
if strings.Contains(out, "too many rows") {
t.Errorf("delivered-page-under-cap should not emit cap error:\n%s", out)
}
outJSON, codeJSON := bdRunRaw(t, bd, mDir, nil, "list", "--include-infra", "--json",
"--limit", "2", "--max-rows", "5")
if codeJSON != 0 {
t.Fatalf("expected exit 0 under --json (delivered page under cap despite pre-trim merge overage), got %d\n%s", codeJSON, outJSON)
}
if strings.Contains(outJSON, "too many rows") {
t.Errorf("delivered-page-under-cap under --json should not emit cap error:\n%s", outJSON)
}
})
// be-x42v.4 round-5 follow-up: searchInTx's merge branch concatenates
// two independently ORDER BY'd legs (`append(filtered, wispResults...)`)
// and round-4's trimToSearchLimit then sliced that unsorted
// concatenation — with Limit small enough that durable rows alone fill
// it, a higher-ranked wisp was silently dropped from the page even
// though the CLI's pre-round-4 behavior (return the full merged set,
// let the caller sort-then-trim) surfaced it correctly. Default sort is
// priority ASC: 3 durable issues at P2, one wisp at P0 (highest rank)
// — with --limit 1 the P0 wisp must be the sole delivered row, not one
// of the P2 durable rows the unsorted concatenation happened to put
// first. Must fail against 77227aa67.
t.Run("IncludeInfraMerged_WispOutranksDurable_InDeliveredPage", func(t *testing.T) {
mDir, _, _ := bdInit(t, bd, "--prefix", "mrwo")
for i := 0; i < 3; i++ {
bdCreate(t, bd, mDir, fmt.Sprintf("Durable p2 %d", i), "--type", "task", "--priority", "2")
}
wisp := bdCreate(t, bd, mDir, "Wisp p0 outranks", "--type", "task", "--priority", "0", "--ephemeral")
out, code := bdRunRaw(t, bd, mDir, nil, "list", "--include-infra", "--limit", "1")
if code != 0 {
t.Fatalf("expected exit 0, got %d\n%s", code, out)
}
if !strings.Contains(out, wisp.ID) {
t.Errorf("P0 wisp %s must be the sole row in a --limit 1 page (default sort is priority ASC), got:\n%s", wisp.ID, out)
}
outJSON, codeJSON := bdRunRaw(t, bd, mDir, nil, "list", "--include-infra", "--json", "--limit", "1")
if codeJSON != 0 {
t.Fatalf("expected exit 0 under --json, got %d\n%s", codeJSON, outJSON)
}
if !strings.Contains(outJSON, wisp.ID) {
t.Errorf("P0 wisp %s must be the sole row in a --limit 1 --json page, got:\n%s", wisp.ID, outJSON)
}
})
// be-x42v.4 follow-up (review MUST-FIX 5): the initial query under
// `bd list --watch` must surface a cap violation with exit 2, same as
// non-watch `bd list`. Before the fix, watchIssues logged the error to
// stderr itself and returned void, so the process always exited 0 —
// the failure never reached RunE/handleMaxRowsError. This subprocess
// exercises only the initial-query failure path (returns before
// entering the polling loop), so it terminates without needing Ctrl+C.
t.Run("Watch_FlagOverCap_Exits2", func(t *testing.T) {
out, code := bdRunRaw(t, bd, dir, nil, "list", "--watch", "--max-rows", "5")
if code != 2 {
t.Fatalf("expected exit 2 (cap exceeded under --watch), got %d\n%s", code, out)
}
if !strings.Contains(out, "too many rows") {
t.Errorf("expected 'too many rows' in stderr:\n%s", out)
}
if !strings.Contains(out, "--max-rows=5") {
t.Errorf("expected source `--max-rows=5` in stderr:\n%s", out)
}
})
}