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

trento-project / agent / 12876910536

20 Jan 2025 11:03PM UTC coverage: 71.655% (-0.2%) from 71.827%
12876910536

Pull #378

github

balanza
accept feedback
Pull Request #378: Test command termination error

2 of 4 new or added lines in 1 file covered. (50.0%)

22 existing lines in 1 file now uncovered.

4065 of 5673 relevant lines covered (71.66%)

20.21 hits per line

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

86.67
/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) {
2✔
20
        cmd := exec.Command(name, arg...)
2✔
21

2✔
22
        return cmd.Output()
2✔
23
}
2✔
24

25
func (e Executor) ExecContext(ctx context.Context, name string, arg ...string) ([]byte, error) {
4✔
26
        cmd := exec.CommandContext(ctx, name, arg...)
4✔
27
        cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
4✔
28
        cmd.Cancel = func() error {
5✔
29
                err := syscall.Kill(-cmd.Process.Pid, syscall.SIGKILL)
1✔
30
                if err != nil {
1✔
NEW
31
                        return fmt.Errorf("error killing process group: %w", err)
×
NEW
32
                }
×
33
                return nil
1✔
34
        }
35
        return cmd.Output()
4✔
36
}
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