| OLD | NEW |
| 1 // Copyright 2017 The LUCI Authors. All rights reserved. | 1 // Copyright 2017 The LUCI Authors. All rights reserved. |
| 2 // Use of this source code is governed under the Apache License, Version 2.0 | 2 // Use of this source code is governed under the Apache License, Version 2.0 |
| 3 // that can be found in the LICENSE file. | 3 // that can be found in the LICENSE file. |
| 4 | 4 |
| 5 package application | 5 package application |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "strings" | 8 "strings" |
| 9 | 9 |
| 10 "github.com/maruel/subcommands" | 10 "github.com/maruel/subcommands" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 } | 47 } |
| 48 if err := spec.NormalizeSpec(a.opts.EnvConfig.Spec); err != nil
{ | 48 if err := spec.NormalizeSpec(a.opts.EnvConfig.Spec); err != nil
{ |
| 49 return errors.Annotate(err).Reason("failed to normalize
specification").Err() | 49 return errors.Annotate(err).Reason("failed to normalize
specification").Err() |
| 50 } | 50 } |
| 51 s := a.opts.EnvConfig.Spec | 51 s := a.opts.EnvConfig.Spec |
| 52 renderedSpec := spec.Render(s) | 52 renderedSpec := spec.Render(s) |
| 53 logging.Infof(c, "Successfully verified specification:\n%s", ren
deredSpec) | 53 logging.Infof(c, "Successfully verified specification:\n%s", ren
deredSpec) |
| 54 | 54 |
| 55 // Run our Verification generator and verify each generated envi
ronment. | 55 // Run our Verification generator and verify each generated envi
ronment. |
| 56 if a.WithVerificationConfig != nil { | 56 if a.WithVerificationConfig != nil { |
| 57 » » » err := a.WithVerificationConfig(c, func(cfg Config, veri
ficationScenarios []*vpython.Pep425Tag) error { | 57 » » » err := a.WithVerificationConfig(c, func(cfg Config, veri
ficationScenarios []*vpython.PEP425Tag) error { |
| 58 if len(s.VerifyPep425Tag) > 0 { | 58 if len(s.VerifyPep425Tag) > 0 { |
| 59 verificationScenarios = s.VerifyPep425Ta
g | 59 verificationScenarios = s.VerifyPep425Ta
g |
| 60 } | 60 } |
| 61 if len(verificationScenarios) == 0 { | 61 if len(verificationScenarios) == 0 { |
| 62 return nil | 62 return nil |
| 63 } | 63 } |
| 64 | 64 |
| 65 var failures []string | 65 var failures []string |
| 66 for _, vs := range verificationScenarios { | 66 for _, vs := range verificationScenarios { |
| 67 // Create a verification environment to
pass to our package loader. | 67 // Create a verification environment to
pass to our package loader. |
| 68 e := vpython.Environment{ | 68 e := vpython.Environment{ |
| 69 Spec: s.Clone(), | 69 Spec: s.Clone(), |
| 70 » » » » » » Pep425Tag: []*vpython.Pep425Tag{
vs}, | 70 » » » » » » Pep425Tag: []*vpython.PEP425Tag{
vs}, |
| 71 } | 71 } |
| 72 | 72 |
| 73 if err := cfg.PackageLoader.Resolve(c, &
e); err != nil { | 73 if err := cfg.PackageLoader.Resolve(c, &
e); err != nil { |
| 74 logging.Errorf(c, "Failed to res
olve against %q: %s", vs.TagString(), err) | 74 logging.Errorf(c, "Failed to res
olve against %q: %s", vs.TagString(), err) |
| 75 failures = append(failures, vs.T
agString()) | 75 failures = append(failures, vs.T
agString()) |
| 76 } | 76 } |
| 77 } | 77 } |
| 78 | 78 |
| 79 if len(failures) > 0 { | 79 if len(failures) > 0 { |
| 80 logging.Errorf(c, "Verification failed f
or %d scenario(s): %s\n%s", | 80 logging.Errorf(c, "Verification failed f
or %d scenario(s): %s\n%s", |
| 81 len(failures), strings.Join(fail
ures, ", "), renderedSpec) | 81 len(failures), strings.Join(fail
ures, ", "), renderedSpec) |
| 82 return errors.New("verification failed") | 82 return errors.New("verification failed") |
| 83 } | 83 } |
| 84 | 84 |
| 85 logging.Infof(c, "Verified %d scenario(s).", len
(verificationScenarios)) | 85 logging.Infof(c, "Verified %d scenario(s).", len
(verificationScenarios)) |
| 86 return nil | 86 return nil |
| 87 }) | 87 }) |
| 88 if err != nil { | 88 if err != nil { |
| 89 return err | 89 return err |
| 90 } | 90 } |
| 91 } | 91 } |
| 92 | 92 |
| 93 return nil | 93 return nil |
| 94 }) | 94 }) |
| 95 } | 95 } |
| OLD | NEW |