• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

trento-project / agent / 12794486954

15 Jan 2025 06:15PM UTC coverage: 71.827% (-0.08%) from 71.911%
12794486954

push

github

web-flow
Handle context cancellation in `corosync-cmapctl` gatherer (#376)

26 of 44 new or added lines in 3 files covered. (59.09%)

1 existing line in 1 file now uncovered.

4074 of 5672 relevant lines covered (71.83%)

20.54 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/pkg/utils/commandexecutor.go
1
package utils
2

3
import (
4
        "context"
5
        "fmt"
6
        "os/exec"
7
        "syscall"
8
)
9

10
//go:generate mockery --name=CommandExecutor
11

12
type CommandExecutor interface {
13
        Exec(name string, arg ...string) ([]byte, error)
14
        ExecContext(ctx context.Context, name string, arg ...string) ([]byte, error)
15
}
16

17
type Executor struct{}
18

19
func (e Executor) Exec(name string, arg ...string) ([]byte, error) {
×
20
        cmd := exec.Command(name, arg...)
×
NEW
21

×
NEW
22
        return cmd.Output()
×
NEW
23
}
×
24

NEW
25
func (e Executor) ExecContext(ctx context.Context, name string, arg ...string) ([]byte, error) {
×
NEW
26
        cmd := exec.CommandContext(ctx, name, arg...)
×
NEW
27
        cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
×
NEW
28
        cmd.Cancel = func() error {
×
NEW
29
                <-ctx.Done()
×
NEW
30
                err := syscall.Kill(-cmd.Process.Pid, syscall.SIGKILL)
×
NEW
31
                return fmt.Errorf("error killing process group: %w", err)
×
NEW
32
        }
×
33
        return cmd.Output()
×
34
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc