| OLD | NEW |
| 1 // Copyright 2015 The LUCI Authors. All rights reserved. | 1 // Copyright 2015 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 executor | 5 package executor |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "errors" | 8 "errors" |
| 9 "fmt" | 9 "fmt" |
| 10 "io" | 10 "io" |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 stdout, | 126 stdout, |
| 127 stderr, | 127 stderr, |
| 128 } | 128 } |
| 129 | 129 |
| 130 // Process the bootstrapped I/O. We explicitly defer a Finish here to en
sure | 130 // Process the bootstrapped I/O. We explicitly defer a Finish here to en
sure |
| 131 // that we clean up any internal streams if our Processor fails/panics. | 131 // that we clean up any internal streams if our Processor fails/panics. |
| 132 // | 132 // |
| 133 // If we fail to process the I/O, terminate the bootstrapped process | 133 // If we fail to process the I/O, terminate the bootstrapped process |
| 134 // immediately, since it may otherwise block forever on I/O. | 134 // immediately, since it may otherwise block forever on I/O. |
| 135 proc := annotee.New(ctx, options) | 135 proc := annotee.New(ctx, options) |
| 136 » defer proc.Finish() | 136 » defer proc.Finish(options.CloseSteps) |
| 137 | 137 |
| 138 if err := proc.RunStreams(streams); err != nil { | 138 if err := proc.RunStreams(streams); err != nil { |
| 139 cancelFunc() | 139 cancelFunc() |
| 140 return fmt.Errorf("failed to process bootstrapped I/O: %v", err) | 140 return fmt.Errorf("failed to process bootstrapped I/O: %v", err) |
| 141 } | 141 } |
| 142 | 142 |
| 143 // Finish and record our annotation steps on completion. | 143 // Finish and record our annotation steps on completion. |
| 144 » proc.Finish().ForEachStep(func(s *annotation.Step) { | 144 » proc.Finish(options.CloseSteps).ForEachStep(func(s *annotation.Step) { |
| 145 e.steps = append(e.steps, s.Proto()) | 145 e.steps = append(e.steps, s.Proto()) |
| 146 }) | 146 }) |
| 147 return nil | 147 return nil |
| 148 } | 148 } |
| 149 | 149 |
| 150 // Steps returns a list of Steps from the latest run. | 150 // Steps returns a list of Steps from the latest run. |
| 151 func (e *Executor) Steps() []*milo.Step { | 151 func (e *Executor) Steps() []*milo.Step { |
| 152 return e.steps | 152 return e.steps |
| 153 } | 153 } |
| 154 | 154 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 173 Name: name, | 173 Name: name, |
| 174 Tee: tee, | 174 Tee: tee, |
| 175 Alias: "stdio", | 175 Alias: "stdio", |
| 176 StripAnnotations: (e.Annotate == StripAnnotations), | 176 StripAnnotations: (e.Annotate == StripAnnotations), |
| 177 } | 177 } |
| 178 if e.Annotate != NoAnnotations { | 178 if e.Annotate != NoAnnotations { |
| 179 s.Annotate = true | 179 s.Annotate = true |
| 180 } | 180 } |
| 181 return s | 181 return s |
| 182 } | 182 } |
| OLD | NEW |