OLD | NEW |
1 <!-- | 1 <!-- |
2 Copyright 2014 The Chromium Authors. All rights reserved. | 2 Copyright 2014 The Chromium Authors. All rights reserved. |
3 Use of this source code is governed by a BSD-style license that can be | 3 Use of this source code is governed by a BSD-style license that can be |
4 found in the LICENSE file. | 4 found in the LICENSE file. |
5 --> | 5 --> |
6 | 6 |
7 <link rel="import" href="ct-results-comparison.html"> | 7 <link rel="import" href="ct-results-comparison.html"> |
8 | 8 |
9 <polymer-element name="ct-results-detail" attributes="test builder result"> | 9 <polymer-element name="ct-results-detail" attributes="failure builder"> |
10 <template> | 10 <template> |
11 <style> | 11 <style> |
12 :host { | 12 :host { |
13 display: block; | 13 display: block; |
14 } | 14 } |
15 </style> | 15 </style> |
16 <template if="{{!_urlGroups.length}}"> | 16 <template if="{{!_urlGroups.length}}"> |
17 No results to display. | 17 No results to display. |
18 </template> | 18 </template> |
19 <template repeat="{{urlGroup in _urlGroups}}"> | 19 <template repeat="{{urlGroup in _urlGroups}}"> |
20 <template if="{{urlGroup.urls[_kUnknownKind]}}"> | 20 <template if="{{urlGroup.urls[_kUnknownKind]}}"> |
21 <ct-test-output type="{{urlGroup.type}}" url="{{urlGroup.urls[_kUnknownK
ind]}}"></ct-test-output> | 21 <ct-test-output type="{{urlGroup.type}}" url="{{urlGroup.urls[_kUnknownK
ind]}}"></ct-test-output> |
22 </template> | 22 </template> |
23 <template if="{{!urlGroup.urls[_kUnknownKind]}}"> | 23 <template if="{{!urlGroup.urls[_kUnknownKind]}}"> |
24 <ct-results-comparison type="{{urlGroup.type}}" expectedUrl="{{urlGroup.
urls[_kExpectedKind]}}" | 24 <ct-results-comparison type="{{urlGroup.type}}" expectedUrl="{{urlGroup.
urls[_kExpectedKind]}}" |
25 actualUrl="{{urlGroup.urls[_kActualKind]}}" diffUrl="{{urlGroup.urls
[_kDiffKind]}}"></ct-results-comparison> | 25 actualUrl="{{urlGroup.urls[_kActualKind]}}" diffUrl="{{urlGroup.urls
[_kDiffKind]}}"></ct-results-comparison> |
26 </template> | 26 </template> |
27 </template> | 27 </template> |
28 </template> | 28 </template> |
29 <script> | 29 <script> |
30 Polymer({ | 30 Polymer({ |
31 test: '', | 31 failure: null, |
32 // FIXME: Initializing builder gives a JS error. Presumably because | 32 // FIXME: Initializing builder gives a JS error. Presumably because |
33 // ct-results-by-builder sets builder="{{builders[selected]}}". But, | 33 // ct-results-by-builder sets builder="{{builders[selected]}}". But, |
34 // it seems wrong that the way the parent uses this element constrains | 34 // it seems wrong that the way the parent uses this element constrains |
35 // what the element can do. Polymer bug? | 35 // what the element can do. Polymer bug? |
36 // builder: '', | 36 // builder: '', |
37 // FIXME: Initializing result gives a JS error like above. | |
38 // result: '', | |
39 | 37 |
40 _urlGroups: [], | 38 _urlGroups: [], |
41 _kExpectedKind: results.kExpectedKind, | 39 _kExpectedKind: results.kExpectedKind, |
42 _kActualKind: results.kActualKind, | 40 _kActualKind: results.kActualKind, |
43 _kDiffKind: results.kDiffKind, | 41 _kDiffKind: results.kDiffKind, |
44 _kUnknownKind: results.kUnknownKind, | 42 _kUnknownKind: results.kUnknownKind, |
45 | 43 |
46 observe: { | 44 observe: { |
47 result: '_update', | 45 failure: '_update', |
48 test: '_update', | |
49 builder: '_update', | 46 builder: '_update', |
50 }, | 47 }, |
51 | 48 |
52 _update: function() { | 49 _update: function() { |
53 if (!this.test || !this.builder || !this.result) | 50 if (!this.failure || !this.builder) |
54 return; | 51 return; |
55 | 52 |
56 var failureInfo = results.failureInfo(this.test, this.builder, this.resu
lt); | 53 // FIXME: If the types of groups doesn't change, then it'd be better to
do this |
| 54 // update in place so that the user doesn't see a flicker. |
| 55 this._urlGroups = []; |
| 56 |
| 57 var result = this.failure.resultNodesByBuilder[this.builder]; |
| 58 // FIXME: There's probably a less hacky way to check this. |
| 59 if (result.actual == 'FAIL' || result.actual == 'UNKNOWN') |
| 60 this._updateUrls(); |
| 61 else |
| 62 this._updateWebkitTestUrls(); |
| 63 }, |
| 64 |
| 65 _updateWebkitTestUrls: function() { |
| 66 var result = this.failure.resultNodesByBuilder[this.builder]; |
| 67 var failureInfo = results.failureInfo(this.failure.testName, this.builde
r, result.actual); |
| 68 |
57 // FIXME: Move this logic to a proper model class so that the network re
quests this makes | 69 // FIXME: Move this logic to a proper model class so that the network re
quests this makes |
58 // can be easily mocked out in tests. | 70 // can be easily mocked out in tests. |
59 results.fetchResultsURLs(failureInfo).then(function(resultsUrls) { | 71 results.fetchResultsURLs(failureInfo).then(function(resultsUrls) { |
60 var resultsUrlsByTypeAndKind = {}; | 72 var resultsUrlsByTypeAndKind = {}; |
61 resultsUrls.forEach(function(url) { | 73 resultsUrls.forEach(function(url) { |
62 var resultType = results.resultType(url); | 74 var resultType = results.resultType(url); |
63 if (!resultsUrlsByTypeAndKind[resultType]) | 75 if (!resultsUrlsByTypeAndKind[resultType]) |
64 resultsUrlsByTypeAndKind[resultType] = {}; | 76 resultsUrlsByTypeAndKind[resultType] = {}; |
65 resultsUrlsByTypeAndKind[resultType][results.resultKind(url)] = ur
l; | 77 resultsUrlsByTypeAndKind[resultType][results.resultKind(url)] = ur
l; |
66 }); | 78 }); |
67 | 79 |
68 this._urlGroups = []; | |
69 Object.keys(resultsUrlsByTypeAndKind, function(resultType, resultsUrls
ByKind) { | 80 Object.keys(resultsUrlsByTypeAndKind, function(resultType, resultsUrls
ByKind) { |
70 this._urlGroups.push({ | 81 this._urlGroups.push({ |
71 type: resultType, | 82 type: resultType, |
72 urls: resultsUrlsByKind, | 83 urls: resultsUrlsByKind, |
73 }); | 84 }); |
74 }.bind(this)); | 85 }.bind(this)); |
75 }.bind(this)); | 86 }.bind(this)); |
76 }, | 87 }, |
| 88 |
| 89 _updateUrls: function() { |
| 90 // FIXME: Along with _updateWebkitTestUrls, move this logic to a proper
model class |
| 91 // so that the network requests this makes can be easily mocked out in t
ests. |
| 92 |
| 93 var result = this.failure.resultNodesByBuilder[this.builder]; |
| 94 |
| 95 // FIXME: We only store build logs by the test name, not the testsuite.t
estname, |
| 96 // which means that two failing tests from different test suites conflic
t! |
| 97 var testPart = result.actual == 'UNKNOWN' ? 'stdio' : this.failure.testN
ame.split('.')[1]; |
| 98 var url = result.masterUrl + |
| 99 '/builders/' + encodeURIComponent(this.builder) + |
| 100 '/builds/' + result.lastFailingBuild + |
| 101 '/steps/' + this.failure.step + |
| 102 '/logs/' + testPart; |
| 103 |
| 104 var resultsUrlsByKind = {}; |
| 105 resultsUrlsByKind[this._kUnknownKind] = url; |
| 106 |
| 107 this._urlGroups.push({ |
| 108 type: results.kTextType, |
| 109 urls: resultsUrlsByKind, |
| 110 }); |
| 111 }, |
77 }); | 112 }); |
78 </script> | 113 </script> |
79 </polymer-element> | 114 </polymer-element> |
OLD | NEW |