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

samsarahq / taskrunner / 14199495843

01 Apr 2025 03:19PM UTC coverage: 51.372% (-0.1%) from 51.517%
14199495843

Pull #72

github

samloop
runner: improve error logging

This clarifies some error messages, and provides the stack trace when taskrunner fails on execution.
Pull Request #72: runner: improve error logging

1 of 8 new or added lines in 3 files covered. (12.5%)

3 existing lines in 1 file now uncovered.

730 of 1421 relevant lines covered (51.37%)

4.67 hits per line

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

44.83
/shell/shell.go
1
package shell
2

3
import (
4
        "context"
5
        "fmt"
6
        "io"
7
        "strings"
8

9
        "github.com/samsarahq/go/oops"
10
        "mvdan.cc/sh/interp"
11
        "mvdan.cc/sh/syntax"
12
)
13

14
type RunOption func(*interp.Runner)
15

16
type ShellRun func(ctx context.Context, command string, options ...RunOption) error
17

18
// Stdout sets the output location for the stdout of a command.
19
func Stdout(writer io.Writer) RunOption {
1✔
20
        return func(r *interp.Runner) {
2✔
21
                r.Stdout = writer
1✔
22
        }
1✔
23
}
24

25
// Stderr sets the output location for the stderr of a command.
26
func Stderr(writer io.Writer) RunOption {
×
27
        return func(r *interp.Runner) {
×
28
                r.Stderr = writer
×
29
        }
×
30
}
31

32
// Stdin pipes in the contents provided by the reader to the command.
33
func Stdin(reader io.Reader) RunOption {
×
34
        return func(r *interp.Runner) {
×
35
                r.Stdin = reader
×
36
        }
×
37
}
38

39
// Env sets the environment variables for the command.
40
func Env(vars map[string]string) RunOption {
×
41
        return func(r *interp.Runner) {
×
42
                for k, v := range vars {
×
43
                        r.Env.Set(k, v)
×
44
                }
×
45
        }
46
}
47

48
// Run executes a shell command.
49
func Run(ctx context.Context, command string, opts ...RunOption) error {
2✔
50
        p, err := syntax.NewParser().Parse(strings.NewReader(command), "")
2✔
51
        if err != nil {
2✔
NEW
52
                return oops.Wrapf(err, "failed to parse shell command")
×
53
        }
×
54

55
        r, err := interp.New()
2✔
56
        if err != nil {
2✔
57
                panic(fmt.Errorf("failed to set up interpreter: %s", err.Error()))
×
58
        }
59

60
        for _, opt := range opts {
3✔
61
                opt(r)
1✔
62
        }
1✔
63

64
        return r.Run(ctx, p)
2✔
65
}
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