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

Unified Diff: utils/tests/pub/test_pub.dart

Issue 10421026: Make pub handle missing git more gracefully. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 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 side-by-side diff with in-line comments
Download patch
« utils/pub/pub.dart ('K') | « utils/tests/pub/pub_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: utils/tests/pub/test_pub.dart
diff --git a/utils/tests/pub/test_pub.dart b/utils/tests/pub/test_pub.dart
index fdd49247418b05baab09c439846234aae75e1fcb..7172c7ba00728b148c6d1e31f422619201199e62 100644
--- a/utils/tests/pub/test_pub.dart
+++ b/utils/tests/pub/test_pub.dart
@@ -75,7 +75,8 @@ List<_ScheduledEvent> _scheduledBeforePub;
*/
List<_ScheduledEvent> _scheduledAfterPub;
-void runPub([List<String> args, Pattern output, int exitCode = 0]) {
+void runPub([List<String> args, Pattern output, Pattern error,
+ int exitCode = 0]) {
var createdSandboxDir;
var asyncDone = expectAsync0(() {});
@@ -108,15 +109,12 @@ void runPub([List<String> args, Pattern output, int exitCode = 0]) {
return _runPub(args, pathInSandbox(appPath));
}).chain((result) {
- Expect.equals(result.stderr.length, 0,
- 'Did not expect any output on stderr, and got:\n' +
- Strings.join(result.stderr, '\n'));
+ _validateOutput(output, result.stdout);
+ _validateOutput(error, result.stderr);
Expect.equals(result.exitCode, exitCode,
'Pub returned exit code ${result.exitCode}, expected $exitCode.');
- _validateOutput(output, result.stdout);
-
return _runScheduled(createdSandboxDir, _scheduledAfterPub);
});
@@ -135,6 +133,22 @@ void runPub([List<String> args, Pattern output, int exitCode = 0]) {
});
}
+
+/**
+ * Wraps a test that needs git in order to run. This validates that the test is
+ * running on a builbot in which case we expect git to be installed. If we are
+ * not running on the buildbot, we will instead see if git is installed and
+ * skip the test if not. This way, users don't need to have git installed to
+ * run the tests locally (unless they actually care about the pub git tests).
+ */
+void withGit(void callback()) {
+ isGitInstalled.then(expectAsync1((installed) {
+ if (installed || Platform.environment.containsKey('BUILDBOT_BUILDERNAME')) {
+ callback();
+ }
+ }));
+}
+
Future<Directory> _setUpSandbox() {
return createTempDir('pub-test-sandbox-');
}
@@ -170,6 +184,8 @@ Future<ProcessResult> _runPub(List<String> pubArgs, String workingDir) {
* reports whether the output contained the pattern.
*/
void _validateOutput(Pattern expected, List<String> actual) {
+ if (expected == null) return;
+
if (expected is String) return _validateOutputString(expected, actual);
var actualText = Strings.join(actual, "\n");
if (actualText.contains(expected)) return;
« utils/pub/pub.dart ('K') | « utils/tests/pub/pub_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698