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

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

Issue 513023002: Step one towards stable error messages with details: (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 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 library polymer.test.linter_test; 5 library polymer.test.linter_test;
6 6
7 import 'dart:convert'; 7 import 'dart:convert';
8 8
9 import 'package:polymer/src/build/common.dart'; 9 import 'package:polymer/src/build/common.dart';
10 import 'package:polymer/src/build/linter.dart'; 10 import 'package:polymer/src/build/linter.dart';
11 import 'package:polymer/src/build/messages.dart';
11 import 'package:unittest/unittest.dart'; 12 import 'package:unittest/unittest.dart';
12 13
13 import 'common.dart'; 14 import 'common.dart';
14 15
15 void main() { 16 void main() {
16 _testLinter('nothing to report', { 17 _testLinter('nothing to report', {
17 'a|lib/test.html': '<!DOCTYPE html><html></html>', 18 'a|lib/test.html': '<!DOCTYPE html><html></html>',
18 }, []); 19 }, []);
19 20
20 group('must have proper initialization imports', () { 21 group('must have proper initialization imports', () {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 '<link rel="import" href="packages/a/lib.html">' 53 '<link rel="import" href="packages/a/lib.html">'
53 '<polymer-element name="x-a"></polymer-element>' 54 '<polymer-element name="x-a"></polymer-element>'
54 '<script type="application/dart" src="foo.dart">' 55 '<script type="application/dart" src="foo.dart">'
55 '</script>' 56 '</script>'
56 '<script src="packages/browser/dart.js"></script>' 57 '<script src="packages/browser/dart.js"></script>'
57 '</html>', 58 '</html>',
58 }, []); 59 }, []);
59 60
60 test('usePolymerHtmlMessage looks right', () { 61 test('usePolymerHtmlMessage looks right', () {
61 _check(int i, String url) { 62 _check(int i, String url) {
62 expect(usePolymerHtmlMessage(i), 63 expect(_usePolymerHtmlMessage(i),
63 contains('<link rel="import" href="$url">')); 64 contains('<link rel="import" href="$url">'));
64 } 65 }
65 _check(0, 'packages/polymer/polymer.html'); 66 _check(0, 'packages/polymer/polymer.html');
66 _check(1, '../packages/polymer/polymer.html'); 67 _check(1, '../packages/polymer/polymer.html');
67 _check(2, '../../packages/polymer/polymer.html'); 68 _check(2, '../../packages/polymer/polymer.html');
68 _check(3, '../../../packages/polymer/polymer.html'); 69 _check(3, '../../../packages/polymer/polymer.html');
69 }); 70 });
70 71
71 _testLinter('missing polymer.html in web', { 72 _testLinter('missing polymer.html in web', {
72 'a|web/test.html': '<!DOCTYPE html><html>\n' 73 'a|web/test.html': '<!DOCTYPE html><html>\n'
73 '<polymer-element name="x-a"></polymer-element>' 74 '<polymer-element name="x-a"></polymer-element>'
74 '<script type="application/dart" src="foo.dart">' 75 '<script type="application/dart" src="foo.dart">'
75 '</script>' 76 '</script>'
76 '<script src="packages/browser/dart.js"></script>' 77 '<script src="packages/browser/dart.js"></script>'
77 '</html>', 78 '</html>',
78 }, [ 79 }, [
79 'warning: ${usePolymerHtmlMessage(0)} (web/test.html 1 0)', 80 'warning: ${_usePolymerHtmlMessage(0)} '
81 '(web/test.html 1 0)',
80 ]); 82 ]);
81 83
82 _testLinter('missing polymer.html in web/foo', { 84 _testLinter('missing polymer.html in web/foo', {
83 'a|web/foo/test.html': '<!DOCTYPE html><html>\n' 85 'a|web/foo/test.html': '<!DOCTYPE html><html>\n'
84 '<polymer-element name="x-a"></polymer-element>' 86 '<polymer-element name="x-a"></polymer-element>'
85 '<script type="application/dart" src="foo.dart">' 87 '<script type="application/dart" src="foo.dart">'
86 '</script>' 88 '</script>'
87 '<script src="packages/browser/dart.js"></script>' 89 '<script src="packages/browser/dart.js"></script>'
88 '</html>', 90 '</html>',
89 }, [ 91 }, [
90 'warning: ${usePolymerHtmlMessage(1)} (web/foo/test.html 1 0)', 92 'warning: ${_usePolymerHtmlMessage(1)} '
93 '(web/foo/test.html 1 0)',
91 ]); 94 ]);
92 95
93 _testLinter('missing polymer.html in lib', { 96 _testLinter('missing polymer.html in lib', {
94 'a|lib/test.html': '<!DOCTYPE html><html>\n' 97 'a|lib/test.html': '<!DOCTYPE html><html>\n'
95 '<polymer-element name="x-a"></polymer-element>' 98 '<polymer-element name="x-a"></polymer-element>'
96 '<script type="application/dart" src="foo.dart">' 99 '<script type="application/dart" src="foo.dart">'
97 '</script>' 100 '</script>'
98 '<script src="packages/browser/dart.js"></script>' 101 '<script src="packages/browser/dart.js"></script>'
99 '</html>', 102 '</html>',
100 }, [ 103 }, [
101 'warning: ${usePolymerHtmlMessage(2)} (lib/test.html 1 0)', 104 'warning: ${_usePolymerHtmlMessage(2)} '
105 '(lib/test.html 1 0)',
102 ]); 106 ]);
103 107
104 _testLinter('missing polymer.html in lib/foo/bar', { 108 _testLinter('missing polymer.html in lib/foo/bar', {
105 'a|lib/foo/bar/test.html': '<!DOCTYPE html><html>\n' 109 'a|lib/foo/bar/test.html': '<!DOCTYPE html><html>\n'
106 '<polymer-element name="x-a"></polymer-element>' 110 '<polymer-element name="x-a"></polymer-element>'
107 '<script type="application/dart" src="foo.dart">' 111 '<script type="application/dart" src="foo.dart">'
108 '</script>' 112 '</script>'
109 '<script src="packages/browser/dart.js"></script>' 113 '<script src="packages/browser/dart.js"></script>'
110 '</html>', 114 '</html>',
111 }, [ 115 }, [
112 'warning: ${usePolymerHtmlMessage(4)} (lib/foo/bar/test.html 1 0)', 116 'warning: ${_usePolymerHtmlMessage(4)} '
117 '(lib/foo/bar/test.html 1 0)',
113 ]); 118 ]);
114 119
115 _testLinter('missing Dart code', { 120 _testLinter('missing Dart code', {
116 'a|web/test.html': '<!DOCTYPE html><html>' 121 'a|web/test.html': '<!DOCTYPE html><html>'
117 '<link rel="import" href="packages/polymer/polymer.html">' 122 '<link rel="import" href="packages/polymer/polymer.html">'
118 '<script src="packages/browser/dart.js"></script>' 123 '<script src="packages/browser/dart.js"></script>'
119 '</html>', 124 '</html>',
120 }, [ 125 }, [
121 'warning: $USE_INIT_DART', 126 'warning: ${MISSING_INIT_POLYMER.snippet}',
122 ]); 127 ]);
123 128
124 _testLinter('nothing to report, experimental with no Dart code', { 129 _testLinter('nothing to report, experimental with no Dart code', {
125 'a|web/test.html': '<!DOCTYPE html><html>' 130 'a|web/test.html': '<!DOCTYPE html><html>'
126 '<link rel="import" ' 131 '<link rel="import" '
127 'href="packages/polymer/polymer_experimental.html">' 132 'href="packages/polymer/polymer_experimental.html">'
128 '<script src="packages/browser/dart.js"></script>' 133 '<script src="packages/browser/dart.js"></script>'
129 '</html>', 134 '</html>',
130 }, []); 135 }, []);
131 136
132 _testLinter('experimental cannot have Dart code in main document', { 137 _testLinter('experimental cannot have Dart code in main document', {
133 'a|web/test.html': '<!DOCTYPE html><html>' 138 'a|web/test.html': '<!DOCTYPE html><html>'
134 '<link rel="import" ' 139 '<link rel="import" '
135 'href="packages/polymer/polymer_experimental.html">\n' 140 'href="packages/polymer/polymer_experimental.html">\n'
136 '<script type="application/dart" src="foo.dart">' 141 '<script type="application/dart" src="foo.dart">'
137 '</script>' 142 '</script>'
138 '<script src="packages/browser/dart.js"></script>' 143 '<script src="packages/browser/dart.js"></script>'
139 '</html>', 144 '</html>',
140 }, [ 145 }, [
141 'warning: $NO_DART_SCRIPT_AND_EXPERIMENTAL (web/test.html 1 0)', 146 'warning: ${NO_DART_SCRIPT_AND_EXPERIMENTAL.snippet} '
147 '(web/test.html 1 0)',
142 ]); 148 ]);
143 149
144 _testLinter('missing Dart code and polymer.html', { 150 _testLinter('missing Dart code and polymer.html', {
145 'a|web/test.html': '<!DOCTYPE html><html></html>', 151 'a|web/test.html': '<!DOCTYPE html><html></html>',
146 }, [ 152 }, [
147 'warning: $USE_INIT_DART', 153 'warning: ${MISSING_INIT_POLYMER.snippet}',
148 ]); 154 ]);
149 }); 155 });
150 156
151 group('single script tag per document', () { 157 group('single script tag per document', () {
152 _testLinter('two top-level tags', { 158 _testLinter('two top-level tags', {
153 'a|web/test.html': '<!DOCTYPE html><html>' 159 'a|web/test.html': '<!DOCTYPE html><html>'
154 '<link rel="import" href="packages/polymer/polymer.html">' 160 '<link rel="import" href="packages/polymer/polymer.html">'
155 '<script type="application/dart" src="a.dart">' 161 '<script type="application/dart" src="a.dart">'
156 '</script>\n' 162 '</script>\n'
157 '<script type="application/dart" src="b.dart">' 163 '<script type="application/dart" src="b.dart">'
(...skipping 29 matching lines...) Expand all
187 }, [ 193 }, [
188 'warning: Only one "application/dart" script tag per document is' 194 'warning: Only one "application/dart" script tag per document is'
189 ' allowed. (web/test.html 1 0)', 195 ' allowed. (web/test.html 1 0)',
190 ]); 196 ]);
191 }); 197 });
192 198
193 group('doctype warning', () { 199 group('doctype warning', () {
194 _testLinter('in web', { 200 _testLinter('in web', {
195 'a|web/test.html': '<html></html>', 201 'a|web/test.html': '<html></html>',
196 }, [ 202 }, [
197 'warning: Unexpected start tag (html). Expected DOCTYPE. ' 203 'warning: (from html5lib) Unexpected start tag (html). '
198 '(web/test.html 0 0)', 204 'Expected DOCTYPE. (web/test.html 0 0)',
199 'warning: $USE_INIT_DART', 205 'warning: ${MISSING_INIT_POLYMER.snippet}',
200 ]); 206 ]);
201 207
202 _testLinter('in lib', { 208 _testLinter('in lib', {
203 'a|lib/test.html': '<html></html>', 209 'a|lib/test.html': '<html></html>',
204 }, []); 210 }, []);
205 }); 211 });
206 212
207 group('duplicate polymer-elements,', () { 213 group('duplicate polymer-elements,', () {
208 _testLinter('same file', { 214 _testLinter('same file', {
209 'a|lib/test.html': '''<html> 215 'a|lib/test.html': '''<html>
210 <link rel="import" href="../../packages/polymer/polymer.html"> 216 <link rel="import" href="../../packages/polymer/polymer.html">
211 <polymer-element name="x-a"></polymer-element> 217 <polymer-element name="x-a"></polymer-element>
212 <polymer-element name="x-a"></polymer-element> 218 <polymer-element name="x-a"></polymer-element>
213 </html>'''.replaceAll(' ', ''), 219 </html>'''.replaceAll(' ', ''),
214 }, [ 220 }, [
215 'warning: duplicate definition for custom tag "x-a". ' 221 'warning: duplicate definition for custom tag "x-a". '
216 '(lib/test.html 2 0)', 222 '(lib/test.html 2 0)',
217 'warning: duplicate definition for custom tag "x-a" ' 223 'warning: duplicate definition for custom tag "x-a". '
218 '(second definition). (lib/test.html 3 0)' 224 '(second definition). (lib/test.html 3 0)'
219 ]); 225 ]);
220 226
221 _testLinter('other file', { 227 _testLinter('other file', {
222 'a|lib/b.html': '''<html> 228 'a|lib/b.html': '''<html>
223 <link rel="import" href="../../packages/polymer/polymer.html"> 229 <link rel="import" href="../../packages/polymer/polymer.html">
224 <polymer-element name="x-a"></polymer-element> 230 <polymer-element name="x-a"></polymer-element>
225 </html>'''.replaceAll(' ', ''), 231 </html>'''.replaceAll(' ', ''),
226 'a|lib/test.html': '''<html> 232 'a|lib/test.html': '''<html>
227 <link rel="import" href="b.html"> 233 <link rel="import" href="b.html">
228 <polymer-element name="x-a"></polymer-element> 234 <polymer-element name="x-a"></polymer-element>
229 </html>'''.replaceAll(' ', ''), 235 </html>'''.replaceAll(' ', ''),
230 }, [ 236 }, [
231 'warning: duplicate definition for custom tag "x-a". ' 237 'warning: duplicate definition for custom tag "x-a". '
232 '(lib/b.html 2 0)', 238 '(lib/b.html 2 0)',
233 'warning: duplicate definition for custom tag "x-a" ' 239 'warning: duplicate definition for custom tag "x-a". '
234 '(second definition). (lib/test.html 2 0)' 240 '(second definition). (lib/test.html 2 0)'
235 ]); 241 ]);
236 242
237 _testLinter('non existing file', { 243 _testLinter('non existing file', {
238 'a|lib/test.html': '''<html> 244 'a|lib/test.html': '''<html>
239 <link rel="import" href="../../packages/polymer/polymer.html"> 245 <link rel="import" href="../../packages/polymer/polymer.html">
240 <link rel="import" href="b.html"> 246 <link rel="import" href="b.html">
241 <polymer-element name="x-a"></polymer-element> 247 <polymer-element name="x-a"></polymer-element>
242 </html>'''.replaceAll(' ', ''), 248 </html>'''.replaceAll(' ', ''),
243 }, [ 249 }, [
244 'warning: couldn\'t find imported asset "lib/b.html" in package ' 250 'warning: couldn\'t find imported asset "lib/b.html" in package '
245 '"a". (lib/test.html 2 0)' 251 '"a". (lib/test.html 2 0)'
246 ]); 252 ]);
247 253
248 _testLinter('other package', { 254 _testLinter('other package', {
249 'b|lib/b.html': '''<html> 255 'b|lib/b.html': '''<html>
250 <link rel="import" href="../../packages/polymer/polymer.html"> 256 <link rel="import" href="../../packages/polymer/polymer.html">
251 <polymer-element name="x-a"></polymer-element> 257 <polymer-element name="x-a"></polymer-element>
252 </html>'''.replaceAll(' ', ''), 258 </html>'''.replaceAll(' ', ''),
253 'a|lib/test.html': '''<html> 259 'a|lib/test.html': '''<html>
254 <link rel="import" href="../../packages/b/b.html"> 260 <link rel="import" href="../../packages/b/b.html">
255 <polymer-element name="x-a"></polymer-element> 261 <polymer-element name="x-a"></polymer-element>
256 </html>'''.replaceAll(' ', ''), 262 </html>'''.replaceAll(' ', ''),
257 }, [ 263 }, [
258 'warning: duplicate definition for custom tag "x-a". ' 264 'warning: duplicate definition for custom tag "x-a". '
259 '(package:b/b.html 2 0)', 265 '(package:b/b.html 2 0)',
260 'warning: duplicate definition for custom tag "x-a" ' 266 'warning: duplicate definition for custom tag "x-a". '
261 '(second definition). (lib/test.html 2 0)' 267 '(second definition). (lib/test.html 2 0)'
262 ]); 268 ]);
263 }); 269 });
264 270
265 _testLinter('bad link-rel tag (href missing)', { 271 _testLinter('bad link-rel tag (href missing)', {
266 'a|lib/test.html': '''<html> 272 'a|lib/test.html': '''<html>
267 <link rel="import"> 273 <link rel="import">
268 <link rel="stylesheet"> 274 <link rel="stylesheet">
269 <link rel="foo"> 275 <link rel="foo">
270 <link rel="import" href=""> 276 <link rel="import" href="">
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 'a|lib/b.html': '<html></html>', 308 'a|lib/b.html': '<html></html>',
303 'a|lib/test.html': '''<html> 309 'a|lib/test.html': '''<html>
304 <link rel="import" href="../../packages/polymer/polymer.html"> 310 <link rel="import" href="../../packages/polymer/polymer.html">
305 <polymer-element name="x-a"> 311 <polymer-element name="x-a">
306 <link rel="import" href="b.html"> 312 <link rel="import" href="b.html">
307 <template><div> 313 <template><div>
308 </div></template> 314 </div></template>
309 </polymer-element> 315 </polymer-element>
310 </html>'''.replaceAll(' ', ''), 316 </html>'''.replaceAll(' ', ''),
311 }, [ 317 }, [
312 'error: $NO_IMPORT_WITHIN_ELEMENT (lib/test.html 3 2)' 318 'error: ${NO_IMPORT_WITHIN_ELEMENT.snippet} (lib/test.html 3 2)'
313 ]); 319 ]);
314 320
315 _testLinter('need a name for <polymer-element>', { 321 _testLinter('need a name for <polymer-element>', {
316 'a|lib/test.html': '''<html> 322 'a|lib/test.html': '''<html>
317 <link rel="import" href="../../packages/polymer/polymer.html"> 323 <link rel="import" href="../../packages/polymer/polymer.html">
318 <polymer-element></polymer-element> 324 <polymer-element></polymer-element>
319 </html>'''.replaceAll(' ', ''), 325 </html>'''.replaceAll(' ', ''),
320 }, [ 326 }, [
321 'error: Missing tag name of the custom element. Please include an ' 327 'error: Missing tag name of the custom element. Please include an '
322 'attribute like \'name="your-tag-name"\'. (lib/test.html 2 0)' 328 'attribute like \'name="your-tag-name"\'. (lib/test.html 2 0)'
323 ]); 329 ]);
324 330
325 _testLinter('name for <polymer-element> should have dashes', { 331 _testLinter('name for <polymer-element> should have dashes', {
326 'a|lib/test.html': '''<html> 332 'a|lib/test.html': '''<html>
327 <link rel="import" href="../../packages/polymer/polymer.html"> 333 <link rel="import" href="../../packages/polymer/polymer.html">
328 <polymer-element name="a"></polymer-element> 334 <polymer-element name="a"></polymer-element>
329 </html>'''.replaceAll(' ', ''), 335 </html>'''.replaceAll(' ', ''),
330 }, [ 336 }, [
331 'error: Invalid name "a". Custom element names must have at least one' 337 'error: Invalid name "a". Custom element names must have at least one'
332 ' dash and can\'t be any of the following names: annotation-xml, ' 338 ' dash (-) and can\'t be any of the following names: annotation-xml, '
333 'color-profile, font-face, font-face-src, font-face-uri, ' 339 'color-profile, font-face, font-face-src, font-face-uri, '
334 'font-face-format, font-face-name, missing-glyph. (lib/test.html 2 0)' 340 'font-face-format, font-face-name, missing-glyph. (lib/test.html 2 0)'
335 ]); 341 ]);
336 342
337 _testLinter('extend is a valid element or existing tag', { 343 _testLinter('extend is a valid element or existing tag', {
338 'a|lib/test.html': '''<html> 344 'a|lib/test.html': '''<html>
339 <link rel="import" href="../../packages/polymer/polymer.html"> 345 <link rel="import" href="../../packages/polymer/polymer.html">
340 <polymer-element name="x-a" extends="li"></polymer-element> 346 <polymer-element name="x-a" extends="li"></polymer-element>
341 </html>'''.replaceAll(' ', ''), 347 </html>'''.replaceAll(' ', ''),
342 }, []); 348 }, []);
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 <polymer-element name="x-a"><div on-foo-bar="{{quux}}"></div> 506 <polymer-element name="x-a"><div on-foo-bar="{{quux}}"></div>
501 </polymer-element> 507 </polymer-element>
502 '''.replaceAll(' ', ''), 508 '''.replaceAll(' ', ''),
503 }, []); 509 }, []);
504 }); 510 });
505 511
506 group('using custom tags', () { 512 group('using custom tags', () {
507 _testLinter('tag exists (x-tag)', { 513 _testLinter('tag exists (x-tag)', {
508 'a|lib/test.html': '<x-foo></x-foo>', 514 'a|lib/test.html': '<x-foo></x-foo>',
509 }, [ 515 }, [
510 'warning: definition for Polymer element with tag name "x-foo" not ' 516 'warning: custom element with name "x-foo" not found. '
511 'found. (lib/test.html 0 0)' 517 '(lib/test.html 0 0)'
512 ]); 518 ]);
513 519
514 _testLinter('tag exists (type extension)', { 520 _testLinter('tag exists (type extension)', {
515 'a|lib/test.html': '<div is="x-foo"></div>', 521 'a|lib/test.html': '<div is="x-foo"></div>',
516 }, [ 522 }, [
517 'warning: definition for Polymer element with tag name "x-foo" not ' 523 'warning: custom element with name "x-foo" not found. '
518 'found. (lib/test.html 0 0)' 524 '(lib/test.html 0 0)'
519 ]); 525 ]);
520 526
521 _testLinter('tag exists (internally defined in code)', { 527 _testLinter('tag exists (internally defined in code)', {
522 'a|lib/test.html': '<div is="auto-binding-dart"></div>', 528 'a|lib/test.html': '<div is="auto-binding-dart"></div>',
523 }, []); 529 }, []);
524 530
525 _testLinter('used correctly (no base tag)', { 531 _testLinter('used correctly (no base tag)', {
526 'a|lib/test.html': ''' 532 'a|lib/test.html': '''
527 <link rel="import" href="../../packages/polymer/polymer.html"> 533 <link rel="import" href="../../packages/polymer/polymer.html">
528 <polymer-element name="x-a"></polymer-element> 534 <polymer-element name="x-a"></polymer-element>
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 661
656 testPhases("logs are output to file", outputLogsPhases, { 662 testPhases("logs are output to file", outputLogsPhases, {
657 'a|web/test.html': '<!DOCTYPE html><html>\n' 663 'a|web/test.html': '<!DOCTYPE html><html>\n'
658 '<polymer-element name="x-a"></polymer-element>' 664 '<polymer-element name="x-a"></polymer-element>'
659 '<script type="application/dart" src="foo.dart">' 665 '<script type="application/dart" src="foo.dart">'
660 '</script>' 666 '</script>'
661 '<script src="packages/browser/dart.js"></script>' 667 '<script src="packages/browser/dart.js"></script>'
662 '</html>', 668 '</html>',
663 }, { 669 }, {
664 'a|web/test.html._buildLogs.1': 670 'a|web/test.html._buildLogs.1':
665 '[{' 671 '{"polymer#3":[{'
666 '"level":"Warning",' 672 '"level":"Warning",'
667 '"message":${JSON.encode(const HtmlEscape().convert( 673 '"message":{'
668 usePolymerHtmlMessage(0)))},' 674 '"id":"polymer#3",'
675 '"snippet":"${_usePolymerHtmlMessage(0).replaceAll('"','\\"')}"'
676 '},'
669 '"span":{' 677 '"span":{'
670 '"location":"web/test.html:2:1",' 678 '"start":{'
671 '"text":' 679 '"url":"web/test.html",'
672 '"${const HtmlEscape().convert('<polymer-element name="x-a">')}" ' 680 '"offset":22,'
681 '"line":1,'
682 '"column":0'
683 '},'
684 '"end":{'
685 '"url":"web/test.html",'
686 '"offset":50,'
687 '"line":1,'
688 '"column":28'
689 '},'
690 '"text":"<polymer-element name=\\"x-a\\">"'
673 '}' 691 '}'
674 '}]', 692 '}]}',
675 }, [ 693 }, [
676 // Logs should still make it to barback too. 694 // Logs should still make it to barback too.
677 'warning: ${usePolymerHtmlMessage(0)} (web/test.html 1 0)', 695 'warning: ${_usePolymerHtmlMessage(0)} (web/test.html 1 0)',
678 ]); 696 ]);
679 }); 697 });
680 } 698 }
681 699
700 _usePolymerHtmlMessage(int i) {
701 var prefix = '../' * i;
702 return USE_POLYMER_HTML.create({'reachOutPrefix': prefix}).snippet;
703 }
704
682 _testLinter(String name, Map inputFiles, List outputMessages, 705 _testLinter(String name, Map inputFiles, List outputMessages,
683 [bool solo = false]) { 706 [bool solo = false]) {
684 var outputFiles = {}; 707 var outputFiles = {};
685 if (outputMessages.every((m) => m.startsWith('warning:'))) { 708 if (outputMessages.every((m) => m.startsWith('warning:'))) {
686 inputFiles.forEach((k, v) => outputFiles[k] = v); 709 inputFiles.forEach((k, v) => outputFiles[k] = v);
687 } 710 }
688 if (outputMessages.isEmpty) { 711 if (outputMessages.isEmpty) {
689 var linter = new Linter(new TransformOptions()); 712 var linter = new Linter(new TransformOptions());
690 testPhases(name, [[linter]], inputFiles, outputFiles, outputMessages, solo); 713 testPhases(name, [[linter]], inputFiles, outputFiles, outputMessages, solo);
691 } else { 714 } else {
692 testLogOutput( 715 testLogOutput(
693 (options) => new Linter(options), name, inputFiles, outputFiles, 716 (options) => new Linter(options), name, inputFiles, outputFiles,
694 outputMessages, solo); 717 outputMessages, solo);
695 } 718 }
696 } 719 }
OLDNEW
« no previous file with comments | « pkg/polymer/test/build/import_inliner_test.dart ('k') | pkg/polymer/test/build/log_injector_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698