| 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 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 "packages/", | 51 "packages/", |
| 52 ]; | 52 ]; |
| 53 | 53 |
| 54 const List<MessageKind> MESSAGE_SKIP_LIST = const <MessageKind>[ | 54 const List<MessageKind> MESSAGE_SKIP_LIST = const <MessageKind>[ |
| 55 // TODO(johnniwinther): Support checking of this warning. (Issue 26132) | 55 // TODO(johnniwinther): Support checking of this warning. (Issue 26132) |
| 56 MessageKind.IMPORT_EXPERIMENTAL_MIRRORS, | 56 MessageKind.IMPORT_EXPERIMENTAL_MIRRORS, |
| 57 ]; | 57 ]; |
| 58 | 58 |
| 59 main(List<String> arguments) { | 59 main(List<String> arguments) { |
| 60 List<String> options = <String>[]; | 60 List<String> options = <String>[]; |
| 61 List<Uri> uriList = <Uri>[]; |
| 62 String filter; |
| 63 bool first = true; |
| 61 for (String argument in arguments) { | 64 for (String argument in arguments) { |
| 62 if (argument == '-v') { | 65 if (argument.startsWith('-')) { |
| 63 options.add(Flags.verbose); | 66 options.add(argument == '-v' ? Flags.verbose : argument); |
| 64 } else if (argument.startsWith('-')) { | 67 } else if (first) { |
| 65 options.add(argument); | 68 File file = new File(argument); |
| 66 } | 69 if (file.existsSync()) { |
| 67 } | 70 // Read test files from [file]. |
| 68 List<Uri> uriList = <Uri>[]; | 71 for (String line in file.readAsLinesSync()) { |
| 69 for (String arg in arguments) { | 72 line = line.trim(); |
| 70 if (!arg.startsWith('-')) { | 73 if (line.startsWith('Analyzing uri: ')) { |
| 71 for (String line in new File(arg).readAsLinesSync()) { | 74 int filenameOffset = line.indexOf('tests/compiler/dart2js/'); |
| 72 line = line.trim(); | 75 if (filenameOffset != -1) { |
| 73 if (line.startsWith('Analyzing uri: ')) { | 76 uriList.add(Uri.base.resolve( |
| 74 int filenameOffset = line.indexOf('tests/compiler/dart2js/'); | 77 nativeToUriPath(line.substring(filenameOffset)))); |
| 75 if (filenameOffset != -1) { | 78 } |
| 76 uriList.add(Uri.base.resolve( | |
| 77 nativeToUriPath(line.substring(filenameOffset)))); | |
| 78 } | 79 } |
| 79 } | 80 } |
| 81 } else { |
| 82 // Use argument as filter on test files. |
| 83 filter = argument; |
| 80 } | 84 } |
| 85 } else { |
| 86 throw new ArgumentError("Extra argument $argument in $arguments."); |
| 81 } | 87 } |
| 88 first = false; |
| 82 } | 89 } |
| 83 | 90 |
| 84 asyncTest(() async { | 91 asyncTest(() async { |
| 85 if (uriList.isEmpty) { | 92 if (uriList.isEmpty) { |
| 86 Directory dir = | 93 Directory dir = |
| 87 new Directory.fromUri(Uri.base.resolve('tests/compiler/dart2js/')); | 94 new Directory.fromUri(Uri.base.resolve('tests/compiler/dart2js/')); |
| 88 for (FileSystemEntity entity in dir.listSync(recursive: true)) { | 95 for (FileSystemEntity entity in dir.listSync(recursive: true)) { |
| 89 if (entity is File && entity.path.endsWith('.dart')) { | 96 if (entity is File && entity.path.endsWith('.dart')) { |
| 90 Uri file = Uri.base.resolve(nativeToUriPath(entity.path)); | 97 Uri file = Uri.base.resolve(nativeToUriPath(entity.path)); |
| 98 if (filter != null && !'$file'.contains(filter)) { |
| 99 continue; |
| 100 } |
| 91 if (!SKIP_LIST.any((skip) => file.path.contains(skip))) { | 101 if (!SKIP_LIST.any((skip) => file.path.contains(skip))) { |
| 92 uriList.add(file); | 102 uriList.add(file); |
| 93 } | 103 } |
| 94 } | 104 } |
| 95 } | 105 } |
| 96 } | 106 } |
| 97 await analyze( | 107 await analyze( |
| 98 uriList, | 108 uriList, |
| 99 WHITE_LIST, | 109 WHITE_LIST, |
| 100 mode: AnalysisMode.URI, | 110 mode: AnalysisMode.URI, |
| 101 options: options, | 111 options: options, |
| 102 skipList: MESSAGE_SKIP_LIST); | 112 skipList: MESSAGE_SKIP_LIST); |
| 103 }); | 113 }); |
| 104 } | 114 } |
| OLD | NEW |