2015-01-08 17:20:05 -05:00
|
|
|
// load traceur runtime as our tests are written in es6
|
|
|
|
require('traceur/bin/traceur-runtime.js');
|
2015-02-11 13:13:49 -05:00
|
|
|
|
2015-02-17 13:32:09 -05:00
|
|
|
var argv = require('yargs')
|
|
|
|
.usage('Angular e2e/perf test options.')
|
|
|
|
.options({
|
|
|
|
'sample-size': {
|
|
|
|
describe: 'sample size',
|
2015-02-27 16:41:53 -05:00
|
|
|
default: 20
|
2015-02-17 13:32:09 -05:00
|
|
|
},
|
|
|
|
'force-gc': {
|
2015-02-23 13:34:58 -05:00
|
|
|
describe: 'force gc.',
|
2015-02-17 13:32:09 -05:00
|
|
|
default: false,
|
|
|
|
type: 'boolean'
|
|
|
|
},
|
|
|
|
'benchmark': {
|
|
|
|
describe: 'whether to run the benchmarks',
|
|
|
|
default: false
|
|
|
|
},
|
|
|
|
'browsers': {
|
2015-02-23 13:34:58 -05:00
|
|
|
describe: 'comma separated list of preconfigured browsers to use',
|
2015-02-17 13:32:09 -05:00
|
|
|
default: 'ChromeDesktop'
|
2015-02-23 13:34:58 -05:00
|
|
|
},
|
|
|
|
'spec': {
|
|
|
|
describe: 'comma separated file patterns to test',
|
|
|
|
default: false
|
2015-02-17 13:32:09 -05:00
|
|
|
}
|
|
|
|
})
|
|
|
|
.help('ng-help')
|
|
|
|
.wrap(40)
|
|
|
|
.argv
|
2015-02-11 13:13:49 -05:00
|
|
|
|
2015-02-17 13:32:09 -05:00
|
|
|
var browsers = argv['browsers'].split(',');
|
|
|
|
|
2015-02-27 12:07:16 -05:00
|
|
|
var CHROME_OPTIONS = {
|
|
|
|
'args': ['--js-flags=--expose-gc'],
|
|
|
|
'perfLoggingPrefs': {
|
|
|
|
'traceCategories': 'blink.console,disabled-by-default-devtools.timeline'
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
var CHROME_MOBILE_EMULATION = {
|
|
|
|
// Can't use 'deviceName':'Google Nexus 7 2'
|
|
|
|
// as this would yield wrong orientation,
|
|
|
|
// so we specify facts explicitly
|
|
|
|
'deviceMetrics': {
|
|
|
|
'width': 600,
|
|
|
|
'height': 960,
|
|
|
|
'pixelRatio': 2
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-02-17 13:32:09 -05:00
|
|
|
var BROWSER_CAPS = {
|
|
|
|
Dartium: {
|
|
|
|
name: 'Dartium',
|
|
|
|
browserName: 'chrome',
|
2015-02-27 12:07:16 -05:00
|
|
|
chromeOptions: mergeInto(CHROME_OPTIONS, {
|
|
|
|
'mobileEmulation': CHROME_MOBILE_EMULATION,
|
|
|
|
'binary': process.env.DARTIUM
|
|
|
|
}),
|
2015-02-17 13:32:09 -05:00
|
|
|
loggingPrefs: {
|
|
|
|
performance: 'ALL',
|
|
|
|
browser: 'ALL'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
ChromeDesktop: {
|
|
|
|
browserName: 'chrome',
|
2015-02-27 12:07:16 -05:00
|
|
|
chromeOptions: mergeInto(CHROME_OPTIONS, {
|
|
|
|
'mobileEmulation': CHROME_MOBILE_EMULATION
|
|
|
|
}),
|
2015-02-17 13:32:09 -05:00
|
|
|
loggingPrefs: {
|
|
|
|
performance: 'ALL',
|
|
|
|
browser: 'ALL'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
ChromeAndroid: {
|
|
|
|
browserName: 'chrome',
|
2015-02-27 12:07:16 -05:00
|
|
|
chromeOptions: mergeInto(CHROME_OPTIONS, {
|
|
|
|
'androidPackage': 'com.android.chrome',
|
|
|
|
}),
|
2015-02-17 13:32:09 -05:00
|
|
|
loggingPrefs: {
|
|
|
|
performance: 'ALL',
|
|
|
|
browser: 'ALL'
|
|
|
|
}
|
2015-02-18 17:39:52 -05:00
|
|
|
},
|
|
|
|
IPhoneSimulator: {
|
|
|
|
browserName: 'MobileSafari',
|
|
|
|
simulator: true,
|
|
|
|
CFBundleName: 'Safari',
|
|
|
|
device: 'iphone',
|
|
|
|
instruments: 'true',
|
|
|
|
loggingPrefs: {
|
|
|
|
performance: 'ALL',
|
|
|
|
browser: 'ALL'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
IPadNative: {
|
|
|
|
browserName: 'MobileSafari',
|
|
|
|
simulator: false,
|
|
|
|
CFBundleName: 'Safari',
|
|
|
|
device: 'ipad',
|
|
|
|
loggingPrefs: {
|
|
|
|
performance: 'ALL',
|
|
|
|
browser: 'ALL'
|
|
|
|
}
|
2015-02-17 13:32:09 -05:00
|
|
|
}
|
|
|
|
};
|
2015-01-08 17:20:05 -05:00
|
|
|
|
2015-02-23 13:34:58 -05:00
|
|
|
var getBenchmarkFiles = function (benchmark, spec) {
|
|
|
|
var specFiles = [];
|
|
|
|
var perfFiles = [];
|
|
|
|
if (spec.length) {
|
|
|
|
spec.split(',').forEach(function (name) {
|
|
|
|
specFiles.push('dist/js/cjs/**/e2e_test/' + name)
|
|
|
|
perfFiles.push('dist/js/cjs/**/e2e_test/' + name)
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
specFiles.push('dist/js/cjs/**/e2e_test/**/*_spec.js');
|
|
|
|
perfFiles.push('dist/js/cjs/**/e2e_test/**/*_perf.js');
|
|
|
|
}
|
|
|
|
return benchmark ? perfFiles : specFiles.concat(perfFiles);
|
|
|
|
};
|
|
|
|
|
2015-01-08 17:20:05 -05:00
|
|
|
var config = exports.config = {
|
|
|
|
// Disable waiting for Angular as we don't have an integration layer yet...
|
|
|
|
// TODO(tbosch): Implement a proper debugging API for Ng2.0, remove this here
|
|
|
|
// and the sleeps in all tests.
|
|
|
|
onPrepare: function() {
|
|
|
|
browser.ignoreSynchronization = true;
|
|
|
|
var _get = browser.get;
|
2015-02-05 21:33:57 -05:00
|
|
|
var sleepInterval = process.env.TRAVIS || process.env.JENKINS_URL ? 7000 : 3000;
|
2015-01-08 17:20:05 -05:00
|
|
|
browser.get = function() {
|
|
|
|
var result = _get.apply(this, arguments);
|
|
|
|
browser.sleep(sleepInterval);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2015-02-23 13:34:58 -05:00
|
|
|
specs: getBenchmarkFiles(argv['benchmark'], argv['spec']),
|
2015-02-17 13:32:09 -05:00
|
|
|
|
|
|
|
exclude: [
|
|
|
|
'dist/js/cjs/**/node_modules/**',
|
|
|
|
],
|
|
|
|
|
|
|
|
multiCapabilities: browsers.map(function(browserName) {
|
|
|
|
var caps = BROWSER_CAPS[browserName];
|
|
|
|
console.log('Testing against', browserName);
|
|
|
|
if (!caps) {
|
|
|
|
throw new Error('Not configured browser name: '+browserName);
|
|
|
|
}
|
|
|
|
return caps;
|
|
|
|
}),
|
|
|
|
|
2015-01-08 23:59:03 -05:00
|
|
|
framework: 'jasmine2',
|
|
|
|
|
2015-01-08 17:20:05 -05:00
|
|
|
jasmineNodeOpts: {
|
|
|
|
showColors: true,
|
2015-02-26 14:32:57 -05:00
|
|
|
defaultTimeoutInterval: argv['benchmark'] ? 1200000 : 30000
|
2015-02-11 13:13:49 -05:00
|
|
|
},
|
|
|
|
params: {
|
|
|
|
benchmark: {
|
|
|
|
scaling: [{
|
|
|
|
userAgent: /Android/, value: 0.125
|
|
|
|
}]
|
|
|
|
}
|
2015-01-08 17:20:05 -05:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-02-11 13:13:49 -05:00
|
|
|
exports.createBenchpressRunner = function(options) {
|
2015-02-17 13:32:09 -05:00
|
|
|
var nodeUuid = require('node-uuid');
|
|
|
|
var benchpress = require('./dist/js/cjs/benchpress/benchpress');
|
|
|
|
|
2015-02-11 13:13:49 -05:00
|
|
|
// TODO(tbosch): add cloud reporter again (only when !options.test)
|
|
|
|
// var cloudReporterConfig;
|
|
|
|
// if (process.env.CLOUD_SECRET_PATH) {
|
|
|
|
// console.log('using cloud reporter!');
|
|
|
|
// cloudReporterConfig = {
|
|
|
|
// auth: require(process.env.CLOUD_SECRET_PATH),
|
|
|
|
// projectId: 'angular-perf',
|
|
|
|
// datasetId: 'benchmarks',
|
|
|
|
// tableId: 'ng2perf'
|
|
|
|
// };
|
|
|
|
// }
|
|
|
|
|
|
|
|
var runId = nodeUuid.v1();
|
|
|
|
if (process.env.GIT_SHA) {
|
|
|
|
runId = process.env.GIT_SHA + ' ' + runId;
|
|
|
|
}
|
|
|
|
var bindings = [
|
2015-03-02 12:23:09 -05:00
|
|
|
benchpress.SeleniumWebDriverAdapter.PROTRACTOR_BINDINGS,
|
2015-02-17 13:32:09 -05:00
|
|
|
benchpress.bind(benchpress.Options.FORCE_GC).toValue(argv['force-gc']),
|
2015-02-11 13:13:49 -05:00
|
|
|
benchpress.bind(benchpress.Options.DEFAULT_DESCRIPTION).toValue({
|
|
|
|
'lang': options.lang,
|
|
|
|
'runId': runId
|
2015-02-20 16:32:54 -05:00
|
|
|
})
|
2015-02-11 13:13:49 -05:00
|
|
|
];
|
2015-02-17 13:32:09 -05:00
|
|
|
if (argv['benchmark']) {
|
2015-02-20 16:32:54 -05:00
|
|
|
bindings.push(benchpress.Validator.bindTo(benchpress.RegressionSlopeValidator));
|
2015-02-17 13:32:09 -05:00
|
|
|
bindings.push(benchpress.bind(benchpress.RegressionSlopeValidator.SAMPLE_SIZE).toValue(argv['sample-size']));
|
|
|
|
} else {
|
2015-02-20 16:32:54 -05:00
|
|
|
bindings.push(benchpress.Validator.bindTo(benchpress.SizeValidator));
|
2015-02-11 13:13:49 -05:00
|
|
|
bindings.push(benchpress.bind(benchpress.SizeValidator.SAMPLE_SIZE).toValue(1));
|
|
|
|
}
|
|
|
|
|
|
|
|
global.benchpressRunner = new benchpress.Runner(bindings);
|
|
|
|
}
|
2015-02-27 12:07:16 -05:00
|
|
|
|
|
|
|
function mergeInto(src, target) {
|
|
|
|
for (var prop in src) {
|
|
|
|
target[prop] = src[prop];
|
|
|
|
}
|
|
|
|
return target;
|
|
|
|
}
|