Skip to content

Commit 23e52a3

Browse files
rscgopherbot
authored andcommitted
bisect: diagnose bad targets better
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 <[email protected]> Auto-Submit: Russ Cox <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Run-TryBot: Russ Cox <[email protected]>
1 parent d5af889 commit 23e52a3

13 files changed

+430
-426
lines changed

cmd/bisect/main.go

+7-3
Original file line numberDiff line numberDiff line change
@@ -240,13 +240,13 @@ func (b *Bisect) Search() bool {
240240
switch {
241241
case runN.Success && !runY.Success:
242242
b.Logf("target succeeds with no changes, fails with all changes")
243-
b.Logf("searching for minimal set of changes to enable to cause failure")
243+
b.Logf("searching for minimal set of enabled changes causing failure")
244244
broken = runY
245245
b.Disable = false
246246

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

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

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

570+
if err != nil && len(r.MatchIDs) == 0 {
571+
b.Fatalf("target failed without printing any matches\n%s", r.Out)
572+
}
573+
570574
// In verbose mode, print extra debugging: all the lines with match markers.
571575
if b.Verbose {
572576
b.Logf("matches:\n%s", strings.Join(r.MatchFull, "\n\t"))

cmd/bisect/testdata/basic.txt

+24-24
Original file line numberDiff line numberDiff line change
@@ -8,37 +8,37 @@ apricot
88
---
99
-- stderr --
1010
bisect: checking target with all changes disabled
11-
bisect: run test n... ok (90 matches)
11+
bisect: run: test n... ok (90 matches)
1212
bisect: checking target with all changes enabled
13-
bisect: run test y... FAIL (90 matches)
13+
bisect: run: test y... FAIL (90 matches)
1414
bisect: target succeeds with no changes, fails with all changes
15-
bisect: searching for minimal set of changes to enable to cause failure
16-
bisect: run test +0... FAIL (45 matches)
17-
bisect: run test +00... ok (23 matches)
18-
bisect: run test +10... FAIL (22 matches)
19-
bisect: run test +010... FAIL (11 matches)
20-
bisect: run test +0010... FAIL (6 matches)
21-
bisect: run test +00010... FAIL (3 matches)
22-
bisect: run test +000010... FAIL (2 matches)
23-
bisect: run test +0000010... FAIL (1 matches)
15+
bisect: searching for minimal set of enabled changes causing failure
16+
bisect: run: test +0... FAIL (45 matches)
17+
bisect: run: test +00... ok (23 matches)
18+
bisect: run: test +10... FAIL (22 matches)
19+
bisect: run: test +010... FAIL (11 matches)
20+
bisect: run: test +0010... FAIL (6 matches)
21+
bisect: run: test +00010... FAIL (3 matches)
22+
bisect: run: test +000010... FAIL (2 matches)
23+
bisect: run: test +0000010... FAIL (1 matches)
2424
bisect: confirming failing change set
25-
bisect: run test v+0000010... FAIL (1 matches)
25+
bisect: run: test v+0000010... FAIL (1 matches)
2626
bisect: FOUND failing change set
2727
bisect: checking for more failures
28-
bisect: run test -0000010... FAIL (89 matches)
28+
bisect: run: test -0000010... FAIL (89 matches)
2929
bisect: target still fails; searching for more bad changes
30-
bisect: run test +0-0000010... FAIL (44 matches)
31-
bisect: run test +00-0000010... ok (23 matches)
32-
bisect: run test +10-0000010... FAIL (21 matches)
33-
bisect: run test +010-0000010... ok (10 matches)
34-
bisect: run test +110-0000010... FAIL (11 matches)
35-
bisect: run test +0110-0000010... FAIL (6 matches)
36-
bisect: run test +00110-0000010... FAIL (3 matches)
37-
bisect: run test +000110-0000010... FAIL (2 matches)
38-
bisect: run test +0000110-0000010... FAIL (1 matches)
30+
bisect: run: test +0-0000010... FAIL (44 matches)
31+
bisect: run: test +00-0000010... ok (23 matches)
32+
bisect: run: test +10-0000010... FAIL (21 matches)
33+
bisect: run: test +010-0000010... ok (10 matches)
34+
bisect: run: test +110-0000010... FAIL (11 matches)
35+
bisect: run: test +0110-0000010... FAIL (6 matches)
36+
bisect: run: test +00110-0000010... FAIL (3 matches)
37+
bisect: run: test +000110-0000010... FAIL (2 matches)
38+
bisect: run: test +0000110-0000010... FAIL (1 matches)
3939
bisect: confirming failing change set
40-
bisect: run test v+0000110-0000010... FAIL (1 matches)
40+
bisect: run: test v+0000110-0000010... FAIL (1 matches)
4141
bisect: FOUND failing change set
4242
bisect: checking for more failures
43-
bisect: run test -0000110-0000010... ok (88 matches)
43+
bisect: run: test -0000110-0000010... ok (88 matches)
4444
bisect: target succeeds with all remaining changes enabled

cmd/bisect/testdata/count2.txt

+47-47
Original file line numberDiff line numberDiff line change
@@ -8,60 +8,60 @@ apricot
88
---
99
-- stderr --
1010
bisect: checking target with all changes disabled
11-
bisect: run test n... ok (90 matches)
12-
bisect: run test n... ok (90 matches)
11+
bisect: run: test n... ok (90 matches)
12+
bisect: run: test n... ok (90 matches)
1313
bisect: checking target with all changes enabled
14-
bisect: run test y... FAIL (90 matches)
15-
bisect: run test y... FAIL (90 matches)
14+
bisect: run: test y... FAIL (90 matches)
15+
bisect: run: test y... FAIL (90 matches)
1616
bisect: target succeeds with no changes, fails with all changes
17-
bisect: searching for minimal set of changes to enable to cause failure
18-
bisect: run test +0... FAIL (45 matches)
19-
bisect: run test +0... FAIL (45 matches)
20-
bisect: run test +00... ok (23 matches)
21-
bisect: run test +00... ok (23 matches)
22-
bisect: run test +10... FAIL (22 matches)
23-
bisect: run test +10... FAIL (22 matches)
24-
bisect: run test +010... FAIL (11 matches)
25-
bisect: run test +010... FAIL (11 matches)
26-
bisect: run test +0010... FAIL (6 matches)
27-
bisect: run test +0010... FAIL (6 matches)
28-
bisect: run test +00010... FAIL (3 matches)
29-
bisect: run test +00010... FAIL (3 matches)
30-
bisect: run test +000010... FAIL (2 matches)
31-
bisect: run test +000010... FAIL (2 matches)
32-
bisect: run test +0000010... FAIL (1 matches)
33-
bisect: run test +0000010... FAIL (1 matches)
17+
bisect: searching for minimal set of enabled changes causing failure
18+
bisect: run: test +0... FAIL (45 matches)
19+
bisect: run: test +0... FAIL (45 matches)
20+
bisect: run: test +00... ok (23 matches)
21+
bisect: run: test +00... ok (23 matches)
22+
bisect: run: test +10... FAIL (22 matches)
23+
bisect: run: test +10... FAIL (22 matches)
24+
bisect: run: test +010... FAIL (11 matches)
25+
bisect: run: test +010... FAIL (11 matches)
26+
bisect: run: test +0010... FAIL (6 matches)
27+
bisect: run: test +0010... FAIL (6 matches)
28+
bisect: run: test +00010... FAIL (3 matches)
29+
bisect: run: test +00010... FAIL (3 matches)
30+
bisect: run: test +000010... FAIL (2 matches)
31+
bisect: run: test +000010... FAIL (2 matches)
32+
bisect: run: test +0000010... FAIL (1 matches)
33+
bisect: run: test +0000010... FAIL (1 matches)
3434
bisect: confirming failing change set
35-
bisect: run test v+0000010... FAIL (1 matches)
36-
bisect: run test v+0000010... FAIL (1 matches)
35+
bisect: run: test v+0000010... FAIL (1 matches)
36+
bisect: run: test v+0000010... FAIL (1 matches)
3737
bisect: FOUND failing change set
3838
bisect: checking for more failures
39-
bisect: run test -0000010... FAIL (89 matches)
40-
bisect: run test -0000010... FAIL (89 matches)
39+
bisect: run: test -0000010... FAIL (89 matches)
40+
bisect: run: test -0000010... FAIL (89 matches)
4141
bisect: target still fails; searching for more bad changes
42-
bisect: run test +0-0000010... FAIL (44 matches)
43-
bisect: run test +0-0000010... FAIL (44 matches)
44-
bisect: run test +00-0000010... ok (23 matches)
45-
bisect: run test +00-0000010... ok (23 matches)
46-
bisect: run test +10-0000010... FAIL (21 matches)
47-
bisect: run test +10-0000010... FAIL (21 matches)
48-
bisect: run test +010-0000010... ok (10 matches)
49-
bisect: run test +010-0000010... ok (10 matches)
50-
bisect: run test +110-0000010... FAIL (11 matches)
51-
bisect: run test +110-0000010... FAIL (11 matches)
52-
bisect: run test +0110-0000010... FAIL (6 matches)
53-
bisect: run test +0110-0000010... FAIL (6 matches)
54-
bisect: run test +00110-0000010... FAIL (3 matches)
55-
bisect: run test +00110-0000010... FAIL (3 matches)
56-
bisect: run test +000110-0000010... FAIL (2 matches)
57-
bisect: run test +000110-0000010... FAIL (2 matches)
58-
bisect: run test +0000110-0000010... FAIL (1 matches)
59-
bisect: run test +0000110-0000010... FAIL (1 matches)
42+
bisect: run: test +0-0000010... FAIL (44 matches)
43+
bisect: run: test +0-0000010... FAIL (44 matches)
44+
bisect: run: test +00-0000010... ok (23 matches)
45+
bisect: run: test +00-0000010... ok (23 matches)
46+
bisect: run: test +10-0000010... FAIL (21 matches)
47+
bisect: run: test +10-0000010... FAIL (21 matches)
48+
bisect: run: test +010-0000010... ok (10 matches)
49+
bisect: run: test +010-0000010... ok (10 matches)
50+
bisect: run: test +110-0000010... FAIL (11 matches)
51+
bisect: run: test +110-0000010... FAIL (11 matches)
52+
bisect: run: test +0110-0000010... FAIL (6 matches)
53+
bisect: run: test +0110-0000010... FAIL (6 matches)
54+
bisect: run: test +00110-0000010... FAIL (3 matches)
55+
bisect: run: test +00110-0000010... FAIL (3 matches)
56+
bisect: run: test +000110-0000010... FAIL (2 matches)
57+
bisect: run: test +000110-0000010... FAIL (2 matches)
58+
bisect: run: test +0000110-0000010... FAIL (1 matches)
59+
bisect: run: test +0000110-0000010... FAIL (1 matches)
6060
bisect: confirming failing change set
61-
bisect: run test v+0000110-0000010... FAIL (1 matches)
62-
bisect: run test v+0000110-0000010... FAIL (1 matches)
61+
bisect: run: test v+0000110-0000010... FAIL (1 matches)
62+
bisect: run: test v+0000110-0000010... FAIL (1 matches)
6363
bisect: FOUND failing change set
6464
bisect: checking for more failures
65-
bisect: run test -0000110-0000010... ok (88 matches)
66-
bisect: run test -0000110-0000010... ok (88 matches)
65+
bisect: run: test -0000110-0000010... ok (88 matches)
66+
bisect: run: test -0000110-0000010... ok (88 matches)
6767
bisect: target succeeds with all remaining changes enabled

cmd/bisect/testdata/double.txt

+36-36
Original file line numberDiff line numberDiff line change
@@ -9,49 +9,49 @@ peach
99
---
1010
-- stderr --
1111
bisect: checking target with all changes disabled
12-
bisect: run test n... ok (90 matches)
12+
bisect: run: test n... ok (90 matches)
1313
bisect: checking target with all changes enabled
14-
bisect: run test y... FAIL (90 matches)
14+
bisect: run: test y... FAIL (90 matches)
1515
bisect: target succeeds with no changes, fails with all changes
16-
bisect: searching for minimal set of changes to enable to cause failure
17-
bisect: run test +0... FAIL (45 matches)
18-
bisect: run test +00... ok (23 matches)
19-
bisect: run test +10... FAIL (22 matches)
20-
bisect: run test +010... FAIL (11 matches)
21-
bisect: run test +0010... FAIL (6 matches)
22-
bisect: run test +00010... FAIL (3 matches)
23-
bisect: run test +000010... FAIL (2 matches)
24-
bisect: run test +0000010... FAIL (1 matches)
16+
bisect: searching for minimal set of enabled changes causing failure
17+
bisect: run: test +0... FAIL (45 matches)
18+
bisect: run: test +00... ok (23 matches)
19+
bisect: run: test +10... FAIL (22 matches)
20+
bisect: run: test +010... FAIL (11 matches)
21+
bisect: run: test +0010... FAIL (6 matches)
22+
bisect: run: test +00010... FAIL (3 matches)
23+
bisect: run: test +000010... FAIL (2 matches)
24+
bisect: run: test +0000010... FAIL (1 matches)
2525
bisect: confirming failing change set
26-
bisect: run test v+0000010... FAIL (1 matches)
26+
bisect: run: test v+0000010... FAIL (1 matches)
2727
bisect: FOUND failing change set
2828
bisect: checking for more failures
29-
bisect: run test -0000010... FAIL (89 matches)
29+
bisect: run: test -0000010... FAIL (89 matches)
3030
bisect: target still fails; searching for more bad changes
31-
bisect: run test +0-0000010... ok (44 matches)
32-
bisect: run test +1-0000010... ok (45 matches)
33-
bisect: run test +0+1-0000010... FAIL (44 matches)
34-
bisect: run test +00+1-0000010... ok (23 matches)
35-
bisect: run test +10+1-0000010... FAIL (21 matches)
36-
bisect: run test +010+1-0000010... ok (10 matches)
37-
bisect: run test +110+1-0000010... FAIL (11 matches)
38-
bisect: run test +0110+1-0000010... FAIL (6 matches)
39-
bisect: run test +00110+1-0000010... FAIL (3 matches)
40-
bisect: run test +000110+1-0000010... FAIL (2 matches)
41-
bisect: run test +0000110+1-0000010... FAIL (1 matches)
42-
bisect: run test +1+0000110-0000010... FAIL (45 matches)
43-
bisect: run test +01+0000110-0000010... ok (23 matches)
44-
bisect: run test +11+0000110-0000010... FAIL (22 matches)
45-
bisect: run test +011+0000110-0000010... FAIL (11 matches)
46-
bisect: run test +0011+0000110-0000010... ok (6 matches)
47-
bisect: run test +1011+0000110-0000010... FAIL (5 matches)
48-
bisect: run test +01011+0000110-0000010... ok (3 matches)
49-
bisect: run test +11011+0000110-0000010... FAIL (2 matches)
50-
bisect: run test +011011+0000110-0000010... ok (1 matches)
51-
bisect: run test +111011+0000110-0000010... FAIL (1 matches)
31+
bisect: run: test +0-0000010... ok (44 matches)
32+
bisect: run: test +1-0000010... ok (45 matches)
33+
bisect: run: test +0+1-0000010... FAIL (44 matches)
34+
bisect: run: test +00+1-0000010... ok (23 matches)
35+
bisect: run: test +10+1-0000010... FAIL (21 matches)
36+
bisect: run: test +010+1-0000010... ok (10 matches)
37+
bisect: run: test +110+1-0000010... FAIL (11 matches)
38+
bisect: run: test +0110+1-0000010... FAIL (6 matches)
39+
bisect: run: test +00110+1-0000010... FAIL (3 matches)
40+
bisect: run: test +000110+1-0000010... FAIL (2 matches)
41+
bisect: run: test +0000110+1-0000010... FAIL (1 matches)
42+
bisect: run: test +1+0000110-0000010... FAIL (45 matches)
43+
bisect: run: test +01+0000110-0000010... ok (23 matches)
44+
bisect: run: test +11+0000110-0000010... FAIL (22 matches)
45+
bisect: run: test +011+0000110-0000010... FAIL (11 matches)
46+
bisect: run: test +0011+0000110-0000010... ok (6 matches)
47+
bisect: run: test +1011+0000110-0000010... FAIL (5 matches)
48+
bisect: run: test +01011+0000110-0000010... ok (3 matches)
49+
bisect: run: test +11011+0000110-0000010... FAIL (2 matches)
50+
bisect: run: test +011011+0000110-0000010... ok (1 matches)
51+
bisect: run: test +111011+0000110-0000010... FAIL (1 matches)
5252
bisect: confirming failing change set
53-
bisect: run test v+0000110+111011-0000010... FAIL (2 matches)
53+
bisect: run: test v+0000110+111011-0000010... FAIL (2 matches)
5454
bisect: FOUND failing change set
5555
bisect: checking for more failures
56-
bisect: run test -0000110-111011-0000010... ok (87 matches)
56+
bisect: run: test -0000110-111011-0000010... ok (87 matches)
5757
bisect: target succeeds with all remaining changes enabled

cmd/bisect/testdata/max1.txt

+12-12
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@ amber
55
---
66
-- stderr --
77
bisect: checking target with all changes disabled
8-
bisect: run test n... ok (90 matches)
8+
bisect: run: test n... ok (90 matches)
99
bisect: checking target with all changes enabled
10-
bisect: run test y... FAIL (90 matches)
10+
bisect: run: test y... FAIL (90 matches)
1111
bisect: target succeeds with no changes, fails with all changes
12-
bisect: searching for minimal set of changes to enable to cause failure
13-
bisect: run test +0... FAIL (45 matches)
14-
bisect: run test +00... ok (23 matches)
15-
bisect: run test +10... FAIL (22 matches)
16-
bisect: run test +010... FAIL (11 matches)
17-
bisect: run test +0010... FAIL (6 matches)
18-
bisect: run test +00010... FAIL (3 matches)
19-
bisect: run test +000010... FAIL (2 matches)
20-
bisect: run test +0000010... FAIL (1 matches)
12+
bisect: searching for minimal set of enabled changes causing failure
13+
bisect: run: test +0... FAIL (45 matches)
14+
bisect: run: test +00... ok (23 matches)
15+
bisect: run: test +10... FAIL (22 matches)
16+
bisect: run: test +010... FAIL (11 matches)
17+
bisect: run: test +0010... FAIL (6 matches)
18+
bisect: run: test +00010... FAIL (3 matches)
19+
bisect: run: test +000010... FAIL (2 matches)
20+
bisect: run: test +0000010... FAIL (1 matches)
2121
bisect: confirming failing change set
22-
bisect: run test v+0000010... FAIL (1 matches)
22+
bisect: run: test v+0000010... FAIL (1 matches)
2323
bisect: FOUND failing change set

0 commit comments

Comments
 (0)