mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-31 15:27:50 +00:00
First round of sauce support cleanup.
This commit is contained in:
@@ -6,11 +6,8 @@ node_js:
|
||||
env:
|
||||
global:
|
||||
- BIN="node" BUILD=false MAKE=false OPTION="" SAUCELABS=false
|
||||
|
||||
# SauceLabs credentials:
|
||||
- SAUCE_USERNAME="pimterry"
|
||||
- secure: "KBETrs7sRrU3V8itVgLzBUVkzP9XXpAEZVjbd8icoNL9eVW3h4Kk5g/bOa06IAml0ThnMZztIwMKkplCIam6W/Cv+eIOiQT2kkG32lHFwbVXEkbq+rKj8XmpRmXBf/Th63V+u5GMVmQlYrIfdXju6cFfSEZ2uG8SHVg9hFyyf8c="
|
||||
|
||||
- SAUCE_USERNAME="jdalton"
|
||||
- secure: "woILQltl1pI3DgadZ5NrcqntdPvnRmQBwIVNZL91Ht5d9snIhgyAixI6xNAS8F8BzD9RzqzVPHay5sHfn+GhNaojcaiHs1nXAbdyclevMyfP+3MQ1HGfMSU0bv1GdT35LJ+C0u4Y3SuuZSbBlNEeLXRPMngPZahf4xL8RsZz/is="
|
||||
matrix:
|
||||
- BUILD="compat"
|
||||
- BUILD="modern"
|
||||
@@ -54,7 +51,7 @@ before_install:
|
||||
- "[ $BIN == 'rhino' ] && echo -e '#!/bin/sh\\njava -jar /opt/rhino-1.7R5/js.jar $@' | sudo tee /usr/local/bin/rhino && sudo chmod +x /usr/local/bin/rhino || true"
|
||||
- "[ $BIN == 'ringo' ] && wget http://ringojs.org/downloads/ringojs-0.9.zip && sudo unzip ringojs-0.9 -d /opt && rm ringojs-0.9.zip || true"
|
||||
- "[ $BIN == 'ringo' ] && sudo ln -s /opt/ringojs-0.9/bin/ringo /usr/local/bin/ringo && sudo chmod +x /usr/local/bin/ringo || true"
|
||||
- "[ $SAUCELABS != false ] && npm install connect request sauce-tunnel || true"
|
||||
- "[ $SAUCELABS != false ] && npm i connect request sauce-tunnel || true"
|
||||
script:
|
||||
- "[ $BIN == 'istanbul' ] && $BIN cover ./test/test.js || true"
|
||||
- "[ $BUILD != false ] && [ $BUILD != 'compat' ] && MAKE=true || true"
|
||||
|
||||
@@ -16,13 +16,6 @@
|
||||
<script src="./asset/test-ui.js"></script>
|
||||
<div id="qunit"></div>
|
||||
<div id="exports"></div>
|
||||
<script>
|
||||
// Report test results in a global, for saucelabs
|
||||
window.global_test_results = null;
|
||||
QUnit.done(function (results) {
|
||||
window.global_test_results = results;
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
// set bad shims
|
||||
Array._isArray = Array.isArray;
|
||||
@@ -79,6 +72,12 @@
|
||||
delete Object._defineProperty;
|
||||
delete Object._keys;
|
||||
|
||||
// report test results in a global for Sauce Labs
|
||||
var global_test_results;
|
||||
QUnit.done(function(results) {
|
||||
global_test_results = results;
|
||||
});
|
||||
|
||||
// load Lo-Dash again to overwrite the existing `_` value
|
||||
document.write('<script src="' + (ui.isModularize ? '../lodash.js' : ui.buildPath) + '"><\/script>');
|
||||
|
||||
|
||||
@@ -1,108 +1,113 @@
|
||||
var connect = require('connect');
|
||||
var path = require('path');
|
||||
var SauceTunnel = require('sauce-tunnel');
|
||||
var request = require('request');
|
||||
var connect = require('connect'),
|
||||
path = require('path'),
|
||||
request = require('request'),
|
||||
SauceTunnel = require('sauce-tunnel');
|
||||
|
||||
var port = 8081,
|
||||
username = process.env.SAUCE_USERNAME,
|
||||
accessKey = process.env.SAUCE_ACCESS_KEY;
|
||||
|
||||
var port = 8081;
|
||||
var username = process.env['SAUCE_USERNAME'];
|
||||
var accessKey = process.env['SAUCE_ACCESS_KEY'];
|
||||
var platforms = [
|
||||
["Windows 7", "chrome", ""],
|
||||
["Windows 7", "firefox", "24"],
|
||||
["Windows 7", "internet explorer", "9"]
|
||||
['Windows 7', 'chrome', ''],
|
||||
['Windows 7', 'firefox', '24'],
|
||||
['Windows 7', 'internet explorer', '9']
|
||||
];
|
||||
|
||||
// Create a web server for the local dir
|
||||
// create a web server for the local dir
|
||||
var server = connect.createServer(
|
||||
connect.static(path.resolve(__dirname, '..'))
|
||||
connect.static(path.resolve(__dirname, '..'))
|
||||
).listen(port);
|
||||
|
||||
// Set up sauce connect so we can use this server from saucelabs
|
||||
var tunnelTimeout = 10000;
|
||||
var tunnel = new SauceTunnel(username, accessKey, null, true, tunnelTimeout);
|
||||
// set up sauce connect so we can use this server from saucelabs
|
||||
var tunnelTimeout = 10000,
|
||||
tunnel = new SauceTunnel(username, accessKey, null, true, tunnelTimeout);
|
||||
|
||||
console.log("Opening sauce connect tunnel...");
|
||||
tunnel.start(function (success) {
|
||||
if (success) {
|
||||
console.log("Sauce connect tunnel opened");
|
||||
runTests();
|
||||
} else {
|
||||
console.error("Failed to open sauce connect tunnel")
|
||||
process.exit(2);
|
||||
}
|
||||
console.log('Opening sauce connect tunnel...');
|
||||
|
||||
tunnel.start(function(success) {
|
||||
if (success) {
|
||||
console.log('Sauce connect tunnel opened');
|
||||
runTests();
|
||||
} else {
|
||||
console.error('Failed to open sauce connect tunnel')
|
||||
process.exit(2);
|
||||
}
|
||||
});
|
||||
|
||||
function runTests() {
|
||||
var testDefinition = {
|
||||
platforms: platforms,
|
||||
url: "http://localhost:" + port + "/test/index.html",
|
||||
framework: "qunit"
|
||||
};
|
||||
var testDefinition = {
|
||||
'framework': 'qunit',
|
||||
'platforms': platforms,
|
||||
'url': 'http://localhost:' + port + '/test/index.html'
|
||||
};
|
||||
|
||||
console.log("Starting saucelabs tests: " + JSON.stringify(testDefinition));
|
||||
console.log('Starting saucelabs tests: ' + JSON.stringify(testDefinition));
|
||||
|
||||
request.post('https://saucelabs.com/rest/v1/' + username + '/js-tests', {
|
||||
auth: { user: username, pass: accessKey },
|
||||
json: testDefinition
|
||||
}, function (error, response, 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);
|
||||
}
|
||||
});
|
||||
request.post('https://saucelabs.com/rest/v1/' + username + '/js-tests', {
|
||||
'auth': { 'user': username, 'pass': accessKey },
|
||||
'json': testDefinition
|
||||
}, function(error, response, 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) {
|
||||
if (body["completed"] == true) {
|
||||
handleTestResults(body["js tests"]);
|
||||
} else {
|
||||
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) {
|
||||
if (body.completed) {
|
||||
handleTestResults(body['js tests']);
|
||||
} else {
|
||||
console.error("Failed to check test status on SauceLabs, status " + response.statusCode + ", body:\n" + JSON.stringify(body));
|
||||
process.exit(4);
|
||||
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, test) {
|
||||
return passedSoFar && test.result.failed === 0;
|
||||
}, true);
|
||||
var allTestsSuccessful = results.reduce(function(passedSoFar, test) {
|
||||
return passedSoFar && test.result.failed === 0;
|
||||
}, true);
|
||||
|
||||
if (allTestsSuccessful) {
|
||||
console.log("Tests passed");
|
||||
} else {
|
||||
var failingTests = results.filter(function (test) {
|
||||
return test.result.failed !== 0;
|
||||
});
|
||||
var failingPlatforms = failingTests.map(function (test) {
|
||||
return test.platform;
|
||||
});
|
||||
if (allTestsSuccessful) {
|
||||
console.log('Tests passed');
|
||||
}
|
||||
else {
|
||||
var failingTests = results.filter(function(test) {
|
||||
return test.result.failed !== 0;
|
||||
});
|
||||
|
||||
console.error("Tests failed on platforms: " + JSON.stringify(failingPlatforms));
|
||||
var failingPlatforms = failingTests.map(function(test) {
|
||||
return test.platform;
|
||||
});
|
||||
|
||||
failingTests.forEach(function (test) {
|
||||
var platform = JSON.stringify(test.platform);
|
||||
console.error('Tests failed on platforms: ' + JSON.stringify(failingPlatforms));
|
||||
|
||||
if (test.result.failed) {
|
||||
console.error(test.result.failed + " failures on " + platform + ". See " + test.url + " for details.");
|
||||
} else {
|
||||
console.error("Testing on " + platform + " failed; no results available. See " + test.url + " for details.");
|
||||
}
|
||||
});
|
||||
}
|
||||
failingTests.forEach(function(test) {
|
||||
var platform = JSON.stringify(test.platform);
|
||||
|
||||
console.log("Shutting down sauce connect tunnel...");
|
||||
tunnel.stop(function () {
|
||||
process.exit(allTestsSuccessful ? 0 : 1);
|
||||
})
|
||||
}
|
||||
if (test.result.failed) {
|
||||
console.error(test.result.failed + ' failures on ' + platform + '. See ' + test.url + ' for details.');
|
||||
} else {
|
||||
console.error('Testing on ' + platform + ' failed; no results available. See ' + test.url + ' for details.');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
console.log('Shutting down sauce connect tunnel...');
|
||||
|
||||
tunnel.stop(function() {
|
||||
process.exit(allTestsSuccessful ? 0 : 1);
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user