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

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

Issue 11348288: Get archive creation working on Windows. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebase. Created 8 years 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/tests/pub/pub.status ('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 649 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 return isGitInstalled.transform((installed) { 660 return isGitInstalled.transform((installed) {
661 if (!installed && 661 if (!installed &&
662 !Platform.environment.containsKey('BUILDBOT_BUILDERNAME')) { 662 !Platform.environment.containsKey('BUILDBOT_BUILDERNAME')) {
663 _abortScheduled = true; 663 _abortScheduled = true;
664 } 664 }
665 return null; 665 return null;
666 }); 666 });
667 }); 667 });
668 } 668 }
669 669
670 Future<Directory> _setUpSandbox() { 670 Future<Directory> _setUpSandbox() => createTempDir();
671 return createTempDir();
672 }
673 671
674 Future _runScheduled(Directory parentDir, List<_ScheduledEvent> scheduled) { 672 Future _runScheduled(Directory parentDir, List<_ScheduledEvent> scheduled) {
675 if (scheduled == null) return new Future.immediate(null); 673 if (scheduled == null) return new Future.immediate(null);
676 var iterator = scheduled.iterator(); 674 var iterator = scheduled.iterator();
677 675
678 Future runNextEvent(_) { 676 Future runNextEvent(_) {
679 if (_abortScheduled || !iterator.hasNext) { 677 if (_abortScheduled || !iterator.hasNext) {
680 _abortScheduled = false; 678 _abortScheduled = false;
681 scheduled.clear(); 679 scheduled.clear();
682 return new Future.immediate(null); 680 return new Future.immediate(null);
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
1147 final List<Descriptor> contents; 1145 final List<Descriptor> contents;
1148 1146
1149 TarFileDescriptor(Pattern name, this.contents) 1147 TarFileDescriptor(Pattern name, this.contents)
1150 : super(name); 1148 : super(name);
1151 1149
1152 /** 1150 /**
1153 * Creates the files and directories within this tar file, then archives them, 1151 * Creates the files and directories within this tar file, then archives them,
1154 * compresses them, and saves the result to [parentDir]. 1152 * compresses them, and saves the result to [parentDir].
1155 */ 1153 */
1156 Future<File> create(parentDir) { 1154 Future<File> create(parentDir) {
1155 // TODO(rnystrom): Use withTempDir().
1157 var tempDir; 1156 var tempDir;
1158 return parentDir.createTemp().chain((_tempDir) { 1157 return createTempDir().chain((_tempDir) {
1159 tempDir = _tempDir; 1158 tempDir = _tempDir;
1160 return Futures.wait(contents.map((child) => child.create(tempDir))); 1159 return Futures.wait(contents.map((child) => child.create(tempDir)));
1161 }).chain((createdContents) { 1160 }).chain((createdContents) {
1162 return consumeInputStream(createTarGz(createdContents, baseDir: tempDir)); 1161 return consumeInputStream(createTarGz(createdContents, baseDir: tempDir));
1163 }).chain((bytes) { 1162 }).chain((bytes) {
1164 return new File(join(parentDir, _stringName)).writeAsBytes(bytes); 1163 return new File(join(parentDir, _stringName)).writeAsBytes(bytes);
1165 }).chain((file) { 1164 }).chain((file) {
1166 return deleteDir(tempDir).transform((_) => file); 1165 return deleteDir(tempDir).transform((_) => file);
1167 }); 1166 });
1168 } 1167 }
(...skipping 13 matching lines...) Expand all
1182 * Loads the contents of this tar file. 1181 * Loads the contents of this tar file.
1183 */ 1182 */
1184 InputStream load(List<String> path) { 1183 InputStream load(List<String> path) {
1185 if (!path.isEmpty) { 1184 if (!path.isEmpty) {
1186 var joinedPath = Strings.join(path, '/'); 1185 var joinedPath = Strings.join(path, '/');
1187 throw "Can't load $joinedPath from within $name: not a directory."; 1186 throw "Can't load $joinedPath from within $name: not a directory.";
1188 } 1187 }
1189 1188
1190 var sinkStream = new ListInputStream(); 1189 var sinkStream = new ListInputStream();
1191 var tempDir; 1190 var tempDir;
1191 // TODO(rnystrom): Use withTempDir() here.
1192 // TODO(nweiz): propagate any errors to the return value. See issue 3657. 1192 // TODO(nweiz): propagate any errors to the return value. See issue 3657.
1193 createTempDir().chain((_tempDir) { 1193 createTempDir().chain((_tempDir) {
1194 tempDir = _tempDir; 1194 tempDir = _tempDir;
1195 return create(tempDir); 1195 return create(tempDir);
1196 }).then((tar) { 1196 }).then((tar) {
1197 var sourceStream = tar.openInputStream(); 1197 var sourceStream = tar.openInputStream();
1198 pipeInputToInput(sourceStream, 1198 pipeInputToInput(sourceStream, sinkStream).then((_) {
1199 sinkStream, 1199 tempDir.delete(recursive: true);
1200 () => tempDir.delete(recursive: true)); 1200 });
1201 }); 1201 });
1202 return sinkStream; 1202 return sinkStream;
1203 } 1203 }
1204 } 1204 }
1205 1205
1206 /** 1206 /**
1207 * A descriptor that validates that no file exists with the given name. 1207 * A descriptor that validates that no file exists with the given name.
1208 */ 1208 */
1209 class NothingDescriptor extends Descriptor { 1209 class NothingDescriptor extends Descriptor {
1210 NothingDescriptor(String name) : super(name); 1210 NothingDescriptor(String name) : super(name);
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
1528 /// calling [completion] is unnecessary. 1528 /// calling [completion] is unnecessary.
1529 void expectLater(Future actual, matcher, {String reason, 1529 void expectLater(Future actual, matcher, {String reason,
1530 FailureHandler failureHandler, bool verbose: false}) { 1530 FailureHandler failureHandler, bool verbose: false}) {
1531 _schedule((_) { 1531 _schedule((_) {
1532 return actual.transform((value) { 1532 return actual.transform((value) {
1533 expect(value, matcher, reason: reason, failureHandler: failureHandler, 1533 expect(value, matcher, reason: reason, failureHandler: failureHandler,
1534 verbose: false); 1534 verbose: false);
1535 }); 1535 });
1536 }); 1536 });
1537 } 1537 }
OLDNEW
« no previous file with comments | « utils/tests/pub/pub.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698