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

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

Issue 12036065: Make pub use the SDK's "version" file for its version. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Comment regex. Created 7 years, 11 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/tests/pub/real_version_test.dart ('k') | utils/tests/pub/update/pub_update_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 /// Test infrastructure for testing pub. Unlike typical unit tests, most pub 5 /// Test infrastructure for testing pub. Unlike typical unit tests, most pub
6 /// tests are integration tests that stage some stuff on the file system, run 6 /// tests are integration tests that stage some stuff on the file system, run
7 /// pub, and then validate the results. This library provides an API to build 7 /// pub, and then validate the results. This library provides an API to build
8 /// tests like that. 8 /// tests like that.
9 library test_pub; 9 library test_pub;
10 10
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 final String sdkPath = "sdk"; 425 final String sdkPath = "sdk";
426 426
427 /// The path of the mock app directory used for tests. Relative to the sandbox 427 /// The path of the mock app directory used for tests. Relative to the sandbox
428 /// directory. 428 /// directory.
429 final String appPath = "myapp"; 429 final String appPath = "myapp";
430 430
431 /// The path of the packages directory in the mock app used for tests. Relative 431 /// The path of the packages directory in the mock app used for tests. Relative
432 /// to the sandbox directory. 432 /// to the sandbox directory.
433 final String packagesPath = "$appPath/packages"; 433 final String packagesPath = "$appPath/packages";
434 434
435 /// The type for callbacks that will be fired during [runPub]. Takes the 435 /// The type for callbacks that will be fired during [schedulePub]. Takes the
436 /// sandbox directory as a parameter. 436 /// sandbox directory as a parameter.
437 typedef Future _ScheduledEvent(Directory parentDir); 437 typedef Future _ScheduledEvent(Directory parentDir);
438 438
439 /// The list of events that are scheduled to run as part of the test case. 439 /// The list of events that are scheduled to run as part of the test case.
440 List<_ScheduledEvent> _scheduled; 440 List<_ScheduledEvent> _scheduled;
441 441
442 /// The list of events that are scheduled to run after the test case, even if 442 /// The list of events that are scheduled to run after the test case, even if
443 /// it failed. 443 /// it failed.
444 List<_ScheduledEvent> _scheduledCleanup; 444 List<_ScheduledEvent> _scheduledCleanup;
445 445
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 } 531 }
532 532
533 throw new ExpectException(Strings.join(failures, '\n')); 533 throw new ExpectException(Strings.join(failures, '\n'));
534 } 534 }
535 535
536 return null; 536 return null;
537 }); 537 });
538 }); 538 });
539 } 539 }
540 540
541 /// A shorthand for [schedulePub] and [run] when no validation needs to be done
542 /// after Pub has been run.
543 ///
544 /// Any futures in [args] will be resolved before the process is started.
545 void runPub({List args, Pattern output, Pattern error, int exitCode: 0}) {
546 schedulePub(args: args, output: output, error: error, exitCode: exitCode);
547 _run();
548 }
549
550 /// Starts a Pub process and returns a [ScheduledProcess] that supports 541 /// Starts a Pub process and returns a [ScheduledProcess] that supports
551 /// interaction with that process. 542 /// interaction with that process.
552 /// 543 ///
553 /// Any futures in [args] will be resolved before the process is started. 544 /// Any futures in [args] will be resolved before the process is started.
554 ScheduledProcess startPub({List args, Future<Uri> tokenEndpoint}) { 545 ScheduledProcess startPub({List args, Future<Uri> tokenEndpoint}) {
555 var process = _scheduleValue((sandboxDir) => 546 var process = _scheduleValue((sandboxDir) =>
556 _doPub(startProcess, sandboxDir, args, tokenEndpoint)); 547 _doPub(startProcess, sandboxDir, args, tokenEndpoint));
557 return new ScheduledProcess("pub", process); 548 return new ScheduledProcess("pub", process);
558 } 549 }
559 550
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
779 Future validate(String dir); 770 Future validate(String dir);
780 771
781 /// Deletes the file or directory within [dir]. Returns a [Future] that is 772 /// Deletes the file or directory within [dir]. Returns a [Future] that is
782 /// completed after the deletion is done. 773 /// completed after the deletion is done.
783 Future delete(String dir); 774 Future delete(String dir);
784 775
785 /// Loads the file at [path] from within this descriptor. If [path] is empty, 776 /// Loads the file at [path] from within this descriptor. If [path] is empty,
786 /// loads the contents of the descriptor itself. 777 /// loads the contents of the descriptor itself.
787 InputStream load(List<String> path); 778 InputStream load(List<String> path);
788 779
789 /// Schedules the directory to be created before Pub is run with [runPub]. 780 /// Schedules the directory to be created before Pub is run with
790 /// The directory will be created relative to the sandbox directory. 781 /// [schedulePub]. The directory will be created relative to the sandbox
782 /// directory.
791 // TODO(nweiz): Use implicit closurization once issue 2984 is fixed. 783 // TODO(nweiz): Use implicit closurization once issue 2984 is fixed.
792 void scheduleCreate() => _schedule((dir) => this.create(dir)); 784 void scheduleCreate() => _schedule((dir) => this.create(dir));
793 785
794 /// Schedules the file or directory to be deleted recursively. 786 /// Schedules the file or directory to be deleted recursively.
795 void scheduleDelete() => _schedule((dir) => this.delete(dir)); 787 void scheduleDelete() => _schedule((dir) => this.delete(dir));
796 788
797 /// Schedules the directory to be validated after Pub is run with [runPub]. 789 /// Schedules the directory to be validated after Pub is run with
798 /// The directory will be validated relative to the sandbox directory. 790 /// [schedulePub]. The directory will be validated relative to the sandbox
791 /// directory.
799 void scheduleValidate() => _schedule((parentDir) => validate(parentDir.path)); 792 void scheduleValidate() => _schedule((parentDir) => validate(parentDir.path));
800 793
801 /// Asserts that the name of the descriptor is a [String] and returns it. 794 /// Asserts that the name of the descriptor is a [String] and returns it.
802 String get _stringName { 795 String get _stringName {
803 if (name is String) return name; 796 if (name is String) return name;
804 throw 'Pattern $name must be a string.'; 797 throw 'Pattern $name must be a string.';
805 } 798 }
806 799
807 /// Validates that at least one file in [dir] matching [name] is valid 800 /// Validates that at least one file in [dir] matching [name] is valid
808 /// according to [validate]. [validate] should complete to an exception if 801 /// according to [validate]. [validate] should complete to an exception if
(...skipping 748 matching lines...) Expand 10 before | Expand all | Expand 10 after
1557 /// calling [completion] is unnecessary. 1550 /// calling [completion] is unnecessary.
1558 void expectLater(Future actual, matcher, {String reason, 1551 void expectLater(Future actual, matcher, {String reason,
1559 FailureHandler failureHandler, bool verbose: false}) { 1552 FailureHandler failureHandler, bool verbose: false}) {
1560 _schedule((_) { 1553 _schedule((_) {
1561 return actual.then((value) { 1554 return actual.then((value) {
1562 expect(value, matcher, reason: reason, failureHandler: failureHandler, 1555 expect(value, matcher, reason: reason, failureHandler: failureHandler,
1563 verbose: false); 1556 verbose: false);
1564 }); 1557 });
1565 }); 1558 });
1566 } 1559 }
OLDNEW
« no previous file with comments | « utils/tests/pub/real_version_test.dart ('k') | utils/tests/pub/update/pub_update_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698