Skip to content

Commit de05d1b

Browse files
committed
build: speedup test.untit.dart by removing unneeded pub symlinks
This is an alternative to angular#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 angular#2437
1 parent 1fb9484 commit de05d1b

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

gulpfile.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,31 @@ gulp.task('build/pubspec.dart', pubget.subDir(gulp, gulpPlugins, {
208208
command: DART_SDK.PUB
209209
}));
210210

211+
212+
// This is a hacky way to work around dart's pub that creates `packages` symlink in every directory
213+
// that contains a dart file with the main method. For our tests this means that every test subfolder
214+
// has a link to the root `packages` directory which causes Karma to sift through 80k files during
215+
// each `karma run` invocation.
216+
//
217+
// Since these directories are not needed for karma tests to run, it's safe to delete them without
218+
// breaking any functionality.
219+
//
220+
// See #2437 for more info.
221+
gulp.task('!build/remove-pub-symlinks', function(done) {
222+
if (process.platform == 'win32') {
223+
done();
224+
return;
225+
}
226+
227+
exec('find dist/dart/angular2/test/ -name packages | xargs rm -r', function (error, stdout, stderr) {
228+
if (error) {
229+
done(stderr);
230+
return;
231+
}
232+
done();
233+
});
234+
});
235+
211236
// ------------
212237
// dartanalyzer
213238

@@ -480,6 +505,7 @@ gulp.task('test.unit.dart', function (done) {
480505
'build/tree.dart',
481506
'!build/pubget.angular2.dart',
482507
'!build/change_detect.dart',
508+
'!build/remove-pub-symlinks',
483509
'!test.unit.dart/karma-server',
484510
'!test.unit.dart/karma-run',
485511
function(error) {

0 commit comments

Comments
 (0)