Skip to content

Commit 646d3f9

Browse files
tbgroachdev-claude
andcommitted
Rebuild when cached bin directory is empty
If a previous benchdiff run was interrupted, the bin directory could be left behind empty. On subsequent runs, build() would see the directory, read zero test files, and return early — causing benchdiff to silently do nothing. Fix by detecting the empty bin directory and removing it so the build proceeds. Co-Authored-By: roachdev-claude <roachdev-claude-bot@cockroachlabs.com>
1 parent b4c438f commit 646d3f9

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

main.go

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,9 @@ func parseGitRefs(oldRef, newRef string) (string, string, error) {
317317
return oldRef, newRef, nil
318318
}
319319

320-
func buildBenches(ctx context.Context, pkgFilter []string, postChck string, bss ...*benchSuite) error {
320+
func buildBenches(
321+
ctx context.Context, pkgFilter []string, postChck string, bss ...*benchSuite,
322+
) error {
321323
// Get the current branch so we can revert to it after, if possible.
322324
if ref, ok, err := getCurSymbolicRef(); err != nil {
323325
return err
@@ -596,9 +598,7 @@ func processBenchOutput(
596598
return tables, nil
597599
}
598600

599-
func logProfileLocations(
600-
bs1, bs2 *benchSuite, cpuProfile, memProfile, mutexProfile bool,
601-
) {
601+
func logProfileLocations(bs1, bs2 *benchSuite, cpuProfile, memProfile, mutexProfile bool) {
602602
if !cpuProfile && !memProfile && !mutexProfile {
603603
return
604604
}
@@ -712,7 +712,14 @@ func (bs *benchSuite) build(pkgFilter []string, postChck string, t time.Time) (e
712712
}
713713
bs.testFiles[f.Name()] = struct{}{}
714714
}
715-
return nil
715+
if len(bs.testFiles) > 0 {
716+
return nil
717+
}
718+
// The bin directory exists but contains no test binaries. This can
719+
// happen if a previous build was interrupted. Remove it and rebuild.
720+
if err := os.RemoveAll(bs.binDir); err != nil {
721+
return err
722+
}
716723
} else if !os.IsNotExist(err) {
717724
return errors.Wrap(err, "looking for test directory")
718725
}

0 commit comments

Comments
 (0)