| 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 | 6 |
| 7 import 'package:front_end/compiler_options.dart'; | 7 import 'package:front_end/compiler_options.dart'; |
| 8 import 'package:front_end/incremental_kernel_generator.dart'; | 8 import 'package:front_end/incremental_kernel_generator.dart'; |
| 9 import 'package:front_end/memory_file_system.dart'; | 9 import 'package:front_end/memory_file_system.dart'; |
| 10 import 'package:front_end/src/incremental/byte_store.dart'; | 10 import 'package:front_end/src/incremental/byte_store.dart'; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 | 29 |
| 30 /// The used file watcher. | 30 /// The used file watcher. |
| 31 WatchUsedFilesFn watchFn = (uri, used) {}; | 31 WatchUsedFilesFn watchFn = (uri, used) {}; |
| 32 | 32 |
| 33 /// The object under test. | 33 /// The object under test. |
| 34 IncrementalKernelGeneratorImpl incrementalKernelGenerator; | 34 IncrementalKernelGeneratorImpl incrementalKernelGenerator; |
| 35 | 35 |
| 36 /// Compute the initial [Program] for the given [entryPoint]. | 36 /// Compute the initial [Program] for the given [entryPoint]. |
| 37 Future<Program> getInitialState(Uri entryPoint, | 37 Future<Program> getInitialState(Uri entryPoint, |
| 38 {bool setPackages: true}) async { | 38 {bool setPackages: true}) async { |
| 39 createSdkFiles(fileSystem); | 39 Map<String, Uri> dartLibraries = createSdkFiles(fileSystem); |
| 40 // TODO(scheglov) Builder the SDK kernel and set it into the options. | 40 // TODO(scheglov) Builder the SDK kernel and set it into the options. |
| 41 | 41 |
| 42 // TODO(scheglov) Make `.packages` file optional. |
| 43 |
| 42 var compilerOptions = new CompilerOptions() | 44 var compilerOptions = new CompilerOptions() |
| 43 ..fileSystem = fileSystem | 45 ..fileSystem = fileSystem |
| 44 ..byteStore = new MemoryByteStore() | 46 ..byteStore = new MemoryByteStore() |
| 45 // ..logger = new PerformanceLog(stdout) | 47 // ..logger = new PerformanceLog(stdout) |
| 46 ..strongMode = true | 48 ..strongMode = true |
| 47 ..chaseDependencies = true | 49 ..chaseDependencies = true |
| 48 ..librariesSpecificationUri = Uri.parse('file:///sdk/lib/libraries.json'); | 50 ..dartLibraries = dartLibraries; |
| 49 | 51 |
| 50 if (setPackages) { | 52 if (setPackages) { |
| 51 compilerOptions.packagesFileUri = Uri.parse('file:///test/.packages'); | 53 compilerOptions.packagesFileUri = Uri.parse('file:///test/.packages'); |
| 52 } | 54 } |
| 53 incrementalKernelGenerator = await IncrementalKernelGenerator | 55 incrementalKernelGenerator = await IncrementalKernelGenerator |
| 54 .newInstance(compilerOptions, entryPoint, watch: watchFn); | 56 .newInstance(compilerOptions, entryPoint, watch: watchFn); |
| 55 return (await incrementalKernelGenerator.computeDelta()).newProgram; | 57 return (await incrementalKernelGenerator.computeDelta()).newProgram; |
| 56 } | 58 } |
| 57 | 59 |
| 58 test_compile_chain() async { | 60 test_compile_chain() async { |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 throw fail('No library found with URI "$uri"'); | 380 throw fail('No library found with URI "$uri"'); |
| 379 } | 381 } |
| 380 | 382 |
| 381 String _getLibraryText(Library library) { | 383 String _getLibraryText(Library library) { |
| 382 StringBuffer buffer = new StringBuffer(); | 384 StringBuffer buffer = new StringBuffer(); |
| 383 new Printer(buffer, syntheticNames: new NameSystem()) | 385 new Printer(buffer, syntheticNames: new NameSystem()) |
| 384 .writeLibraryFile(library); | 386 .writeLibraryFile(library); |
| 385 return buffer.toString(); | 387 return buffer.toString(); |
| 386 } | 388 } |
| 387 } | 389 } |
| OLD | NEW |