-
Notifications
You must be signed in to change notification settings - Fork 2
/
saucerunner.html
149 lines (126 loc) · 4.96 KB
/
saucerunner.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
<!-- /* Copyright 2015-2016 Teem2 LLC. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
either express or implied. See the License for the specific language governing permissions and limitations under the License.*/
-->
<html>
<head>
<script>
window.onload = function() {
var files;
//this is for testing this runner itself, to run through all smokes run through the dreem server localhost:8080/saucerun
files = [
'http://localhost:8080/compositions/smoke/view.dre?test'
];
//to run all the smokes run from the server localhost:8080/saucerun,
//which populates this DYNAMIC_FILES collection with all files from the smoke directory
var DYNAMIC_FILES = null;
if (DYNAMIC_FILES) files = DYNAMIC_FILES;
var maxCheckOverride; //these determine how long to wait for test results - for the mobile platforms the tests need more time
var testTimeoutOverride; //these determine how long to wait for test results - for the mobile platforms the tests need more time
var qParams = window.location.search.slice(1).split('&');
for (var i in qParams) {
var qParam = qParams[i];
var paramPair = qParam.split('=');
if (paramPair[0] == 'maxChecks') maxCheckOverride = parseInt(paramPair[1]);
else if (paramPair[0] == 'testTimeout') testTimeoutOverride = parseInt(paramPair[1]);
}
var successCount = 0;
var failedCount = 0;
var tests = [];
var currentTestName;
function reportFailure(results) {
var message;
if (!results) {
message = 'did not report any results';
} else {
message = '' + results.failed + ' failed of ' + results.total + ' tests:: \n';
for (var i in results.tests) {
var test = results.tests[i];
if (test.result == false) {
message += test.name + ' ' + test.message + '\n';
}
}
}
failedCount++;
tests.push({
"name": currentTestName,
"result": false,
"message": message,
"duration": results ? results.duration : 0
});
}
function reportSuccess(results) {
successCount++;
tests.push({
"name": currentTestName,
"result": true,
"message": '' + results.passed + ' passing of ' + results.total + ' tests',
"duration": results.duration
});
}
var startTime = new Date();
function reportAllResults() {
var duration = (new Date() - startTime) / 1000;
window.global_test_results = {
"passed": successCount,
"failed": failedCount,
"total": successCount + failedCount,
"duration": duration,
"tests": tests
}
}
function collate() {
var results = window.testframe.contentWindow.global_test_results;
if (!results) {
reportFailure(null);
} else if (results.failed > 0) {
reportFailure(results);
} else {
reportSuccess(results);
}
runNextTest();
}
var testIndex = 0;
function runNextTest() {
if (testIndex >= files.length) {
reportAllResults();
return;
}
currentTestName = files[testIndex];
testIndex++;
if (window.testframe) {
document.body.removeChild(window.testframe);
}
var testframe = document.createElement("iframe");
testframe.style.width = "100%";
testframe.style.height = "100%";
testframe.style.position = "absolute";
testframe.style.left = 0;
testframe.style.top = 0;
var testUrl = currentTestName + '?test';
if (testTimeoutOverride) testUrl += '&testTimeout=' + testTimeoutOverride;
testframe.src = testUrl;
document.body.appendChild(testframe);
testframe.onload = function() {
var maxChecks = maxCheckOverride || 200;
var totalChecks = 0;
var checker = function() {
totalChecks++;
if (window.testframe.contentWindow.global_test_results || (totalChecks >= maxChecks)) {
collate();
} else {
window.setTimeout(checker, 500);
}
}
checker();
}
window.testframe = testframe;
}
runNextTest();
};
</script>
</head>
<body>
</body>
</html>