Skip to content

Commit ce68c9c

Browse files
committed
review: lock and clone errors name their real cause; log doc drops the bash file
1 parent 1b40989 commit ce68c9c

3 files changed

Lines changed: 9 additions & 2 deletions

File tree

runner/internal/run/lock.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package run
22

33
import (
4+
"errors"
45
"fmt"
56
"os"
67
"path/filepath"
@@ -28,7 +29,10 @@ func AcquireLock(benchRoot string) (release func(), err error) {
2829
}
2930
if err := syscall.Flock(int(f.Fd()), syscall.LOCK_EX|syscall.LOCK_NB); err != nil {
3031
f.Close()
31-
return nil, fmt.Errorf("another campaign is already running on this BENCH_ROOT (held lock: %s)", path)
32+
if errors.Is(err, syscall.EWOULDBLOCK) {
33+
return nil, fmt.Errorf("another campaign is already running on this BENCH_ROOT (held lock: %s)", path)
34+
}
35+
return nil, fmt.Errorf("lock %s: %w", path, err)
3236
}
3337
// The lock lives on the open file description, so the fd stays open until
3438
// release; closing it anywhere earlier would drop the lock silently.

runner/internal/run/log.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const campaignLogName = "campaign.log"
1313

1414
// Notef prints a bash-style note — `== [HH:MM:SS] msg`, the clock in UTC —
1515
// the line format every operator reading a campaign log already knows from
16-
// campaign.sh's note().
16+
// the note() of the bash campaign runner this package replaces.
1717
func Notef(w io.Writer, format string, args ...any) {
1818
fmt.Fprintf(w, "== [%s] %s\n", time.Now().UTC().Format("15:04:05"), fmt.Sprintf(format, args...))
1919
}

runner/internal/run/source.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ import (
1717
// modified.
1818
func EnsureSrc(src, repo string, out io.Writer) error {
1919
if _, err := os.Stat(filepath.Join(src, ".git")); err != nil {
20+
if !os.IsNotExist(err) {
21+
return fmt.Errorf("inspect build clone at %s: %w", src, err)
22+
}
2023
if err := runCommand([]string{"git", "clone", repo, src}, nil, out); err != nil {
2124
return fmt.Errorf("clone %s into %s: %w", repo, src, err)
2225
}

0 commit comments

Comments
 (0)