-
Notifications
You must be signed in to change notification settings - Fork 51
/
test_cmd.go
40 lines (37 loc) · 1.1 KB
/
test_cmd.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package app
import (
"github.com/cashapp/hermit"
"github.com/cashapp/hermit/errors"
"github.com/cashapp/hermit/manifest"
"github.com/cashapp/hermit/ui"
)
type testCmd struct {
Pkg []manifest.GlobSelector `arg:"" required:"" help:"Run sanity tests for these packages."`
CheckSources bool `help:"Check that package sources are reachable" default:"true" negatable:""`
}
func (t *testCmd) Run(l *ui.UI, env *hermit.Env) error {
for _, selector := range t.Pkg {
options := &hermit.ValidationOptions{
CheckSources: t.CheckSources,
}
warnings, err := env.ValidateManifest(l, selector.Name(), options)
if err != nil {
return errors.WithStack(err)
}
for _, warning := range warnings {
l.Warnf("%s: %s", selector, warning)
}
pkg, err := env.Resolve(l, selector, false)
if errors.Is(err, manifest.ErrNoSource) {
l.Warnf("No sources found for package %s on this architecture. Skipping the test", selector)
continue
}
if err != nil {
return errors.WithStack(err)
}
if err = env.Test(l, pkg); err != nil {
return errors.WithStack(err)
}
}
return nil
}