OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 dart2js.analyze_test.test; | 5 library dart2js.analyze_test.test; |
6 | 6 |
7 import 'dart:io'; | 7 import 'dart:io'; |
8 | 8 |
9 import 'package:async_helper/async_helper.dart'; | 9 import 'package:async_helper/async_helper.dart'; |
10 import 'package:compiler/src/apiimpl.dart' show | 10 import 'package:compiler/src/apiimpl.dart' show |
11 CompilerImpl; | 11 CompilerImpl; |
12 import 'package:compiler/src/commandline_options.dart'; | 12 import 'package:compiler/src/commandline_options.dart'; |
13 import 'package:compiler/src/diagnostics/messages.dart' show | 13 import 'package:compiler/src/diagnostics/messages.dart' show |
14 MessageKind; | 14 MessageKind; |
15 import 'package:compiler/src/filenames.dart' show | 15 import 'package:compiler/src/filenames.dart' show |
16 nativeToUriPath; | 16 nativeToUriPath; |
17 | 17 |
18 import 'analyze_helper.dart'; | 18 import 'analyze_helper.dart'; |
19 import 'memory_compiler.dart'; | 19 import 'memory_compiler.dart'; |
20 | 20 |
21 /** | 21 /** |
22 * Map of white-listed warnings and errors. | 22 * Map of white-listed warnings and errors. |
23 * | 23 * |
24 * Use an identifiable suffix of the file uri as key. Use a fixed substring of | 24 * Use an identifiable suffix of the file uri as key. Use a fixed substring of |
25 * the error/warning message in the list of white-listings for each file. | 25 * the error/warning message in the list of white-listings for each file. |
26 */ | 26 */ |
27 // TODO(johnniwinther): Support canonical URIs as keys. | 27 // TODO(johnniwinther): Support canonical URIs as keys. |
28 const Map<String, List/*<String|MessageKind>*/> WHITE_LIST = const { | 28 const Map<String, List/*<String|MessageKind>*/> WHITE_LIST = const { |
29 // Several tests import mirrors; any of these might trigger the warning. | |
30 ".dart": const [ | |
31 MessageKind.IMPORT_EXPERIMENTAL_MIRRORS, | |
32 ], | |
33 "/test/src/util/": const [ | 29 "/test/src/util/": const [ |
34 "Library 'package:async/async.dart' doesn't export a " | 30 "Library 'package:async/async.dart' doesn't export a " |
35 "'ForkableStream' declaration.", | 31 "'ForkableStream' declaration.", |
36 ], | 32 ], |
37 "mirrors_test.dart": const [ | 33 "mirrors_test.dart": const [ |
38 MessageKind.INVALID_SYMBOL, | 34 MessageKind.INVALID_SYMBOL, |
39 MessageKind.PRIVATE_IDENTIFIER, | 35 MessageKind.PRIVATE_IDENTIFIER, |
40 ], | 36 ], |
41 }; | 37 }; |
42 | 38 |
43 const List<String> SKIP_LIST = const <String>[ | 39 const List<String> SKIP_LIST = const <String>[ |
44 // Helper files: | 40 // Helper files: |
45 "dart2js_batch2_run.dart", | 41 "dart2js_batch2_run.dart", |
46 "http_launch_data/", | 42 "http_launch_data/", |
47 "mirrors_helper.dart", | 43 "mirrors_helper.dart", |
48 "path%20with%20spaces/", | 44 "path%20with%20spaces/", |
49 "one_line_dart_program.dart", | 45 "one_line_dart_program.dart", |
50 "sourcemaps/invokes_test_file.dart", | 46 "sourcemaps/invokes_test_file.dart", |
51 "cps_ir/input/", | 47 "cps_ir/input/", |
52 // No longer maintained: | 48 // No longer maintained: |
53 "backend_dart/", | 49 "backend_dart/", |
54 // Broken tests: | 50 // Broken tests: |
55 "http_test.dart", | 51 "http_test.dart", |
56 ]; | 52 ]; |
57 | 53 |
| 54 const List<MessageKind> MESSAGE_SKIP_LIST = const <MessageKind>[ |
| 55 // TODO(johnniwinther): Support checking of this warning. (Issue 26132) |
| 56 MessageKind.IMPORT_EXPERIMENTAL_MIRRORS, |
| 57 ]; |
| 58 |
58 main(List<String> arguments) { | 59 main(List<String> arguments) { |
59 List<String> options = <String>[]; | 60 List<String> options = <String>[]; |
60 if (arguments.contains('-v') || arguments.contains(Flags.verbose)) { | 61 if (arguments.contains('-v') || arguments.contains(Flags.verbose)) { |
61 options.add(Flags.verbose); | 62 options.add(Flags.verbose); |
62 } | 63 } |
| 64 List<Uri> uriList = <Uri>[]; |
| 65 for (String arg in arguments) { |
| 66 if (!arg.startsWith('-')) { |
| 67 for (String line in new File(arg).readAsLinesSync()) { |
| 68 line = line.trim(); |
| 69 if (line.startsWith('Analyzing uri: ')) { |
| 70 int filenameOffset = line.indexOf('tests/compiler/dart2js/'); |
| 71 if (filenameOffset != -1) { |
| 72 uriList.add(Uri.base.resolve( |
| 73 nativeToUriPath(line.substring(filenameOffset)))); |
| 74 } |
| 75 } |
| 76 } |
| 77 } |
| 78 } |
| 79 |
63 asyncTest(() async { | 80 asyncTest(() async { |
64 List<Uri> uriList = <Uri>[]; | 81 if (uriList.isEmpty) { |
65 Directory dir = | 82 Directory dir = |
66 new Directory.fromUri(Uri.base.resolve('tests/compiler/dart2js/')); | 83 new Directory.fromUri(Uri.base.resolve('tests/compiler/dart2js/')); |
67 for (FileSystemEntity entity in dir.listSync(recursive: true)) { | 84 for (FileSystemEntity entity in dir.listSync(recursive: true)) { |
68 if (entity is File && entity.path.endsWith('.dart')) { | 85 if (entity is File && entity.path.endsWith('.dart')) { |
69 Uri file = Uri.base.resolve(nativeToUriPath(entity.path)); | 86 Uri file = Uri.base.resolve(nativeToUriPath(entity.path)); |
70 if (!SKIP_LIST.any((skip) => file.path.contains(skip))) { | 87 if (!SKIP_LIST.any((skip) => file.path.contains(skip))) { |
71 uriList.add(file); | 88 uriList.add(file); |
| 89 } |
72 } | 90 } |
73 } | 91 } |
74 } | 92 } |
75 await analyze( | 93 await analyze( |
76 uriList, WHITE_LIST, mode: AnalysisMode.URI, options: options); | 94 uriList, |
| 95 WHITE_LIST, |
| 96 mode: AnalysisMode.URI, |
| 97 options: options, |
| 98 skipList: MESSAGE_SKIP_LIST); |
77 }); | 99 }); |
78 } | 100 } |
OLD | NEW |