Skip to content

Commit

Permalink
bisect: diagnose bad targets better
Browse files Browse the repository at this point in the history
If a run fails but prints no matches, that's usually a misconfiguration
of the target or a build failure or something like that. Stop immediately
in the run method, instead of having to check for the case later.
This way, this failure mode is diagnosed more quickly and more consistently.

Change-Id: I43141c499b04e304bfb0417a5efd1e1b5dc2ba5e
Reviewed-on: https://go-review.googlesource.com/c/tools/+/493618
Reviewed-by: David Chase <drchase@google.com>
Auto-Submit: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
  • Loading branch information
rsc authored and gopherbot committed May 8, 2023
1 parent d5af889 commit 23e52a3
Show file tree
Hide file tree
Showing 13 changed files with 430 additions and 426 deletions.
10 changes: 7 additions & 3 deletions cmd/bisect/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,13 +240,13 @@ func (b *Bisect) Search() bool {
switch {
case runN.Success && !runY.Success:
b.Logf("target succeeds with no changes, fails with all changes")
b.Logf("searching for minimal set of changes to enable to cause failure")
b.Logf("searching for minimal set of enabled changes causing failure")
broken = runY
b.Disable = false

case !runN.Success && runY.Success:
b.Logf("target fails with no changes, succeeds with all changes")
b.Logf("searching for minimal set of changes to disable to cause failure")
b.Logf("searching for minimal set of disabled changes causing failure")
broken = runN
b.Disable = true

Expand Down Expand Up @@ -500,7 +500,7 @@ func (b *Bisect) run(suffix string) *Result {
// There is no newline in the log print.
// The line will be completed when the command finishes.
cmdText := strings.Join(append(append(env, b.Cmd), args...), " ")
fmt.Fprintf(b.Stderr, "bisect: run %s...", cmdText)
fmt.Fprintf(b.Stderr, "bisect: run: %s...", cmdText)

// Run command with args and env.
var out []byte
Expand Down Expand Up @@ -567,6 +567,10 @@ func (b *Bisect) run(suffix string) *Result {
fmt.Fprintf(b.Stderr, " FAIL (%d matches)\n", len(r.MatchIDs))
}

if err != nil && len(r.MatchIDs) == 0 {
b.Fatalf("target failed without printing any matches\n%s", r.Out)
}

// In verbose mode, print extra debugging: all the lines with match markers.
if b.Verbose {
b.Logf("matches:\n%s", strings.Join(r.MatchFull, "\n\t"))
Expand Down
48 changes: 24 additions & 24 deletions cmd/bisect/testdata/basic.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,37 @@ apricot
---
-- stderr --
bisect: checking target with all changes disabled
bisect: run test n... ok (90 matches)
bisect: run: test n... ok (90 matches)
bisect: checking target with all changes enabled
bisect: run test y... FAIL (90 matches)
bisect: run: test y... FAIL (90 matches)
bisect: target succeeds with no changes, fails with all changes
bisect: searching for minimal set of changes to enable to cause failure
bisect: run test +0... FAIL (45 matches)
bisect: run test +00... ok (23 matches)
bisect: run test +10... FAIL (22 matches)
bisect: run test +010... FAIL (11 matches)
bisect: run test +0010... FAIL (6 matches)
bisect: run test +00010... FAIL (3 matches)
bisect: run test +000010... FAIL (2 matches)
bisect: run test +0000010... FAIL (1 matches)
bisect: searching for minimal set of enabled changes causing failure
bisect: run: test +0... FAIL (45 matches)
bisect: run: test +00... ok (23 matches)
bisect: run: test +10... FAIL (22 matches)
bisect: run: test +010... FAIL (11 matches)
bisect: run: test +0010... FAIL (6 matches)
bisect: run: test +00010... FAIL (3 matches)
bisect: run: test +000010... FAIL (2 matches)
bisect: run: test +0000010... FAIL (1 matches)
bisect: confirming failing change set
bisect: run test v+0000010... FAIL (1 matches)
bisect: run: test v+0000010... FAIL (1 matches)
bisect: FOUND failing change set
bisect: checking for more failures
bisect: run test -0000010... FAIL (89 matches)
bisect: run: test -0000010... FAIL (89 matches)
bisect: target still fails; searching for more bad changes
bisect: run test +0-0000010... FAIL (44 matches)
bisect: run test +00-0000010... ok (23 matches)
bisect: run test +10-0000010... FAIL (21 matches)
bisect: run test +010-0000010... ok (10 matches)
bisect: run test +110-0000010... FAIL (11 matches)
bisect: run test +0110-0000010... FAIL (6 matches)
bisect: run test +00110-0000010... FAIL (3 matches)
bisect: run test +000110-0000010... FAIL (2 matches)
bisect: run test +0000110-0000010... FAIL (1 matches)
bisect: run: test +0-0000010... FAIL (44 matches)
bisect: run: test +00-0000010... ok (23 matches)
bisect: run: test +10-0000010... FAIL (21 matches)
bisect: run: test +010-0000010... ok (10 matches)
bisect: run: test +110-0000010... FAIL (11 matches)
bisect: run: test +0110-0000010... FAIL (6 matches)
bisect: run: test +00110-0000010... FAIL (3 matches)
bisect: run: test +000110-0000010... FAIL (2 matches)
bisect: run: test +0000110-0000010... FAIL (1 matches)
bisect: confirming failing change set
bisect: run test v+0000110-0000010... FAIL (1 matches)
bisect: run: test v+0000110-0000010... FAIL (1 matches)
bisect: FOUND failing change set
bisect: checking for more failures
bisect: run test -0000110-0000010... ok (88 matches)
bisect: run: test -0000110-0000010... ok (88 matches)
bisect: target succeeds with all remaining changes enabled
94 changes: 47 additions & 47 deletions cmd/bisect/testdata/count2.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,60 +8,60 @@ apricot
---
-- stderr --
bisect: checking target with all changes disabled
bisect: run test n... ok (90 matches)
bisect: run test n... ok (90 matches)
bisect: run: test n... ok (90 matches)
bisect: run: test n... ok (90 matches)
bisect: checking target with all changes enabled
bisect: run test y... FAIL (90 matches)
bisect: run test y... FAIL (90 matches)
bisect: run: test y... FAIL (90 matches)
bisect: run: test y... FAIL (90 matches)
bisect: target succeeds with no changes, fails with all changes
bisect: searching for minimal set of changes to enable to cause failure
bisect: run test +0... FAIL (45 matches)
bisect: run test +0... FAIL (45 matches)
bisect: run test +00... ok (23 matches)
bisect: run test +00... ok (23 matches)
bisect: run test +10... FAIL (22 matches)
bisect: run test +10... FAIL (22 matches)
bisect: run test +010... FAIL (11 matches)
bisect: run test +010... FAIL (11 matches)
bisect: run test +0010... FAIL (6 matches)
bisect: run test +0010... FAIL (6 matches)
bisect: run test +00010... FAIL (3 matches)
bisect: run test +00010... FAIL (3 matches)
bisect: run test +000010... FAIL (2 matches)
bisect: run test +000010... FAIL (2 matches)
bisect: run test +0000010... FAIL (1 matches)
bisect: run test +0000010... FAIL (1 matches)
bisect: searching for minimal set of enabled changes causing failure
bisect: run: test +0... FAIL (45 matches)
bisect: run: test +0... FAIL (45 matches)
bisect: run: test +00... ok (23 matches)
bisect: run: test +00... ok (23 matches)
bisect: run: test +10... FAIL (22 matches)
bisect: run: test +10... FAIL (22 matches)
bisect: run: test +010... FAIL (11 matches)
bisect: run: test +010... FAIL (11 matches)
bisect: run: test +0010... FAIL (6 matches)
bisect: run: test +0010... FAIL (6 matches)
bisect: run: test +00010... FAIL (3 matches)
bisect: run: test +00010... FAIL (3 matches)
bisect: run: test +000010... FAIL (2 matches)
bisect: run: test +000010... FAIL (2 matches)
bisect: run: test +0000010... FAIL (1 matches)
bisect: run: test +0000010... FAIL (1 matches)
bisect: confirming failing change set
bisect: run test v+0000010... FAIL (1 matches)
bisect: run test v+0000010... FAIL (1 matches)
bisect: run: test v+0000010... FAIL (1 matches)
bisect: run: test v+0000010... FAIL (1 matches)
bisect: FOUND failing change set
bisect: checking for more failures
bisect: run test -0000010... FAIL (89 matches)
bisect: run test -0000010... FAIL (89 matches)
bisect: run: test -0000010... FAIL (89 matches)
bisect: run: test -0000010... FAIL (89 matches)
bisect: target still fails; searching for more bad changes
bisect: run test +0-0000010... FAIL (44 matches)
bisect: run test +0-0000010... FAIL (44 matches)
bisect: run test +00-0000010... ok (23 matches)
bisect: run test +00-0000010... ok (23 matches)
bisect: run test +10-0000010... FAIL (21 matches)
bisect: run test +10-0000010... FAIL (21 matches)
bisect: run test +010-0000010... ok (10 matches)
bisect: run test +010-0000010... ok (10 matches)
bisect: run test +110-0000010... FAIL (11 matches)
bisect: run test +110-0000010... FAIL (11 matches)
bisect: run test +0110-0000010... FAIL (6 matches)
bisect: run test +0110-0000010... FAIL (6 matches)
bisect: run test +00110-0000010... FAIL (3 matches)
bisect: run test +00110-0000010... FAIL (3 matches)
bisect: run test +000110-0000010... FAIL (2 matches)
bisect: run test +000110-0000010... FAIL (2 matches)
bisect: run test +0000110-0000010... FAIL (1 matches)
bisect: run test +0000110-0000010... FAIL (1 matches)
bisect: run: test +0-0000010... FAIL (44 matches)
bisect: run: test +0-0000010... FAIL (44 matches)
bisect: run: test +00-0000010... ok (23 matches)
bisect: run: test +00-0000010... ok (23 matches)
bisect: run: test +10-0000010... FAIL (21 matches)
bisect: run: test +10-0000010... FAIL (21 matches)
bisect: run: test +010-0000010... ok (10 matches)
bisect: run: test +010-0000010... ok (10 matches)
bisect: run: test +110-0000010... FAIL (11 matches)
bisect: run: test +110-0000010... FAIL (11 matches)
bisect: run: test +0110-0000010... FAIL (6 matches)
bisect: run: test +0110-0000010... FAIL (6 matches)
bisect: run: test +00110-0000010... FAIL (3 matches)
bisect: run: test +00110-0000010... FAIL (3 matches)
bisect: run: test +000110-0000010... FAIL (2 matches)
bisect: run: test +000110-0000010... FAIL (2 matches)
bisect: run: test +0000110-0000010... FAIL (1 matches)
bisect: run: test +0000110-0000010... FAIL (1 matches)
bisect: confirming failing change set
bisect: run test v+0000110-0000010... FAIL (1 matches)
bisect: run test v+0000110-0000010... FAIL (1 matches)
bisect: run: test v+0000110-0000010... FAIL (1 matches)
bisect: run: test v+0000110-0000010... FAIL (1 matches)
bisect: FOUND failing change set
bisect: checking for more failures
bisect: run test -0000110-0000010... ok (88 matches)
bisect: run test -0000110-0000010... ok (88 matches)
bisect: run: test -0000110-0000010... ok (88 matches)
bisect: run: test -0000110-0000010... ok (88 matches)
bisect: target succeeds with all remaining changes enabled
72 changes: 36 additions & 36 deletions cmd/bisect/testdata/double.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,49 +9,49 @@ peach
---
-- stderr --
bisect: checking target with all changes disabled
bisect: run test n... ok (90 matches)
bisect: run: test n... ok (90 matches)
bisect: checking target with all changes enabled
bisect: run test y... FAIL (90 matches)
bisect: run: test y... FAIL (90 matches)
bisect: target succeeds with no changes, fails with all changes
bisect: searching for minimal set of changes to enable to cause failure
bisect: run test +0... FAIL (45 matches)
bisect: run test +00... ok (23 matches)
bisect: run test +10... FAIL (22 matches)
bisect: run test +010... FAIL (11 matches)
bisect: run test +0010... FAIL (6 matches)
bisect: run test +00010... FAIL (3 matches)
bisect: run test +000010... FAIL (2 matches)
bisect: run test +0000010... FAIL (1 matches)
bisect: searching for minimal set of enabled changes causing failure
bisect: run: test +0... FAIL (45 matches)
bisect: run: test +00... ok (23 matches)
bisect: run: test +10... FAIL (22 matches)
bisect: run: test +010... FAIL (11 matches)
bisect: run: test +0010... FAIL (6 matches)
bisect: run: test +00010... FAIL (3 matches)
bisect: run: test +000010... FAIL (2 matches)
bisect: run: test +0000010... FAIL (1 matches)
bisect: confirming failing change set
bisect: run test v+0000010... FAIL (1 matches)
bisect: run: test v+0000010... FAIL (1 matches)
bisect: FOUND failing change set
bisect: checking for more failures
bisect: run test -0000010... FAIL (89 matches)
bisect: run: test -0000010... FAIL (89 matches)
bisect: target still fails; searching for more bad changes
bisect: run test +0-0000010... ok (44 matches)
bisect: run test +1-0000010... ok (45 matches)
bisect: run test +0+1-0000010... FAIL (44 matches)
bisect: run test +00+1-0000010... ok (23 matches)
bisect: run test +10+1-0000010... FAIL (21 matches)
bisect: run test +010+1-0000010... ok (10 matches)
bisect: run test +110+1-0000010... FAIL (11 matches)
bisect: run test +0110+1-0000010... FAIL (6 matches)
bisect: run test +00110+1-0000010... FAIL (3 matches)
bisect: run test +000110+1-0000010... FAIL (2 matches)
bisect: run test +0000110+1-0000010... FAIL (1 matches)
bisect: run test +1+0000110-0000010... FAIL (45 matches)
bisect: run test +01+0000110-0000010... ok (23 matches)
bisect: run test +11+0000110-0000010... FAIL (22 matches)
bisect: run test +011+0000110-0000010... FAIL (11 matches)
bisect: run test +0011+0000110-0000010... ok (6 matches)
bisect: run test +1011+0000110-0000010... FAIL (5 matches)
bisect: run test +01011+0000110-0000010... ok (3 matches)
bisect: run test +11011+0000110-0000010... FAIL (2 matches)
bisect: run test +011011+0000110-0000010... ok (1 matches)
bisect: run test +111011+0000110-0000010... FAIL (1 matches)
bisect: run: test +0-0000010... ok (44 matches)
bisect: run: test +1-0000010... ok (45 matches)
bisect: run: test +0+1-0000010... FAIL (44 matches)
bisect: run: test +00+1-0000010... ok (23 matches)
bisect: run: test +10+1-0000010... FAIL (21 matches)
bisect: run: test +010+1-0000010... ok (10 matches)
bisect: run: test +110+1-0000010... FAIL (11 matches)
bisect: run: test +0110+1-0000010... FAIL (6 matches)
bisect: run: test +00110+1-0000010... FAIL (3 matches)
bisect: run: test +000110+1-0000010... FAIL (2 matches)
bisect: run: test +0000110+1-0000010... FAIL (1 matches)
bisect: run: test +1+0000110-0000010... FAIL (45 matches)
bisect: run: test +01+0000110-0000010... ok (23 matches)
bisect: run: test +11+0000110-0000010... FAIL (22 matches)
bisect: run: test +011+0000110-0000010... FAIL (11 matches)
bisect: run: test +0011+0000110-0000010... ok (6 matches)
bisect: run: test +1011+0000110-0000010... FAIL (5 matches)
bisect: run: test +01011+0000110-0000010... ok (3 matches)
bisect: run: test +11011+0000110-0000010... FAIL (2 matches)
bisect: run: test +011011+0000110-0000010... ok (1 matches)
bisect: run: test +111011+0000110-0000010... FAIL (1 matches)
bisect: confirming failing change set
bisect: run test v+0000110+111011-0000010... FAIL (2 matches)
bisect: run: test v+0000110+111011-0000010... FAIL (2 matches)
bisect: FOUND failing change set
bisect: checking for more failures
bisect: run test -0000110-111011-0000010... ok (87 matches)
bisect: run: test -0000110-111011-0000010... ok (87 matches)
bisect: target succeeds with all remaining changes enabled
24 changes: 12 additions & 12 deletions cmd/bisect/testdata/max1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ amber
---
-- stderr --
bisect: checking target with all changes disabled
bisect: run test n... ok (90 matches)
bisect: run: test n... ok (90 matches)
bisect: checking target with all changes enabled
bisect: run test y... FAIL (90 matches)
bisect: run: test y... FAIL (90 matches)
bisect: target succeeds with no changes, fails with all changes
bisect: searching for minimal set of changes to enable to cause failure
bisect: run test +0... FAIL (45 matches)
bisect: run test +00... ok (23 matches)
bisect: run test +10... FAIL (22 matches)
bisect: run test +010... FAIL (11 matches)
bisect: run test +0010... FAIL (6 matches)
bisect: run test +00010... FAIL (3 matches)
bisect: run test +000010... FAIL (2 matches)
bisect: run test +0000010... FAIL (1 matches)
bisect: searching for minimal set of enabled changes causing failure
bisect: run: test +0... FAIL (45 matches)
bisect: run: test +00... ok (23 matches)
bisect: run: test +10... FAIL (22 matches)
bisect: run: test +010... FAIL (11 matches)
bisect: run: test +0010... FAIL (6 matches)
bisect: run: test +00010... FAIL (3 matches)
bisect: run: test +000010... FAIL (2 matches)
bisect: run: test +0000010... FAIL (1 matches)
bisect: confirming failing change set
bisect: run test v+0000010... FAIL (1 matches)
bisect: run: test v+0000010... FAIL (1 matches)
bisect: FOUND failing change set
Loading

0 comments on commit 23e52a3

Please sign in to comment.