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

Side by Side Diff: dart/tests/compiler/dart2js/warnings_checker.dart

Issue 136753002: Version 1.1.0-dev.5.9 (Closed) Base URL: http://dart.googlecode.com/svn/trunk/
Patch Set: Created 6 years, 11 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 // Test that dart2js produces the expected static type warnings to ensures that 5 // Test that dart2js produces the expected static type warnings to ensures that
6 // the analyzer and dart2js agrees on the tests. 6 // the analyzer and dart2js agrees on the tests.
7 7
8 import 'dart:async'; 8 import 'dart:async';
9 import 'dart:io'; 9 import 'dart:io';
10 import 'package:expect/expect.dart'; 10 import 'package:expect/expect.dart';
11 import 'package:async_helper/async_helper.dart'; 11 import 'package:async_helper/async_helper.dart';
12 import 'memory_compiler.dart'; 12 import 'memory_compiler.dart';
13 import '../../../sdk/lib/_internal/compiler/implementation/filenames.dart'; 13 import '../../../sdk/lib/_internal/compiler/implementation/filenames.dart';
14 import '../../../sdk/lib/_internal/compiler/implementation/source_file.dart'; 14 import '../../../sdk/lib/_internal/compiler/implementation/source_file.dart';
15 import '../../../sdk/lib/_internal/compiler/implementation/source_file_provider. dart'; 15 import '../../../sdk/lib/_internal/compiler/implementation/source_file_provider. dart';
16 import '../../../sdk/lib/_internal/compiler/implementation/util/uri_extras.dart' ; 16 import '../../../sdk/lib/_internal/compiler/implementation/util/uri_extras.dart' ;
17 import 'dart:convert'; 17 import 'dart:convert';
18 18
19 void checkWarnings(Map<String, dynamic> tests) { 19 void checkWarnings(Map<String, dynamic> tests, [List<String> arguments]) {
20 bool isWindows = Platform.isWindows; 20 bool isWindows = Platform.isWindows;
21 Uri script = currentDirectory.resolveUri(Platform.script); 21 Uri script = currentDirectory.resolveUri(Platform.script);
22 bool warningsMismatch = false; 22 bool warningsMismatch = false;
23 bool verbose = arguments != null && arguments.contains('-v');
23 asyncTest(() => Future.forEach(tests.keys, (String test) { 24 asyncTest(() => Future.forEach(tests.keys, (String test) {
24 Uri uri = script.resolve('../../$test'); 25 Uri uri = script.resolve('../../$test');
25 String source = UTF8.decode(readAll(uriPathToNative(uri.path))); 26 String source = UTF8.decode(readAll(uriPathToNative(uri.path)));
26 SourceFile file = new StringSourceFile( 27 SourceFile file = new StringSourceFile(
27 relativize(currentDirectory, uri, isWindows), source); 28 relativize(currentDirectory, uri, isWindows), source);
28 Map<int,String> expectedWarnings = {}; 29 Map<int,String> expectedWarnings = {};
29 int lineNo = 0; 30 int lineNo = 0;
30 for (String line in source.split('\n')) { 31 for (String line in source.split('\n')) {
31 if (line.contains('///') && line.contains('static type warning')) { 32 if (line.contains('///') && line.contains('static type warning')) {
32 expectedWarnings[lineNo] = line; 33 expectedWarnings[lineNo] = line;
33 } 34 }
34 lineNo++; 35 lineNo++;
35 } 36 }
36 Set<int> unseenWarnings = new Set<int>.from(expectedWarnings.keys); 37 Set<int> unseenWarnings = new Set<int>.from(expectedWarnings.keys);
37 DiagnosticCollector collector = new DiagnosticCollector(); 38 DiagnosticCollector collector = new DiagnosticCollector();
38 var compiler = compilerFor(const {}, 39 var compiler = compilerFor(const {},
39 diagnosticHandler: collector, 40 diagnosticHandler: collector,
40 options: ['--analyze-only'], 41 options: ['--analyze-only'],
41 showDiagnostics: false); 42 showDiagnostics: verbose);
42 return compiler.run(uri).then((_) { 43 return compiler.run(uri).then((_) {
43 Map<String, List<int>> statusMap = tests[test]; 44 Map<String, List<int>> statusMap = tests[test];
44 // Line numbers with known unexpected warnings. 45 // Line numbers with known unexpected warnings.
45 List<int> unexpectedStatus = []; 46 List<int> unexpectedStatus = [];
46 if (statusMap != null && statusMap.containsKey('unexpected')) { 47 if (statusMap != null && statusMap.containsKey('unexpected')) {
47 unexpectedStatus = statusMap['unexpected']; 48 unexpectedStatus = statusMap['unexpected'];
48 } 49 }
49 // Line numbers with known missing warnings. 50 // Line numbers with known missing warnings.
50 List<int> missingStatus = []; 51 List<int> missingStatus = [];
51 if (statusMap != null && statusMap.containsKey('missing')) { 52 if (statusMap != null && statusMap.containsKey('missing')) {
(...skipping 19 matching lines...) Expand all
71 print('$uri [${lineNo+1}]: Missing static type warning.'); 72 print('$uri [${lineNo+1}]: Missing static type warning.');
72 print(line); 73 print(line);
73 } 74 }
74 } 75 }
75 } 76 }
76 }); 77 });
77 }).then((_) { 78 }).then((_) {
78 Expect.isFalse(warningsMismatch); 79 Expect.isFalse(warningsMismatch);
79 })); 80 }));
80 } 81 }
OLDNEW
« no previous file with comments | « dart/tests/compiler/dart2js/mixin_language_test.dart ('k') | dart/tests/language/checked_mode_helper.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698