| 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'; |
| 7 |
| 6 import 'package:compiler/src/commandline_options.dart'; | 8 import 'package:compiler/src/commandline_options.dart'; |
| 7 import 'package:compiler/src/common.dart'; | 9 import 'package:compiler/src/common.dart'; |
| 8 import 'package:compiler/src/common_elements.dart'; | 10 import 'package:compiler/src/common_elements.dart'; |
| 9 import 'package:compiler/src/compiler.dart'; | 11 import 'package:compiler/src/compiler.dart'; |
| 10 import 'package:compiler/src/elements/entities.dart'; | 12 import 'package:compiler/src/elements/entities.dart'; |
| 11 import 'package:expect/expect.dart'; | 13 import 'package:expect/expect.dart'; |
| 12 | 14 |
| 13 import '../annotated_code_helper.dart'; | 15 import '../annotated_code_helper.dart'; |
| 14 import '../memory_compiler.dart'; | 16 import '../memory_compiler.dart'; |
| 15 import '../equivalence/id_equivalence.dart'; | 17 import '../equivalence/id_equivalence.dart'; |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 .spanFromSpannable( | 160 .spanFromSpannable( |
| 159 computeSpannable(elementEnvironment, mainUri, id)) | 161 computeSpannable(elementEnvironment, mainUri, id)) |
| 160 .begin; | 162 .begin; |
| 161 annotations[offset] = '--- | ${data2.value}'; | 163 annotations[offset] = '--- | ${data2.value}'; |
| 162 } | 164 } |
| 163 }); | 165 }); |
| 164 return withAnnotations(annotations); | 166 return withAnnotations(annotations); |
| 165 } | 167 } |
| 166 } | 168 } |
| 167 | 169 |
| 170 /// Check code for all test files int [data] using [computeFromAst] and |
| 171 /// [computeFromKernel] from the respective front ends. If [skipForKernel] |
| 172 /// contains the name of the test file it isn't tested for kernel. |
| 173 Future checkTests(Directory dataDir, ComputeMemberDataFunction computeFromAst, |
| 174 ComputeMemberDataFunction computeFromKernel, |
| 175 {List<String> skipForKernel: const <String>[], bool verbose: false}) async { |
| 176 await for (FileSystemEntity entity in dataDir.list()) { |
| 177 print('----------------------------------------------------------------'); |
| 178 print('Checking ${entity.uri}'); |
| 179 print('----------------------------------------------------------------'); |
| 180 String annotatedCode = await new File.fromUri(entity.uri).readAsString(); |
| 181 print('--from ast------------------------------------------------------'); |
| 182 await checkCode(annotatedCode, computeFromAst, compileFromSource, |
| 183 verbose: verbose); |
| 184 if (skipForKernel.contains(entity.uri.pathSegments.last)) { |
| 185 print('--skipped for kernel------------------------------------------'); |
| 186 continue; |
| 187 } |
| 188 print('--from kernel---------------------------------------------------'); |
| 189 await checkCode(annotatedCode, computeFromKernel, compileFromDill, |
| 190 verbose: verbose); |
| 191 } |
| 192 } |
| 193 |
| 168 /// Compiles the [annotatedCode] with the provided [options] and calls | 194 /// Compiles the [annotatedCode] with the provided [options] and calls |
| 169 /// [computeMemberData] for each member. The result is checked against the | 195 /// [computeMemberData] for each member. The result is checked against the |
| 170 /// expected data derived from [annotatedCode]. | 196 /// expected data derived from [annotatedCode]. |
| 171 Future checkCode( | 197 Future checkCode( |
| 172 String annotatedCode, | 198 String annotatedCode, |
| 173 ComputeMemberDataFunction computeMemberData, | 199 ComputeMemberDataFunction computeMemberData, |
| 174 CompileFunction compileFunction, | 200 CompileFunction compileFunction, |
| 175 {List<String> options: const <String>[], | 201 {List<String> options: const <String>[], |
| 176 bool verbose: false}) async { | 202 bool verbose: false}) async { |
| 177 IdData data = await computeData( | 203 IdData data = await computeData( |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 id = new NodeId(annotation.offset); | 275 id = new NodeId(annotation.offset); |
| 250 expected = text; | 276 expected = text; |
| 251 } else { | 277 } else { |
| 252 id = new ElementId(text.substring(0, colonPos)); | 278 id = new ElementId(text.substring(0, colonPos)); |
| 253 expected = text.substring(colonPos + 1); | 279 expected = text.substring(colonPos + 1); |
| 254 } | 280 } |
| 255 map[id] = expected; | 281 map[id] = expected; |
| 256 } | 282 } |
| 257 return map; | 283 return map; |
| 258 } | 284 } |
| OLD | NEW |