fix(e2e): fix race condition
This commit is contained in:
parent
76abf7bebd
commit
3ec0e7147b
88
gulpfile.js
88
gulpfile.js
|
@ -69,12 +69,12 @@ var _excludeMatchers = _excludePatterns.map(function(excludePattern){
|
||||||
});
|
});
|
||||||
|
|
||||||
var _exampleBoilerplateFiles = [
|
var _exampleBoilerplateFiles = [
|
||||||
'karma.conf.js',
|
'karma.conf.js',
|
||||||
'karma-test-shim.js',
|
'karma-test-shim.js',
|
||||||
'package.json',
|
'package.json',
|
||||||
'styles.css',
|
'styles.css',
|
||||||
'tsconfig.json',
|
'tsconfig.json',
|
||||||
'typings.json'
|
'typings.json'
|
||||||
];
|
];
|
||||||
|
|
||||||
var _exampleDartWebBoilerPlateFiles = ['styles.css'];
|
var _exampleDartWebBoilerPlateFiles = ['styles.css'];
|
||||||
|
@ -153,14 +153,17 @@ function findAndRunE2eTests(filter) {
|
||||||
// to the outputFile.
|
// to the outputFile.
|
||||||
function runE2eTests(appDir, protractorConfigFilename, outputFile ) {
|
function runE2eTests(appDir, protractorConfigFilename, outputFile ) {
|
||||||
// start the app
|
// start the app
|
||||||
var appRunSpawnInfo = spawnExt('npm',['run','http-server', '--', '-s' ], { cwd: appDir });
|
var appRunSpawnInfo = spawnExt('npm',['run','http-server:e2e', '--', '-s' ], { cwd: appDir });
|
||||||
|
var tscRunSpawnInfo = spawnExt('npm',['run','tsc'], { cwd: appDir });
|
||||||
|
|
||||||
// start protractor
|
return tscRunSpawnInfo.promise.then(function(data) {
|
||||||
var pcFilename = path.resolve(protractorConfigFilename); // need to resolve because we are going to be running from a different dir
|
// start protractor
|
||||||
var exePath = path.join(process.cwd(), "./node_modules/.bin/");
|
var pcFilename = path.resolve(protractorConfigFilename); // need to resolve because we are going to be running from a different dir
|
||||||
var spawnInfo = spawnExt('protractor',
|
var exePath = path.join(process.cwd(), "./node_modules/.bin/");
|
||||||
[ pcFilename, '--params.appDir=' + appDir, '--params.outputFile=' + outputFile], { cwd: exePath });
|
var spawnInfo = spawnExt('protractor',
|
||||||
return spawnInfo.promise.then(function(data) {
|
[ pcFilename, '--params.appDir=' + appDir, '--params.outputFile=' + outputFile], { cwd: exePath });
|
||||||
|
return spawnInfo.promise;
|
||||||
|
}).then(function(data) {
|
||||||
// kill the app now that protractor has completed.
|
// kill the app now that protractor has completed.
|
||||||
// Ugh... proc.kill does not work properly on windows with child processes.
|
// Ugh... proc.kill does not work properly on windows with child processes.
|
||||||
// appRun.proc.kill();
|
// appRun.proc.kill();
|
||||||
|
@ -243,14 +246,14 @@ gulp.task('add-example-boilerplate', function() {
|
||||||
gutil.log("symlinking " + linkPath + ' -> ' + realPath)
|
gutil.log("symlinking " + linkPath + ' -> ' + realPath)
|
||||||
fsUtils.addSymlink(realPath, linkPath);
|
fsUtils.addSymlink(realPath, linkPath);
|
||||||
});
|
});
|
||||||
|
|
||||||
realPath = path.join(EXAMPLES_PATH, '/typings');
|
realPath = path.join(EXAMPLES_PATH, '/typings');
|
||||||
var typingsPaths = getTypingsPaths(EXAMPLES_PATH);
|
var typingsPaths = getTypingsPaths(EXAMPLES_PATH);
|
||||||
typingsPaths.forEach(function(linkPath) {
|
typingsPaths.forEach(function(linkPath) {
|
||||||
gutil.log("symlinking " + linkPath + ' -> ' + realPath)
|
gutil.log("symlinking " + linkPath + ' -> ' + realPath)
|
||||||
fsUtils.addSymlink(realPath, linkPath);
|
fsUtils.addSymlink(realPath, linkPath);
|
||||||
});
|
});
|
||||||
|
|
||||||
return copyExampleBoilerplate();
|
return copyExampleBoilerplate();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -263,7 +266,7 @@ function copyExampleBoilerplate() {
|
||||||
return path.join(EXAMPLES_PATH, fn);
|
return path.join(EXAMPLES_PATH, fn);
|
||||||
});
|
});
|
||||||
var examplePaths = getExamplePaths(EXAMPLES_PATH);
|
var examplePaths = getExamplePaths(EXAMPLES_PATH);
|
||||||
|
|
||||||
var dartWebSourceFiles = _exampleDartWebBoilerPlateFiles.map(function(fn){
|
var dartWebSourceFiles = _exampleDartWebBoilerPlateFiles.map(function(fn){
|
||||||
return path.join(EXAMPLES_PATH, fn);
|
return path.join(EXAMPLES_PATH, fn);
|
||||||
});
|
});
|
||||||
|
@ -287,15 +290,15 @@ gulp.task('remove-example-boilerplate', function() {
|
||||||
nodeModulesPaths.forEach(function(linkPath) {
|
nodeModulesPaths.forEach(function(linkPath) {
|
||||||
fsUtils.removeSymlink(linkPath);
|
fsUtils.removeSymlink(linkPath);
|
||||||
});
|
});
|
||||||
|
|
||||||
var typingsPaths = getTypingsPaths(EXAMPLES_PATH);
|
var typingsPaths = getTypingsPaths(EXAMPLES_PATH);
|
||||||
typingsPaths.forEach(function(linkPath) {
|
typingsPaths.forEach(function(linkPath) {
|
||||||
fsUtils.removeSymlink(linkPath);
|
fsUtils.removeSymlink(linkPath);
|
||||||
});
|
});
|
||||||
|
|
||||||
var examplePaths = getExamplePaths(EXAMPLES_PATH);
|
var examplePaths = getExamplePaths(EXAMPLES_PATH);
|
||||||
var dartExampleWebPaths = getDartExampleWebPaths(EXAMPLES_PATH);
|
var dartExampleWebPaths = getDartExampleWebPaths(EXAMPLES_PATH);
|
||||||
|
|
||||||
return deleteFiles(_exampleBoilerplateFiles, examplePaths)
|
return deleteFiles(_exampleBoilerplateFiles, examplePaths)
|
||||||
.then(function() {
|
.then(function() {
|
||||||
return deleteFiles(_exampleDartWebBoilerPlateFiles, dartExampleWebPaths);
|
return deleteFiles(_exampleDartWebBoilerPlateFiles, dartExampleWebPaths);
|
||||||
|
@ -346,7 +349,7 @@ gulp.task('build-js-api-docs', ['_shred-api-examples'], function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('build-plunkers', function() {
|
gulp.task('build-plunkers', function() {
|
||||||
return copyExampleBoilerplate()
|
return copyExampleBoilerplate()
|
||||||
.then(function() {
|
.then(function() {
|
||||||
return plunkerBuilder.buildPlunkers(EXAMPLES_PATH, LIVE_EXAMPLES_PATH, { errFn: gutil.log });
|
return plunkerBuilder.buildPlunkers(EXAMPLES_PATH, LIVE_EXAMPLES_PATH, { errFn: gutil.log });
|
||||||
});
|
});
|
||||||
|
@ -501,7 +504,7 @@ function harpCompile() {
|
||||||
vars: { NODE_ENV: "production" }
|
vars: { NODE_ENV: "production" }
|
||||||
});
|
});
|
||||||
gutil.log("NODE_ENV: " + process.env.NODE_ENV);
|
gutil.log("NODE_ENV: " + process.env.NODE_ENV);
|
||||||
|
|
||||||
var deferred = Q.defer();
|
var deferred = Q.defer();
|
||||||
gutil.log('running harp compile...');
|
gutil.log('running harp compile...');
|
||||||
showHideExampleNodeModules('hide');
|
showHideExampleNodeModules('hide');
|
||||||
|
@ -523,20 +526,20 @@ function harpCompile() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function linkChecker(options) {
|
function linkChecker(options) {
|
||||||
var deferred = Q.defer();
|
var deferred = Q.defer();
|
||||||
var options = options || {};
|
var options = options || {};
|
||||||
|
|
||||||
var blcOptions = options.blcOptions || {};
|
var blcOptions = options.blcOptions || {};
|
||||||
var customData = options.customData || {};
|
var customData = options.customData || {};
|
||||||
|
|
||||||
var excludeBad; // don't bother reporting bad links matching this RegExp
|
var excludeBad; // don't bother reporting bad links matching this RegExp
|
||||||
if (argv.excludeBad) {
|
if (argv.excludeBad) {
|
||||||
excludeBad = new RegExp(argv.excludeBad);
|
excludeBad = new RegExp(argv.excludeBad);
|
||||||
} else {
|
} else {
|
||||||
excludeBad = options.excludeBad === undefined ? /docs\/dart\/latest\/api/ : '';
|
excludeBad = options.excludeBad === undefined ? /docs\/dart\/latest\/api/ : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
var previousPage;
|
var previousPage;
|
||||||
var siteUrl = argv.url || options.url || 'https://angular.io/';
|
var siteUrl = argv.url || options.url || 'https://angular.io/';
|
||||||
|
|
||||||
// See https://github.com/stevenvachon/broken-link-checker#blcsitecheckeroptions-handlers
|
// See https://github.com/stevenvachon/broken-link-checker#blcsitecheckeroptions-handlers
|
||||||
|
@ -546,12 +549,12 @@ function linkChecker(options) {
|
||||||
//gutil.log('Scanning ' + pageUrl);docs/ts/latest/api/core/
|
//gutil.log('Scanning ' + pageUrl);docs/ts/latest/api/core/
|
||||||
},
|
},
|
||||||
junk: function(result, customData){},
|
junk: function(result, customData){},
|
||||||
|
|
||||||
// Analyze links
|
// Analyze links
|
||||||
link: function(result, customData){
|
link: function(result, customData){
|
||||||
if (!result.broken) { return; }
|
if (!result.broken) { return; }
|
||||||
if (excludeBad && excludeBad.test(result.url.resolved)) { return; }
|
if (excludeBad && excludeBad.test(result.url.resolved)) { return; }
|
||||||
|
|
||||||
var currentPage = result.base.resolved
|
var currentPage = result.base.resolved
|
||||||
if (previousPage !== currentPage) {
|
if (previousPage !== currentPage) {
|
||||||
previousPage = currentPage;
|
previousPage = currentPage;
|
||||||
|
@ -563,10 +566,10 @@ function linkChecker(options) {
|
||||||
//gutil.log(msg);
|
//gutil.log(msg);
|
||||||
//gutil.log(result);
|
//gutil.log(result);
|
||||||
},
|
},
|
||||||
|
|
||||||
page: function(error, pageUrl, customData){},
|
page: function(error, pageUrl, customData){},
|
||||||
site: function(error, siteUrl, customData){},
|
site: function(error, siteUrl, customData){},
|
||||||
|
|
||||||
end: function(){
|
end: function(){
|
||||||
var stopTime = new Date().getTime();
|
var stopTime = new Date().getTime();
|
||||||
var elapsed = 'Elapsed link-checking time: ' + ((stopTime - startTime)/1000) + ' seconds';
|
var elapsed = 'Elapsed link-checking time: ' + ((stopTime - startTime)/1000) + ' seconds';
|
||||||
|
@ -576,24 +579,24 @@ function linkChecker(options) {
|
||||||
deferred.resolve(true);
|
deferred.resolve(true);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// create an output file with header.
|
// create an output file with header.
|
||||||
var outputFile = path.join(process.cwd(), 'link-checker-results.txt');
|
var outputFile = path.join(process.cwd(), 'link-checker-results.txt');
|
||||||
var header = 'Link checker results for: ' + siteUrl +
|
var header = 'Link checker results for: ' + siteUrl +
|
||||||
'\nStarted: ' + (new Date()).toLocaleString() +
|
'\nStarted: ' + (new Date()).toLocaleString() +
|
||||||
'\nSkipping bad links matching regex: ' +excludeBad.toString() + '\n\n';
|
'\nSkipping bad links matching regex: ' +excludeBad.toString() + '\n\n';
|
||||||
gutil.log(header);
|
gutil.log(header);
|
||||||
fs.writeFileSync(outputFile, header);
|
fs.writeFileSync(outputFile, header);
|
||||||
|
|
||||||
var siteChecker = new blc.SiteChecker(blcOptions, handlers);
|
var siteChecker = new blc.SiteChecker(blcOptions, handlers);
|
||||||
var startTime = new Date().getTime();
|
var startTime = new Date().getTime();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
siteChecker.enqueue(siteUrl, customData);
|
siteChecker.enqueue(siteUrl, customData);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
deferred.reject(err);
|
deferred.reject(err);
|
||||||
}
|
}
|
||||||
return deferred.promise;
|
return deferred.promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
// harp has issues with node_modules under the public dir
|
// harp has issues with node_modules under the public dir
|
||||||
|
@ -701,7 +704,7 @@ function watchAndSync(options, cb) {
|
||||||
env({
|
env({
|
||||||
vars: { NODE_ENV: "production" }
|
vars: { NODE_ENV: "production" }
|
||||||
});
|
});
|
||||||
|
|
||||||
execCommands(['npm run harp -- server .'], {}, cb);
|
execCommands(['npm run harp -- server .'], {}, cb);
|
||||||
|
|
||||||
var browserSync = require('browser-sync').create();
|
var browserSync = require('browser-sync').create();
|
||||||
|
@ -781,7 +784,7 @@ function apiExamplesWatch(postShredAction) {
|
||||||
|
|
||||||
function devGuideExamplesWatch(shredOptions, postShredAction) {
|
function devGuideExamplesWatch(shredOptions, postShredAction) {
|
||||||
var includePattern = path.join(shredOptions.examplesDir, '**/*.*');
|
var includePattern = path.join(shredOptions.examplesDir, '**/*.*');
|
||||||
// removed this version because gulp.watch has the same glob issue that dgeni has.
|
// removed this version because gulp.watch has the same glob issue that dgeni has.
|
||||||
// var excludePattern = '!' + path.join(shredOptions.examplesDir, '**/node_modules/**/*.*');
|
// var excludePattern = '!' + path.join(shredOptions.examplesDir, '**/node_modules/**/*.*');
|
||||||
// gulp.watch([includePattern, excludePattern], {readDelay: 500}, function (event, done) {
|
// gulp.watch([includePattern, excludePattern], {readDelay: 500}, function (event, done) {
|
||||||
var files = globby.sync( [includePattern], { ignore: [ '**/node_modules/**', '**/_fragments/**']});
|
var files = globby.sync( [includePattern], { ignore: [ '**/node_modules/**', '**/_fragments/**']});
|
||||||
|
@ -989,7 +992,7 @@ function execCommands(cmds, options, cb) {
|
||||||
if (!cmds || cmds.length == 0) cb(null, null, null);
|
if (!cmds || cmds.length == 0) cb(null, null, null);
|
||||||
var exec = require('child_process').exec; // just to make it more portable.
|
var exec = require('child_process').exec; // just to make it more portable.
|
||||||
gutil.log("NODE_ENV: " + process.env.NODE_ENV);
|
gutil.log("NODE_ENV: " + process.env.NODE_ENV);
|
||||||
|
|
||||||
exec(cmds[0], options, function(err, stdout, stderr) {
|
exec(cmds[0], options, function(err, stdout, stderr) {
|
||||||
if (err == null) {
|
if (err == null) {
|
||||||
if (options.shouldLog) {
|
if (options.shouldLog) {
|
||||||
|
@ -1019,4 +1022,3 @@ function checkAngularProjectPath() {
|
||||||
throw new Error('API related tasks require the angular2 repo to be at ' + path.resolve(ANGULAR_PROJECT_PATH));
|
throw new Error('API related tasks require the angular2 repo to be at ' + path.resolve(ANGULAR_PROJECT_PATH));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
"test": "karma start karma.conf.js",
|
"test": "karma start karma.conf.js",
|
||||||
"build-and-test": "npm run tsc && npm run test",
|
"build-and-test": "npm run tsc && npm run test",
|
||||||
"http-server": "tsc && http-server",
|
"http-server": "tsc && http-server",
|
||||||
|
"http-server:e2e": "http-server",
|
||||||
"typings": "typings",
|
"typings": "typings",
|
||||||
"postinstall": "typings install"
|
"postinstall": "typings install"
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue