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

Unified Diff: pkg/polymer/test/build/common.dart

Issue 112843004: Add linter by default for polymer's pub-build, also cleans up the linter code. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years 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
« no previous file with comments | « pkg/polymer/pubspec.yaml ('k') | pkg/polymer/test/build/linter_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/polymer/test/build/common.dart
diff --git a/pkg/polymer/test/build/common.dart b/pkg/polymer/test/build/common.dart
index 592f92fcaf26da4cca3c4203d8f0b09446673bfb..2e2790e39dd719b3746190034f9b794f319c38b9 100644
--- a/pkg/polymer/test/build/common.dart
+++ b/pkg/polymer/test/build/common.dart
@@ -31,20 +31,27 @@ class TestHelper implements PackageProvider {
*/
final Map<String, String> files;
final Iterable<String> packages;
+ final List<String> messages;
+ int messagesSeen = 0;
+ bool errorSeen = false;
Barback barback;
var errorSubscription;
var resultSubscription;
+ var logSubscription;
Future<Asset> getAsset(AssetId id) =>
new Future.value(new Asset.fromString(id, files[idToString(id)]));
- TestHelper(List<List<Transformer>> transformers, Map<String, String> files)
+
+ TestHelper(List<List<Transformer>> transformers, Map<String, String> files,
+ this.messages)
: files = files,
packages = files.keys.map((s) => idFromString(s).package) {
barback = new Barback(this);
for (var p in packages) {
barback.updateTransformers(p, transformers);
}
+
errorSubscription = barback.errors.listen((e) {
var trace = null;
if (e is Error) trace = e.stackTrace;
@@ -53,14 +60,30 @@ class TestHelper implements PackageProvider {
}
fail('error running barback: $e');
});
+
resultSubscription = barback.results.listen((result) {
- expect(result.succeeded, isTrue, reason: "${result.errors}");
+ expect(result.succeeded, !errorSeen, reason: "${result.errors}");
+ });
+
+ logSubscription = barback.log.listen((entry) {
+ if (entry.level == LogLevel.ERROR) errorSeen = true;
+ // We only check messages when an expectation is provided.
+ if (messages == null) return;
+
+ var msg = '${entry.level.name.toLowerCase()}: ${entry.message}';
+ var span = entry.span;
+ var spanInfo = span == null ? '' :
+ ' (${span.sourceUrl} ${span.start.line} ${span.start.column})';
+ expect(messagesSeen, lessThan(messages.length),
+ reason: 'more messages than expected');
+ expect('$msg$spanInfo', messages[messagesSeen++]);
});
}
void tearDown() {
errorSubscription.cancel();
resultSubscription.cancel();
+ logSubscription.cancel();
}
/**
@@ -90,14 +113,20 @@ class TestHelper implements PackageProvider {
files.forEach((k, v) {
futures.add(check(k, v));
});
- return Future.wait(futures);
+ return Future.wait(futures).then((_) {
+ // We only check messages when an expectation is provided.
+ if (messages == null) return;
+ expect(messages.length, messagesSeen,
+ reason: 'less messages than expected');
+ });
}
}
testPhases(String testName, List<List<Transformer>> phases,
- Map<String, String> inputFiles, Map<String, String> expectedFiles) {
+ Map<String, String> inputFiles, Map<String, String> expectedFiles,
+ [List<String> expectedMessages]) {
test(testName, () {
- var helper = new TestHelper(phases, inputFiles)..run();
+ var helper = new TestHelper(phases, inputFiles, expectedMessages)..run();
return helper.checkAll(expectedFiles).then((_) => helper.tearDown());
});
}
« no previous file with comments | « pkg/polymer/pubspec.yaml ('k') | pkg/polymer/test/build/linter_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698