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

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

Issue 10825422: Don't pollute repo with temp dirs for pub tests. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 4 months 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
« no previous file with comments | « utils/pub/io.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 if (!installed && 309 if (!installed &&
310 !Platform.environment.containsKey('BUILDBOT_BUILDERNAME')) { 310 !Platform.environment.containsKey('BUILDBOT_BUILDERNAME')) {
311 _abortScheduled = true; 311 _abortScheduled = true;
312 } 312 }
313 return null; 313 return null;
314 }); 314 });
315 }); 315 });
316 } 316 }
317 317
318 Future<Directory> _setUpSandbox() { 318 Future<Directory> _setUpSandbox() {
319 return createTempDir('pub-test-sandbox-'); 319 return createTempDir();
320 } 320 }
321 321
322 Future _runScheduled(Directory parentDir, List<_ScheduledEvent> scheduled) { 322 Future _runScheduled(Directory parentDir, List<_ScheduledEvent> scheduled) {
323 if (scheduled == null) return new Future.immediate(null); 323 if (scheduled == null) return new Future.immediate(null);
324 var iterator = scheduled.iterator(); 324 var iterator = scheduled.iterator();
325 325
326 Future runNextEvent([_]) { 326 Future runNextEvent([_]) {
327 if (_abortScheduled || !iterator.hasNext()) { 327 if (_abortScheduled || !iterator.hasNext()) {
328 _abortScheduled = false; 328 _abortScheduled = false;
329 scheduled.clear(); 329 scheduled.clear();
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
783 */ 783 */
784 InputStream load(List<String> path) { 784 InputStream load(List<String> path) {
785 if (!path.isEmpty()) { 785 if (!path.isEmpty()) {
786 var joinedPath = Strings.join(path, '/'); 786 var joinedPath = Strings.join(path, '/');
787 throw "Can't load $joinedPath from within $name: not a directory."; 787 throw "Can't load $joinedPath from within $name: not a directory.";
788 } 788 }
789 789
790 var sinkStream = new ListInputStream(); 790 var sinkStream = new ListInputStream();
791 var tempDir; 791 var tempDir;
792 // TODO(nweiz): propagate any errors to the return value. See issue 3657. 792 // TODO(nweiz): propagate any errors to the return value. See issue 3657.
793 createTempDir("pub-test-tmp-").chain((_tempDir) { 793 createTempDir().chain((_tempDir) {
794 tempDir = _tempDir; 794 tempDir = _tempDir;
795 return create(tempDir); 795 return create(tempDir);
796 }).then((tar) { 796 }).then((tar) {
797 var sourceStream = tar.openInputStream(); 797 var sourceStream = tar.openInputStream();
798 pipeInputToInput( 798 pipeInputToInput(
799 sourceStream, sinkStream, onClosed: tempDir.deleteRecursively); 799 sourceStream, sinkStream, onClosed: tempDir.deleteRecursively);
800 }); 800 });
801 return sinkStream; 801 return sinkStream;
802 } 802 }
803 } 803 }
804 804
805 /** 805 /**
806 * Schedules a callback to be called as part of the test case. 806 * Schedules a callback to be called as part of the test case.
807 */ 807 */
808 void _schedule(_ScheduledEvent event) { 808 void _schedule(_ScheduledEvent event) {
809 if (_scheduled == null) _scheduled = []; 809 if (_scheduled == null) _scheduled = [];
810 _scheduled.add(event); 810 _scheduled.add(event);
811 } 811 }
812 812
813 /** 813 /**
814 * Schedules a callback to be called after Pub is run with [runPub], even if it 814 * Schedules a callback to be called after Pub is run with [runPub], even if it
815 * fails. 815 * fails.
816 */ 816 */
817 void _scheduleCleanup(_ScheduledEvent event) { 817 void _scheduleCleanup(_ScheduledEvent event) {
818 if (_scheduledCleanup == null) _scheduledCleanup = []; 818 if (_scheduledCleanup == null) _scheduledCleanup = [];
819 _scheduledCleanup.add(event); 819 _scheduledCleanup.add(event);
820 } 820 }
OLDNEW
« no previous file with comments | « utils/pub/io.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698