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

Side by Side Diff: sdk/lib/_internal/pub/test/test_pub.dart

Issue 16034002: Use helper methods for running pub. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Get rid of unnecessary RegExps in tests. Created 7 years, 7 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
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 /// The path of the packages directory in the mock app used for tests. Relative 231 /// The path of the packages directory in the mock app used for tests. Relative
232 /// to the sandbox directory. 232 /// to the sandbox directory.
233 final String packagesPath = "$appPath/packages"; 233 final String packagesPath = "$appPath/packages";
234 234
235 /// Set to true when the current batch of scheduled events should be aborted. 235 /// Set to true when the current batch of scheduled events should be aborted.
236 bool _abortScheduled = false; 236 bool _abortScheduled = false;
237 237
238 /// Enum identifying a pub command that can be run with a well-defined success 238 /// Enum identifying a pub command that can be run with a well-defined success
239 /// output. 239 /// output.
240 class RunCommand { 240 class RunCommand {
241 static final install = new RunCommand('install', 241 static final install = new RunCommand('install', 'installed');
242 new RegExp("Dependencies installed!\$")); 242 static final update = new RunCommand('update', 'updated');
243
244 static final update = new RunCommand('update',
245 new RegExp("Dependencies updated!\$"));
246 243
247 final String name; 244 final String name;
248 final RegExp success; 245 final RegExp success;
249 RunCommand(this.name, this.success); 246 RunCommand(this.name, String verb)
247 : success = new RegExp("Dependencies $verb!\$");
250 } 248 }
251 249
252 /// Many tests validate behavior that is the same between pub install and 250 /// Many tests validate behavior that is the same between pub install and
253 /// update have the same behavior. Instead of duplicating those tests, this 251 /// update have the same behavior. Instead of duplicating those tests, this
254 /// takes a callback that defines install/update agnostic tests and runs them 252 /// takes a callback that defines install/update agnostic tests and runs them
255 /// with both commands. 253 /// with both commands.
256 void forBothPubInstallAndUpdate(void callback(RunCommand command)) { 254 void forBothPubInstallAndUpdate(void callback(RunCommand command)) {
257 group(RunCommand.install.name, () => callback(RunCommand.install)); 255 group(RunCommand.install.name, () => callback(RunCommand.install));
258 group(RunCommand.update.name, () => callback(RunCommand.update)); 256 group(RunCommand.update.name, () => callback(RunCommand.update));
259 } 257 }
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after
744 bool matches(item, MatchState matchState) { 742 bool matches(item, MatchState matchState) {
745 if (item is! Pair) return false; 743 if (item is! Pair) return false;
746 return _firstMatcher.matches(item.first, matchState) && 744 return _firstMatcher.matches(item.first, matchState) &&
747 _lastMatcher.matches(item.last, matchState); 745 _lastMatcher.matches(item.last, matchState);
748 } 746 }
749 747
750 Description describe(Description description) { 748 Description describe(Description description) {
751 description.addAll("(", ", ", ")", [_firstMatcher, _lastMatcher]); 749 description.addAll("(", ", ", ")", [_firstMatcher, _lastMatcher]);
752 } 750 }
753 } 751 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/pub/test/pub_install_and_update_test.dart ('k') | sdk/lib/_internal/pub/test/unknown_source_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698