From de05d1bf46f1d69499cb8447daf0f213e5215190 Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Tue, 30 Jun 2015 21:37:14 -0700 Subject: [PATCH] build: speedup test.untit.dart by removing unneeded pub symlinks This is an alternative to #2778. All of the symlinks to packages directory within the test directory are not needed for running tests, so we can safely remove them. This removes 80k files from the test directory which significantly speeds up Karma. Closes #2437 --- gulpfile.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/gulpfile.js b/gulpfile.js index 4af66b12a9..5d35df378e 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -208,6 +208,31 @@ gulp.task('build/pubspec.dart', pubget.subDir(gulp, gulpPlugins, { command: DART_SDK.PUB })); + +// This is a hacky way to work around dart's pub that creates `packages` symlink in every directory +// that contains a dart file with the main method. For our tests this means that every test subfolder +// has a link to the root `packages` directory which causes Karma to sift through 80k files during +// each `karma run` invocation. +// +// Since these directories are not needed for karma tests to run, it's safe to delete them without +// breaking any functionality. +// +// See #2437 for more info. +gulp.task('!build/remove-pub-symlinks', function(done) { + if (process.platform == 'win32') { + done(); + return; + } + + exec('find dist/dart/angular2/test/ -name packages | xargs rm -r', function (error, stdout, stderr) { + if (error) { + done(stderr); + return; + } + done(); + }); +}); + // ------------ // dartanalyzer @@ -480,6 +505,7 @@ gulp.task('test.unit.dart', function (done) { 'build/tree.dart', '!build/pubget.angular2.dart', '!build/change_detect.dart', + '!build/remove-pub-symlinks', '!test.unit.dart/karma-server', '!test.unit.dart/karma-run', function(error) {