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

Side by Side Diff: pkg/code_transformers/lib/src/test_harness.dart

Issue 367023003: Roll forward revision 37912. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes. Created 6 years, 5 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 | « pkg/barback/pubspec.yaml ('k') | pkg/code_transformers/pubspec.yaml » ('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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 /// Utilities for creating unit tests of Barback transformers. 5 /// Utilities for creating unit tests of Barback transformers.
6 library code_transformers.src.test_harness; 6 library code_transformers.src.test_harness;
7 7
8 import 'dart:async'; 8 import 'dart:async';
9 9
10 import 'package:barback/barback.dart'; 10 import 'package:barback/barback.dart';
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 print(Trace.format(trace)); 57 print(Trace.format(trace));
58 } 58 }
59 fail('error running barback: $e'); 59 fail('error running barback: $e');
60 }); 60 });
61 61
62 resultSubscription = barback.results.listen((result) { 62 resultSubscription = barback.results.listen((result) {
63 expect(result.succeeded, !errorSeen, reason: "${result.errors}"); 63 expect(result.succeeded, !errorSeen, reason: "${result.errors}");
64 }); 64 });
65 65
66 logSubscription = barback.log.listen((entry) { 66 logSubscription = barback.log.listen((entry) {
67 // Ignore info messages. 67 // Ignore info and fine messages.
68 if (entry.level == LogLevel.INFO) return; 68 if (entry.level == LogLevel.INFO || entry.level == LogLevel.FINE) return;
69 if (entry.level == LogLevel.ERROR) errorSeen = true; 69 if (entry.level == LogLevel.ERROR) errorSeen = true;
70 // We only check messages when an expectation is provided. 70 // We only check messages when an expectation is provided.
71 if (messages == null) return; 71 if (messages == null) return;
72 72
73 var msg = '${entry.level.name.toLowerCase()}: ${entry.message}'; 73 var msg = '${entry.level.name.toLowerCase()}: ${entry.message}';
74 var span = entry.span; 74 var span = entry.span;
75 var spanInfo = span == null ? '' : 75 var spanInfo = span == null ? '' :
76 ' (${span.sourceUrl} ${span.start.line} ${span.start.column})'; 76 ' (${span.sourceUrl} ${span.start.line} ${span.start.column})';
77 expect(messagesSeen, lessThan(messages.length), 77 expect(messagesSeen, lessThan(messages.length),
78 reason: 'more messages than expected.\nMessage seen: $msg$spanInfo'); 78 reason: 'more messages than expected.\nMessage seen: $msg$spanInfo');
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 }); 115 });
116 return Future.wait(futures); 116 return Future.wait(futures);
117 }).then((_) { 117 }).then((_) {
118 // We only check messages when an expectation is provided. 118 // We only check messages when an expectation is provided.
119 if (messages == null) return; 119 if (messages == null) return;
120 expect(messagesSeen, messages.length, 120 expect(messagesSeen, messages.length,
121 reason: 'less messages than expected'); 121 reason: 'less messages than expected');
122 }); 122 });
123 } 123 }
124 } 124 }
OLDNEW
« no previous file with comments | « pkg/barback/pubspec.yaml ('k') | pkg/code_transformers/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698