mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-01 23:57:49 +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);
|
||||
|
||||
// Tell saucelabs to run some tests
|
||||
var browser = JSON.parse(process.env['SAUCE_BROWSER']);
|
||||
var username = process.env['SAUCE_USERNAME'];
|
||||
var accessKey = process.env['SAUCE_ACCESS_KEY'];
|
||||
|
||||
@@ -17,13 +18,50 @@ request.post(
|
||||
{
|
||||
auth: { user: username, pass: accessKey },
|
||||
json: {
|
||||
platforms: [[ "Windows 7", "chrome", "27" ]],
|
||||
platforms: [ browser ],
|
||||
url: "http://localhost:" + port + "/test/index.html",
|
||||
framework: "qunit"
|
||||
}
|
||||
},
|
||||
function (error, response, body) {
|
||||
console.log(response.statusCode);
|
||||
console.log(body);
|
||||
if (response.statusCode == 200) {
|
||||
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