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

Side by Side Diff: pkg/polymer/test/build/common.dart

Issue 160623002: Updating barback test harness for angular transformers changes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 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 | « no previous file | no next file » | 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) 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 library polymer.test.build.common; 5 library polymer.test.build.common;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:barback/barback.dart'; 9 import 'package:barback/barback.dart';
10 import 'package:stack_trace/stack_trace.dart'; 10 import 'package:stack_trace/stack_trace.dart';
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 print(Trace.format(trace)); 59 print(Trace.format(trace));
60 } 60 }
61 fail('error running barback: $e'); 61 fail('error running barback: $e');
62 }); 62 });
63 63
64 resultSubscription = barback.results.listen((result) { 64 resultSubscription = barback.results.listen((result) {
65 expect(result.succeeded, !errorSeen, reason: "${result.errors}"); 65 expect(result.succeeded, !errorSeen, reason: "${result.errors}");
66 }); 66 });
67 67
68 logSubscription = barback.log.listen((entry) { 68 logSubscription = barback.log.listen((entry) {
69 // Ignore info messages.
70 if (entry.level == LogLevel.INFO) return;
69 if (entry.level == LogLevel.ERROR) errorSeen = true; 71 if (entry.level == LogLevel.ERROR) errorSeen = true;
70 // We only check messages when an expectation is provided. 72 // We only check messages when an expectation is provided.
71 if (messages == null) return; 73 if (messages == null) return;
72 74
73 var msg = '${entry.level.name.toLowerCase()}: ${entry.message}'; 75 var msg = '${entry.level.name.toLowerCase()}: ${entry.message}';
74 var span = entry.span; 76 var span = entry.span;
75 var spanInfo = span == null ? '' : 77 var spanInfo = span == null ? '' :
76 ' (${span.sourceUrl} ${span.start.line} ${span.start.column})'; 78 ' (${span.sourceUrl} ${span.start.line} ${span.start.column})';
77 expect(messagesSeen, lessThan(messages.length), 79 expect(messagesSeen, lessThan(messages.length),
78 reason: 'more messages than expected.\nMessage seen: $msg$spanInfo'); 80 reason: 'more messages than expected.\nMessage seen: $msg$spanInfo');
(...skipping 23 matching lines...) Expand all
102 104
103 Future check(String assetIdString, String content) { 105 Future check(String assetIdString, String content) {
104 return this[assetIdString].then((value) { 106 return this[assetIdString].then((value) {
105 value = _removeTrailingWhitespace(value); 107 value = _removeTrailingWhitespace(value);
106 content = _removeTrailingWhitespace(content); 108 content = _removeTrailingWhitespace(content);
107 expect(value, content, reason: 'Final output of $assetIdString differs.'); 109 expect(value, content, reason: 'Final output of $assetIdString differs.');
108 }); 110 });
109 } 111 }
110 112
111 Future checkAll(Map<String, String> files) { 113 Future checkAll(Map<String, String> files) {
112 var futures = []; 114 return barback.results.first.then((_) {
113 files.forEach((k, v) { 115 if (files == null) return null;
114 futures.add(check(k, v)); 116 var futures = [];
115 }); 117 files.forEach((k, v) {
116 return Future.wait(futures).then((_) { 118 futures.add(check(k, v));
119 });
120 return Future.wait(futures);
121 }).then((_) {
117 // We only check messages when an expectation is provided. 122 // We only check messages when an expectation is provided.
118 if (messages == null) return; 123 if (messages == null) return;
119 expect(messages.length, messagesSeen, 124 expect(messages.length, messagesSeen,
120 reason: 'less messages than expected'); 125 reason: 'less messages than expected');
121 }); 126 });
122 } 127 }
123 } 128 }
124 129
125 testPhases(String testName, List<List<Transformer>> phases, 130 testPhases(String testName, List<List<Transformer>> phases,
126 Map<String, String> inputFiles, Map<String, String> expectedFiles, 131 Map<String, String> inputFiles, Map<String, String> expectedFiles,
127 [List<String> expectedMessages]) { 132 [List<String> expectedMessages]) {
128 test(testName, () { 133 test(testName, () {
129 var helper = new TestHelper(phases, inputFiles, expectedMessages)..run(); 134 var helper = new TestHelper(phases, inputFiles, expectedMessages)..run();
130 return helper.checkAll(expectedFiles).then((_) => helper.tearDown()); 135 return helper.checkAll(expectedFiles).then((_) => helper.tearDown());
131 }); 136 });
132 } 137 }
133 138
134 const WEB_COMPONENTS_TAG = 139 const WEB_COMPONENTS_TAG =
135 '<script src="packages/web_components/platform.js"></script>\n' 140 '<script src="packages/web_components/platform.js"></script>\n'
136 '<script src="packages/web_components/dart_support.js"></script>\n'; 141 '<script src="packages/web_components/dart_support.js"></script>\n';
137 142
138 const INTEROP_TAG = '<script src="packages/browser/interop.js"></script>\n'; 143 const INTEROP_TAG = '<script src="packages/browser/interop.js"></script>\n';
139 const DART_JS_TAG = '<script src="packages/browser/dart.js"></script>'; 144 const DART_JS_TAG = '<script src="packages/browser/dart.js"></script>';
140 145
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698