OLD | NEW |
1 package frontend | 1 package frontend |
2 | 2 |
3 import ( | 3 import ( |
4 "bytes" | 4 "bytes" |
5 "encoding/json" | 5 "encoding/json" |
6 "fmt" | 6 "fmt" |
7 "infra/appengine/test-results/model" | 7 "infra/appengine/test-results/model" |
8 "io" | 8 "io" |
9 "net/http" | 9 "net/http" |
10 "regexp" | 10 "regexp" |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 } | 202 } |
203 | 203 |
204 if err := tf.GetData(c); err != nil { | 204 if err := tf.GetData(c); err != nil { |
205 http.Error(w, err.Error(), http.StatusInternalServerError) | 205 http.Error(w, err.Error(), http.StatusInternalServerError) |
206 return | 206 return |
207 } | 207 } |
208 | 208 |
209 finalData := tf.Data | 209 finalData := tf.Data |
210 | 210 |
211 if params.TestListJSON { | 211 if params.TestListJSON { |
| 212 data, err := model.CleanJSON(tf.Data) |
| 213 if err != nil { |
| 214 http.Error(w, err.Error(), http.StatusInternalServerErro
r) |
| 215 logging.Errorf(c, "failed to clean test results JSON: %v
", err) |
| 216 return |
| 217 } |
212 aggr := model.AggregateResult{Builder: params.Builder} | 218 aggr := model.AggregateResult{Builder: params.Builder} |
213 » » if err := json.NewDecoder(tf.Data).Decode(&aggr); err != nil { | 219 » » if err := json.NewDecoder(data).Decode(&aggr); err != nil { |
214 http.Error(w, err.Error(), http.StatusInternalServerErro
r) | 220 http.Error(w, err.Error(), http.StatusInternalServerErro
r) |
215 » » » logging.Errorf(c, "failed to unmarshal TestResults JSON:
%+v: %v", tf.Data, err) | 221 » » » logging.Errorf(c, "failed to unmarshal test results JSON
: %+v: %v", data, err) |
216 return | 222 return |
217 } | 223 } |
218 aggr.Tests.ToTestList() | 224 aggr.Tests.ToTestList() |
219 buf := &bytes.Buffer{} | 225 buf := &bytes.Buffer{} |
220 if err := json.NewEncoder(buf).Encode(aggr.Tests); err != nil { | 226 if err := json.NewEncoder(buf).Encode(aggr.Tests); err != nil { |
221 http.Error(w, err.Error(), http.StatusInternalServerErro
r) | 227 http.Error(w, err.Error(), http.StatusInternalServerErro
r) |
222 logging.Errorf(c, "failed to marshal test list JSON: %+v
, %v", aggr.Tests, err) | 228 logging.Errorf(c, "failed to marshal test list JSON: %+v
, %v", aggr.Tests, err) |
223 return | 229 return |
224 } | 230 } |
225 finalData = buf | 231 finalData = buf |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 } | 273 } |
268 } | 274 } |
269 | 275 |
270 // wrapCallback returns an io.Reader that wraps the data in r in a | 276 // wrapCallback returns an io.Reader that wraps the data in r in a |
271 // JavaScript-style function call with the supplied name as the function name. | 277 // JavaScript-style function call with the supplied name as the function name. |
272 func wrapCallback(r io.Reader, name string) io.Reader { | 278 func wrapCallback(r io.Reader, name string) io.Reader { |
273 start := bytes.NewReader([]byte(name + "(")) | 279 start := bytes.NewReader([]byte(name + "(")) |
274 end := bytes.NewReader([]byte(");")) | 280 end := bytes.NewReader([]byte(");")) |
275 return io.MultiReader(start, r, end) | 281 return io.MultiReader(start, r, end) |
276 } | 282 } |
OLD | NEW |