| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 /** End-to-end tests for the [Compiler] API. */ | 5 /** End-to-end tests for the [Compiler] API. */ |
| 6 library compiler_test; | 6 library compiler_test; |
| 7 | 7 |
| 8 import 'package:logging/logging.dart' show Level; | 8 import 'package:logging/logging.dart' show Level; |
| 9 import 'package:path/path.dart' as path; | 9 import 'package:path/path.dart' as path; |
| 10 import 'package:polymer/src/messages.dart'; | 10 import 'package:polymer/src/messages.dart'; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 var messages = new Messages.silent(); | 47 var messages = new Messages.silent(); |
| 48 var compiler = createCompiler({ | 48 var compiler = createCompiler({ |
| 49 'index.html': '<head></head><body>' | 49 'index.html': '<head></head><body>' |
| 50 '<script type="application/dart" src="notfound.dart"></script>' | 50 '<script type="application/dart" src="notfound.dart"></script>' |
| 51 '</body>', | 51 '</body>', |
| 52 }, messages); | 52 }, messages); |
| 53 | 53 |
| 54 compiler.run().then(expectAsync1((e) { | 54 compiler.run().then(expectAsync1((e) { |
| 55 var msgs = messages.messages.where((m) => | 55 var msgs = messages.messages.where((m) => |
| 56 m.message.contains('unable')).toList(); | 56 m.message.contains('unable')).toList(); |
| 57 | 57 expect(msgs.length, 0); |
| 58 expect(msgs.length, 1); | |
| 59 expect(msgs[0].level, Level.SEVERE); | |
| 60 expect(msgs[0].message, contains('unable to open file')); | |
| 61 expect(msgs[0].span, isNotNull); | |
| 62 expect(msgs[0].span.sourceUrl, 'index.html'); | |
| 63 | |
| 64 MockFileSystem fs = compiler.fileSystem; | 58 MockFileSystem fs = compiler.fileSystem; |
| 65 expect(fs.readCount, { 'index.html': 1, 'notfound.dart': 1 }); | 59 expect(fs.readCount, { 'index.html': 1 }); |
| 66 })); | 60 })); |
| 67 }); | 61 }); |
| 68 | 62 |
| 69 test('component html', () { | 63 test('component html', () { |
| 70 var messages = new Messages.silent(); | 64 var messages = new Messages.silent(); |
| 71 var compiler = createCompiler({ | 65 var compiler = createCompiler({ |
| 72 'index.html': '<head>' | 66 'index.html': '<head>' |
| 73 '<link rel="import" href="notfound.html">' | 67 '<link rel="import" href="notfound.html">' |
| 74 '<body><x-foo>' | 68 '<body><x-foo>' |
| 75 '<script type="application/dart">main() {}</script>', | 69 '<script type="application/dart">main() {}</script>', |
| (...skipping 23 matching lines...) Expand all Loading... |
| 99 '<script type="application/dart">main() {}</script>' | 93 '<script type="application/dart">main() {}</script>' |
| 100 '</body>', | 94 '</body>', |
| 101 'foo.html': '<body><polymer-element name="x-foo" constructor="Foo">' | 95 'foo.html': '<body><polymer-element name="x-foo" constructor="Foo">' |
| 102 '<template></template>' | 96 '<template></template>' |
| 103 '<script type="application/dart" src="notfound.dart"></script>', | 97 '<script type="application/dart" src="notfound.dart"></script>', |
| 104 }, messages); | 98 }, messages); |
| 105 | 99 |
| 106 compiler.run().then(expectAsync1((e) { | 100 compiler.run().then(expectAsync1((e) { |
| 107 var msgs = messages.messages.where((m) => | 101 var msgs = messages.messages.where((m) => |
| 108 m.message.contains('unable')).toList(); | 102 m.message.contains('unable')).toList(); |
| 109 | 103 expect(msgs.length, 0); |
| 110 expect(msgs.length, 1); | |
| 111 expect(msgs[0].level, Level.SEVERE); | |
| 112 expect(msgs[0].message, contains('unable to open file')); | |
| 113 | |
| 114 MockFileSystem fs = compiler.fileSystem; | 104 MockFileSystem fs = compiler.fileSystem; |
| 115 expect(fs.readCount, | 105 expect(fs.readCount, |
| 116 { 'index.html': 1, 'foo.html': 1, 'notfound.dart': 1 }); | 106 { 'index.html': 1, 'foo.html': 1 }); |
| 117 })); | 107 })); |
| 118 }); | 108 }); |
| 119 }); | 109 }); |
| 120 } | 110 } |
| OLD | NEW |