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

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

Issue 11363249: Fix error reporting on invalid command line args. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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
« no previous file with comments | « utils/tests/pub/pub_test.dart ('k') | utils/tests/pub/version_solver_test.dart » ('j') | 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 702 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 * directory is going to be created. 713 * directory is going to be created.
714 */ 714 */
715 final Pattern name; 715 final Pattern name;
716 716
717 Descriptor(this.name); 717 Descriptor(this.name);
718 718
719 /** 719 /**
720 * Creates the file or directory within [dir]. Returns a [Future] that is 720 * Creates the file or directory within [dir]. Returns a [Future] that is
721 * completed after the creation is done. 721 * completed after the creation is done.
722 */ 722 */
723 abstract Future create(dir); 723 Future create(dir);
724 724
725 /** 725 /**
726 * Validates that this descriptor correctly matches the corresponding file 726 * Validates that this descriptor correctly matches the corresponding file
727 * system entry within [dir]. Returns a [Future] that completes to `null` if 727 * system entry within [dir]. Returns a [Future] that completes to `null` if
728 * the entry is valid, or throws an error if it failed. 728 * the entry is valid, or throws an error if it failed.
729 */ 729 */
730 abstract Future validate(String dir); 730 Future validate(String dir);
731 731
732 /** 732 /**
733 * Deletes the file or directory within [dir]. Returns a [Future] that is 733 * Deletes the file or directory within [dir]. Returns a [Future] that is
734 * completed after the deletion is done. 734 * completed after the deletion is done.
735 */ 735 */
736 abstract Future delete(String dir); 736 Future delete(String dir);
737 737
738 /** 738 /**
739 * Loads the file at [path] from within this descriptor. If [path] is empty, 739 * Loads the file at [path] from within this descriptor. If [path] is empty,
740 * loads the contents of the descriptor itself. 740 * loads the contents of the descriptor itself.
741 */ 741 */
742 abstract InputStream load(List<String> path); 742 InputStream load(List<String> path);
743 743
744 /** 744 /**
745 * Schedules the directory to be created before Pub is run with [runPub]. The 745 * Schedules the directory to be created before Pub is run with [runPub]. The
746 * directory will be created relative to the sandbox directory. 746 * directory will be created relative to the sandbox directory.
747 */ 747 */
748 // TODO(nweiz): Use implicit closurization once issue 2984 is fixed. 748 // TODO(nweiz): Use implicit closurization once issue 2984 is fixed.
749 void scheduleCreate() => _schedule((dir) => this.create(dir)); 749 void scheduleCreate() => _schedule((dir) => this.create(dir));
750 750
751 /** 751 /**
752 * Schedules the file or directory to be deleted recursively. 752 * Schedules the file or directory to be deleted recursively.
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
1152 var sinkStream = new ListInputStream(); 1152 var sinkStream = new ListInputStream();
1153 var tempDir; 1153 var tempDir;
1154 // TODO(nweiz): propagate any errors to the return value. See issue 3657. 1154 // TODO(nweiz): propagate any errors to the return value. See issue 3657.
1155 createTempDir().chain((_tempDir) { 1155 createTempDir().chain((_tempDir) {
1156 tempDir = _tempDir; 1156 tempDir = _tempDir;
1157 return create(tempDir); 1157 return create(tempDir);
1158 }).then((tar) { 1158 }).then((tar) {
1159 var sourceStream = tar.openInputStream(); 1159 var sourceStream = tar.openInputStream();
1160 pipeInputToInput(sourceStream, 1160 pipeInputToInput(sourceStream,
1161 sinkStream, 1161 sinkStream,
1162 () => tempDir.delete(recursive: true)); 1162 () => tempDir.deleteRecursively());
1163 }); 1163 });
1164 return sinkStream; 1164 return sinkStream;
1165 } 1165 }
1166 } 1166 }
1167 1167
1168 /** 1168 /**
1169 * A descriptor that validates that no file exists with the given name. 1169 * A descriptor that validates that no file exists with the given name.
1170 */ 1170 */
1171 class NothingDescriptor extends Descriptor { 1171 class NothingDescriptor extends Descriptor {
1172 NothingDescriptor(String name) : super(name); 1172 NothingDescriptor(String name) : super(name);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1224 } 1224 }
1225 1225
1226 /** 1226 /**
1227 * Schedules a callback to be called after Pub is run with [runPub], even if it 1227 * Schedules a callback to be called after Pub is run with [runPub], even if it
1228 * fails. 1228 * fails.
1229 */ 1229 */
1230 void _scheduleCleanup(_ScheduledEvent event) { 1230 void _scheduleCleanup(_ScheduledEvent event) {
1231 if (_scheduledCleanup == null) _scheduledCleanup = []; 1231 if (_scheduledCleanup == null) _scheduledCleanup = [];
1232 _scheduledCleanup.add(event); 1232 _scheduledCleanup.add(event);
1233 } 1233 }
OLDNEW
« no previous file with comments | « utils/tests/pub/pub_test.dart ('k') | utils/tests/pub/version_solver_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698