mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-10 02:47:50 +00:00
Initial working saucelabs test result recording
This commit is contained in:
46
saucelabs.js
46
saucelabs.js
@@ -7,6 +7,7 @@ var server = connect.createServer(
|
|||||||
).listen(port);
|
).listen(port);
|
||||||
|
|
||||||
// Tell saucelabs to run some tests
|
// Tell saucelabs to run some tests
|
||||||
|
var browser = JSON.parse(process.env['SAUCE_BROWSER']);
|
||||||
var username = process.env['SAUCE_USERNAME'];
|
var username = process.env['SAUCE_USERNAME'];
|
||||||
var accessKey = process.env['SAUCE_ACCESS_KEY'];
|
var accessKey = process.env['SAUCE_ACCESS_KEY'];
|
||||||
|
|
||||||
@@ -17,13 +18,50 @@ request.post(
|
|||||||
{
|
{
|
||||||
auth: { user: username, pass: accessKey },
|
auth: { user: username, pass: accessKey },
|
||||||
json: {
|
json: {
|
||||||
platforms: [[ "Windows 7", "chrome", "27" ]],
|
platforms: [ browser ],
|
||||||
url: "http://localhost:" + port + "/test/index.html",
|
url: "http://localhost:" + port + "/test/index.html",
|
||||||
framework: "qunit"
|
framework: "qunit"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
function (error, response, body) {
|
function (error, response, body) {
|
||||||
console.log(response.statusCode);
|
if (response.statusCode == 200) {
|
||||||
console.log(body);
|
var testIdentifier = body;
|
||||||
|
waitForTestCompletion(testIdentifier);
|
||||||
|
} else {
|
||||||
|
console.error("Failed to submit test to SauceLabs, status " + response.statusCode + ", body:\n" + JSON.stringify(body));
|
||||||
|
process.exit(3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
function waitForTestCompletion(testIdentifier) {
|
||||||
|
request.post(
|
||||||
|
'https://saucelabs.com/rest/v1/' + username + '/js-tests/status',
|
||||||
|
{
|
||||||
|
auth: { user: username, pass: accessKey },
|
||||||
|
json: testIdentifier
|
||||||
|
},
|
||||||
|
function (error, response, body) {
|
||||||
|
if (response.statusCode == 200) {
|
||||||
|
console.log(JSON.stringify(body));
|
||||||
|
if (body["completed"] == true) {
|
||||||
|
handleTestResults(body["js tests"]);
|
||||||
|
} else {
|
||||||
|
waitForTestCompletion(testIdentifier);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.error("Failed to check test status on SauceLabs, status " + response.statusCode + ", body:\n" + JSON.stringify(body));
|
||||||
|
process.exit(4);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleTestResults(results) {
|
||||||
|
var allTestsSuccessful = results.reduce(function (passedSoFar, result) {
|
||||||
|
return passedSoFar && !!result['passed']
|
||||||
|
}, true);
|
||||||
|
|
||||||
|
console.log(allTestsSuccessful ? "Test passed" : "Test failed");
|
||||||
|
process.exit(allTestsSuccessful ? 0 : 1);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user