Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(202)

Side by Side Diff: utils/tests/pub/test_pub.dart

Issue 11412086: Make 'where' lazy. (Closed) Base URL: https://dart.googlecode.com/svn/experimental/lib_v2/dart
Patch Set: FilteredIterable/Iterator -> WhereIterable/Iterator. Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /** 5 /**
6 * Test infrastructure for testing pub. Unlike typical unit tests, most pub 6 * Test infrastructure for testing pub. Unlike typical unit tests, most pub
7 * tests are integration tests that stage some stuff on the file system, run 7 * tests are integration tests that stage some stuff on the file system, run
8 * pub, and then validate the results. This library provides an API to build 8 * pub, and then validate the results. This library provides an API to build
9 * tests like that. 9 * tests like that.
10 */ 10 */
(...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after
776 // Special-case strings to support multi-level names like "myapp/packages". 776 // Special-case strings to support multi-level names like "myapp/packages".
777 if (name is String) { 777 if (name is String) {
778 var path = join(dir, name); 778 var path = join(dir, name);
779 return exists(path).chain((exists) { 779 return exists(path).chain((exists) {
780 if (!exists) Expect.fail('File $name in $dir not found.'); 780 if (!exists) Expect.fail('File $name in $dir not found.');
781 return validate(path); 781 return validate(path);
782 }); 782 });
783 } 783 }
784 784
785 return listDir(dir).chain((files) { 785 return listDir(dir).chain((files) {
786 var matches = files.where((file) => endsWithPattern(file, name)); 786 var matches = files.where((file) => endsWithPattern(file, name)).toList();
787 if (matches.length == 0) { 787 if (matches.isEmpty) {
788 Expect.fail('No files in $dir match pattern $name.'); 788 Expect.fail('No files in $dir match pattern $name.');
789 } 789 }
790 if (matches.length == 1) return validate(matches[0]); 790 if (matches.length == 1) return validate(matches[0]);
791 791
792 var failures = []; 792 var failures = [];
793 var successes = 0; 793 var successes = 0;
794 var completer = new Completer(); 794 var completer = new Completer();
795 checkComplete() { 795 checkComplete() {
796 if (failures.length + successes != matches.length) return; 796 if (failures.length + successes != matches.length) return;
797 if (successes > 0) { 797 if (successes > 0) {
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
1228 } 1228 }
1229 1229
1230 /** 1230 /**
1231 * Schedules a callback to be called after Pub is run with [runPub], even if it 1231 * Schedules a callback to be called after Pub is run with [runPub], even if it
1232 * fails. 1232 * fails.
1233 */ 1233 */
1234 void _scheduleCleanup(_ScheduledEvent event) { 1234 void _scheduleCleanup(_ScheduledEvent event) {
1235 if (_scheduledCleanup == null) _scheduledCleanup = []; 1235 if (_scheduledCleanup == null) _scheduledCleanup = [];
1236 _scheduledCleanup.add(event); 1236 _scheduledCleanup.add(event);
1237 } 1237 }
OLDNEW
« runtime/lib/growable_array.dart ('K') | « tests/html/xmlelement_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698