| Index: tests/compiler/dart2js/message_kind_helper.dart
|
| diff --git a/tests/compiler/dart2js/message_kind_helper.dart b/tests/compiler/dart2js/message_kind_helper.dart
|
| index 9d60632dd3a5bc82b4cb7f5b70f883e279aedb72..1499cf5851053791256919b2f98d790e619c5b18 100644
|
| --- a/tests/compiler/dart2js/message_kind_helper.dart
|
| +++ b/tests/compiler/dart2js/message_kind_helper.dart
|
| @@ -15,8 +15,8 @@ import 'package:compiler/src/dart_backend/dart_backend.dart' show
|
| import 'package:compiler/src/diagnostics/messages.dart' show
|
| MessageKind,
|
| MessageTemplate;
|
| -import 'package:compiler/src/old_to_new_api.dart' show
|
| - LegacyCompilerDiagnostics;
|
| +import 'package:compiler/compiler_new.dart' show
|
| + Diagnostic;
|
|
|
| import 'memory_compiler.dart';
|
|
|
| @@ -68,13 +68,7 @@ Future<Compiler> check(MessageTemplate template, Compiler cachedCompiler) {
|
| Expect.isTrue(example.containsKey('main.dart'),
|
| "Example map must contain a 'main.dart' entry.");
|
| }
|
| - List<String> messages = <String>[];
|
| - void collect(Uri uri, int begin, int end, String message, kind) {
|
| - if (kind.name == 'verbose info' || kind.name == 'info') {
|
| - return;
|
| - }
|
| - messages.add(message);
|
| - }
|
| + DiagnosticCollector collector = new DiagnosticCollector();
|
|
|
| bool oldBackendIsDart;
|
| if (cachedCompiler != null) {
|
| @@ -84,7 +78,7 @@ Future<Compiler> check(MessageTemplate template, Compiler cachedCompiler) {
|
|
|
| Compiler compiler = compilerFor(
|
| memorySourceFiles: example,
|
| - diagnosticHandler: new LegacyCompilerDiagnostics(collect),
|
| + diagnosticHandler: collector,
|
| options: [Flags.analyzeOnly,
|
| Flags.enableExperimentalMirrors]..addAll(template.options),
|
| cachedCompiler:
|
| @@ -93,6 +87,11 @@ Future<Compiler> check(MessageTemplate template, Compiler cachedCompiler) {
|
| oldBackendIsDart == newBackendIsDart ? cachedCompiler : null);
|
|
|
| return compiler.run(Uri.parse('memory:main.dart')).then((_) {
|
| + Iterable<DiagnosticMessage> messages = collector.filterMessagesByKinds(
|
| + [Diagnostic.ERROR,
|
| + Diagnostic.WARNING,
|
| + Diagnostic.HINT,
|
| + Diagnostic.CRASH]);
|
|
|
| Expect.isFalse(messages.isEmpty, 'No messages in """$example"""');
|
|
|
| @@ -102,21 +101,31 @@ Future<Compiler> check(MessageTemplate template, Compiler cachedCompiler) {
|
| new RegExp(ESCAPE_REGEXP), (m) => '\\${m[0]}');
|
| pattern = pattern.replaceAll(new RegExp(r'#\\\{[^}]*\\\}'), '.*');
|
|
|
| + bool checkMessage(DiagnosticMessage message) {
|
| + if (message.message.kind != MessageKind.GENERIC) {
|
| + return message.message.kind == template.kind;
|
| + } else {
|
| + return new RegExp('^$pattern\$').hasMatch(message.text);
|
| + }
|
| + }
|
| +
|
| // TODO(johnniwinther): Extend MessageKind to contain information on
|
| // where info messages are expected.
|
| bool messageFound = false;
|
| List unexpectedMessages = [];
|
| - for (String message in messages) {
|
| - if (!messageFound && new RegExp('^$pattern\$').hasMatch(message)) {
|
| + for (DiagnosticMessage message in messages) {
|
| + if (!messageFound && checkMessage(message)) {
|
| messageFound = true;
|
| } else {
|
| unexpectedMessages.add(message);
|
| }
|
| }
|
| - Expect.isTrue(messageFound, '"$pattern" does not match any in $messages');
|
| + Expect.isTrue(messageFound,
|
| + '${template.kind}} does not match any in\n '
|
| + '${messages.join('\n ')}');
|
| Expect.isFalse(compiler.reporter.hasCrashed);
|
| if (!unexpectedMessages.isEmpty) {
|
| - for (String message in unexpectedMessages) {
|
| + for (DiagnosticMessage message in unexpectedMessages) {
|
| print("Unexpected message: $message");
|
| }
|
| if (!kindsWithExtraMessages.contains(template.kind)) {
|
|
|