forked from CCExtractor/sample-platform
-
Notifications
You must be signed in to change notification settings - Fork 0
/
by_id.html
267 lines (262 loc) · 16 KB
/
by_id.html
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
{% extends "base.html" %}
{% block title %}Test progress for {{ title }} {{ super() }}{% endblock %}
{% block body %}
{{ super() }}
<br />
<div class="grid-x">
<div class="grid-x">
<div class="column medium-8">
<h1>Test progress for {{ title }}</h1>
{% set progress = test.progress_data() %}
<table class="tight">
<tbody>
<tr>
<td>{{ test.test_type.description }}</td>
<td>
{% if test.test_type == TestType.pull_request %}
<a href="{{ test.github_link }}" target="_blank">{{ test.pr_nr }}</a> (Commit {{ test.commit[:7] }})
{% elif test.test_type == TestType.commit %}
<a href="{{ test.github_link }}" target="_blank">{{ test.commit[:7] }}</a> (Branch {{ test.branch }})
{% endif %}
</td>
</tr>
<tr>
<td>Platform</td>
<td>{{ test.platform.description }}</td>
</tr>
<tr>
<td>Repository</td>
<td><a href="{{ test.fork.github_url }}" target="_blank">{{ test.fork.github_name }}</a></td>
</tr>
<tr>
<td>Start time</td>
<td>{{ progress.start if progress.start == '-' else progress.start|date('%Y-%m-%d %H:%M:%S (%Z)') }}</td>
</tr>
<tr>
<td>End time</td>
<td id="endtime">{{ progress.end if progress.end == '-' else progress.end|date('%Y-%m-%d %H:%M:%S (%Z)') }}</td>
</tr>
</tbody>
</table>
<ol class="col_12 progtrckr">
{% for stage in progress.stages -%}
{% set status = 'done' if progress.progress.step >= loop.index0 else 'todo' %}
{% if progress.progress.step == loop.index0 and not loop.last -%}
{% set status = 'running' %}
{%- endif %}
{% if progress.progress.state == 'error' and progress.progress.step == loop.index0 -%}
{% set status = status ~ ' error' %}
{%- endif %}
<li class="progtrckr-{{ status }}" id="trckr-{{ stage.description }}">{{ stage.description }}</li>
{%- endfor %}
</ol>
<br class="clear" />
{% if test.progress|length > 0 %}
<input type="button" id="progress_button" class="button" value="Show test progress" />
<a target="_blank" class="button" href = "{{ url_for('test.download_build_log_file',test_id=test.id) }}">Show log file</a>
<div style="overflow-x:auto;">
<table id="progress_table" class="hide striped">
<thead>
<tr>
<th>Time</th>
<th>Status</th>
<th>Message</th>
</tr>
</thead>
<tbody id='progress_table'>
{% for entry in test.progress %}
<tr>
<td>{{ entry.timestamp|date('%Y-%m-%d %H:%M:%S (%Z)') }}</td>
<td>{{ entry.status.description }}</td>
<td>{{ entry.message }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% else %}
<p>This test is still queued. There are {{ next }} tests queued before this one. Based on the average runtime, this test will be finished in {{ hr }} hours {{ min }} minutes.</p>
{% endif %}
{% if test.finished %}
{% if test.failed %}
<h2>An error occurred</h2>
<p>Something went wrong while the tests where running. You should be able to see in the bar above during which stage it went wrong exactly.</p>
<p>If you have build errors, you can access the above log file with build errors.</p>
{% else %}
<h2>Test results</h2>
<p>Click on the category names to expand the results, and on "Fail" to see the differences.</p>
{% for result in results %}
<h4 class="category-header {{ 'fail' if result.error else 'pass' }}" data-category="{{ result.category.id }}">{{ result.category.name }} - {{ 'Fail' if result.error else 'Pass' }}</h4>
{% if result.tests | length != 0 %}
<div id="no-more-tables">
<table class="col-md-12 table-bordered table-striped table-condensed sortable hide cf" data-category="{{ result.category.id }}">
<thead class="cf">
<tr>
<th class="numeric">Regression ID</th>
<th class="numeric">Sample</th>
<th class="numeric">Command</th>
<th class="numeric">Runtime (ms)</th>
<th class="numeric">Exit code</th>
<th class="numeric">Result</th>
</tr>
</thead>
<tbody>
{% for test in result.tests %}
<tr>
<td data-title="Regression ID"><a href="{{ url_for('regression.test_view', regression_id=test.test.id) }}">{{ test.test.id }}</a></td>
<td data-title="Sample"><a href="{{ url_for('sample.sample_by_id', sample_id=test.test.sample.id) }}">{{ test.test.sample.sha[:10] }}...</a></td>
<td data-title="Command">{{ test.test.command }}</td>
<td data-title="Runtime (ms)">{{ test.result.runtime }}</td>
<td data-title="Exit Code">{{ test.result.exit_code }}{{ '' if test.result.exit_code == test.result.expected_rc else ' (Expected '~test.result.expected_rc~')' }}</td>
<td data-title="Result">
{% for file in test.files -%}
{% if file.got is not none %}
{% set no_error = namespace(found=False) %}
{% for output_file in file.regression_test_output.multiple_files %}
{% if file.got == output_file.file_hashes %}
{% set no_error.found = True %}
{% break %}
{%- endif %}
{%- endfor %}
{%- endif %}
{% if test.result.exit_code != test.result.expected_rc %}
{% if file.got is none or no_error.found-%}
Fail
{% else %}
<a href="#" class="diff_link" data-test="{{ file.test_id }}" data-regression="{{ file.regression_test_id }}" data-output="{{ file.regression_test_output_id }}">Fail</a>
{%- endif %}
{% elif file.got is none or no_error.found or test.result.exit_code != 0 -%}
Pass
{% else %}
<a href="#" class="diff_link" data-test="{{ file.test_id }}" data-regression="{{ file.regression_test_id }}" data-output="{{ file.regression_test_output_id }}">Fail</a>
{%- endif %}
{% if not loop.last %}<br />{% endif %}
{% else %}
No files expected for this test
{%- endfor %}
</td>
</tr>
{%- endfor %}
</tbody>
</table>
</div>
{% else %}
<h6>There are no tests executed in this category.</h6>
{% endif %}
{% else %}
<p>There are no results available, though the status indicates the tests are done. Please get in touch.</p>
{% endfor %}
{% endif %}
{% endif %}
</div>
</div>
</div>
{% endblock %}
{% block scripts %}
{{ super() }}
<script type="text/javascript" src="{{ url_for('static', filename='js/same-blocks-highlight.js') }}"></script>
<script type="text/javascript">
{% set progress = test.progress_data() %}
var testprogress = {{ 1 if test.progress|length > 0 else 0 }};
$(document).ready(function(){
{% if not test.finished %}
var timer = setInterval(
function () {
$.ajax({
type: "GET",
url: "{{ url_for('test.get_json_data', test_id=test.id) }}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (data) {
var status, track, val, row, i;
if (data.status === "success") {
if (data.complete) {
window.location.reload();
}
val = data.progress_array;
if (testprogress === 0 && val.length !== 0) {
window.location.reload();
}
{% for stage in progress.stages %}
if (data.details.step >= {{ loop.index0 }}) {
status = 'done';
} else {
status = 'todo';
}
if (data.details.step === {{ loop.index0 }}) {
{% if not loop.last -%}
status = 'running';
{%- endif %}
}
if (data.details.state === 'error' && data.details.step === {{ loop.index0 }}) {
status = 'error';
}
track = $("#trckr-{{ stage.description }}");
track.removeClass("progtrckr-done progtrckr-running progtrckr-error progtrckr-todo");
track.addClass("progtrckr-"+status);
{% endfor %}
row = "";
for (i = 0; i < val.length; i++) {
row += '<tr>';
row += '<td> ' + val[i].timestamp + '</td>';
row += '<td> ' + val[i].status + ' </td>';
row += '<td> ' + val[i].message + ' </td>';
row += '</tr>'
}
$('#progress_table').html(row);
} else{
console.log(data.error);
clearTimeout(timer);
}
},
failure: function (errMsg) {
console.log("Error Fetching");
clearTimeout(timer);
}
});
},
20000
);
{% endif %}
$('.category-header').on('click', function(){
var id = $(this).data('category');
$('table[data-category="'+id+'"]').toggleClass('hide');
});
$('#progress_button').on('click', function(){
var content = ($(this).val().indexOf('Show') === 0 ? 'Hide' : 'Show')+' test progress';
$(this).val(content);
$('#progress_table').toggleClass('hide');
});
$('.diff_link').on('click', function(){
// Make ajax request to get a diff, and display it in a "popup"
var $modal = $('#modal');
var url = '{{ url_for('test.generate_diff', test_id='_0_', regression_test_id='_1_', output_id='_2_') }}';
var diff_download_url = '{{ url_for('test.generate_diff', test_id='_0_', regression_test_id='_1_', output_id='_2_', to_view=0) }}';
url = url.replace('_0_', $(this).data('test')).replace('_1_', $(this).data('regression')).replace('_2_', $(this).data('output'));
diff_download_url = diff_download_url.replace('_0_', $(this).data('test')).replace('_1_', $(this).data('regression')).replace('_2_', $(this).data('output'));
$.ajax(url).done(function(resp){
var id, reveal, popup;
reveal = document.createElement('div');
id = 'diff-popup-'+(new Date()).getTime();
reveal.setAttribute('id', id);
reveal.setAttribute('class', 'large reveal');
reveal.setAttribute('data-reveal', '');
reveal.innerHTML = resp;
reveal.innerHTML +=
'<a href="'+diff_download_url+'" target="_blank">' +
'<button type="button">' +
'Download Full Diff' +
'</button>' +
'</a>, only first 50 shown here.';
reveal.innerHTML +=
'<button class="close-button" data-close aria-label="Cancel" type="button">' +
' <span aria-hidden="true">×</span>' +
'</button>';
document.body.appendChild(reveal);
popup = new Foundation.Reveal($('#'+id));
popup.open();
});
});
});
</script>
{% endblock %}