| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 import 'dart:async'; | 5 import 'dart:async'; |
| 6 import 'dart:io'; | 6 import 'dart:io'; |
| 7 | 7 |
| 8 import 'package:compiler/src/common.dart'; | 8 import 'package:compiler/src/common.dart'; |
| 9 import 'package:compiler/src/common_elements.dart'; | 9 import 'package:compiler/src/common_elements.dart'; |
| 10 import 'package:compiler/src/compiler.dart'; | 10 import 'package:compiler/src/compiler.dart'; |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 } | 165 } |
| 166 } | 166 } |
| 167 | 167 |
| 168 /// Check code for all test files int [data] using [computeFromAst] and | 168 /// Check code for all test files int [data] using [computeFromAst] and |
| 169 /// [computeFromKernel] from the respective front ends. If [skipForKernel] | 169 /// [computeFromKernel] from the respective front ends. If [skipForKernel] |
| 170 /// contains the name of the test file it isn't tested for kernel. | 170 /// contains the name of the test file it isn't tested for kernel. |
| 171 Future checkTests(Directory dataDir, ComputeMemberDataFunction computeFromAst, | 171 Future checkTests(Directory dataDir, ComputeMemberDataFunction computeFromAst, |
| 172 ComputeMemberDataFunction computeFromKernel, | 172 ComputeMemberDataFunction computeFromKernel, |
| 173 {List<String> skipForKernel: const <String>[], | 173 {List<String> skipForKernel: const <String>[], |
| 174 List<String> options: const <String>[], | 174 List<String> options: const <String>[], |
| 175 bool verbose: false}) async { | 175 List<String> args: const <String>[]}) async { |
| 176 args = args.toList(); |
| 177 bool verbose = args.remove('-v'); |
| 176 await for (FileSystemEntity entity in dataDir.list()) { | 178 await for (FileSystemEntity entity in dataDir.list()) { |
| 179 String name = entity.uri.pathSegments.last; |
| 180 if (args.isNotEmpty && !args.contains(name)) continue; |
| 177 print('----------------------------------------------------------------'); | 181 print('----------------------------------------------------------------'); |
| 178 print('Checking ${entity.uri}'); | 182 print('Checking ${entity.uri}'); |
| 179 print('----------------------------------------------------------------'); | 183 print('----------------------------------------------------------------'); |
| 180 String annotatedCode = await new File.fromUri(entity.uri).readAsString(); | 184 String annotatedCode = await new File.fromUri(entity.uri).readAsString(); |
| 181 print('--from ast------------------------------------------------------'); | 185 print('--from ast------------------------------------------------------'); |
| 182 await checkCode(annotatedCode, computeFromAst, compileFromSource, | 186 await checkCode(annotatedCode, computeFromAst, compileFromSource, |
| 183 options: options, verbose: verbose); | 187 options: options, verbose: verbose); |
| 184 if (skipForKernel.contains(entity.uri.pathSegments.last)) { | 188 if (skipForKernel.contains(name)) { |
| 185 print('--skipped for kernel------------------------------------------'); | 189 print('--skipped for kernel------------------------------------------'); |
| 186 continue; | 190 continue; |
| 187 } | 191 } |
| 188 print('--from kernel---------------------------------------------------'); | 192 print('--from kernel---------------------------------------------------'); |
| 189 await checkCode(annotatedCode, computeFromKernel, compileFromDill, | 193 await checkCode(annotatedCode, computeFromKernel, compileFromDill, |
| 190 options: options, verbose: verbose); | 194 options: options, verbose: verbose); |
| 191 } | 195 } |
| 192 } | 196 } |
| 193 | 197 |
| 194 /// Compiles the [annotatedCode] with the provided [options] and calls | 198 /// Compiles the [annotatedCode] with the provided [options] and calls |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 id = new NodeId(annotation.offset); | 282 id = new NodeId(annotation.offset); |
| 279 expected = text; | 283 expected = text; |
| 280 } else { | 284 } else { |
| 281 id = new ElementId(text.substring(0, colonPos)); | 285 id = new ElementId(text.substring(0, colonPos)); |
| 282 expected = text.substring(colonPos + 1); | 286 expected = text.substring(colonPos + 1); |
| 283 } | 287 } |
| 284 map[id] = expected; | 288 map[id] = expected; |
| 285 } | 289 } |
| 286 return map; | 290 return map; |
| 287 } | 291 } |
| OLD | NEW |