-
Notifications
You must be signed in to change notification settings - Fork 51
/
test_cmd.go
45 lines (41 loc) · 1.15 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
41
42
43
44
45
package app
import (
"github.com/pkg/errors"
"github.com/cashapp/hermit"
"github.com/cashapp/hermit/manifest"
"github.com/cashapp/hermit/ui"
)
type testCmd struct {
Pkg []string `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 _, name := range t.Pkg {
selector, err := manifest.GlobSelector(name)
if err != nil {
return errors.WithStack(err)
}
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", name, 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", name)
continue
}
if err != nil {
return errors.WithStack(err)
}
if err = env.Test(l, pkg); err != nil {
return errors.WithStack(err)
}
}
return nil
}