Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(142)

Side by Side Diff: pkg/front_end/test/incremental_kernel_generator_test.dart

Issue 2989223002: Pass additional options in incremental setup (Closed)
Patch Set: fix test Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pkg/front_end/lib/incremental_kernel_generator.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 16 matching lines...) Expand all
27 /// Virtual filesystem for testing. 27 /// Virtual filesystem for testing.
28 final fileSystem = new MemoryFileSystem(Uri.parse('file:///')); 28 final fileSystem = new MemoryFileSystem(Uri.parse('file:///'));
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) async { 37 Future<Program> getInitialState(Uri entryPoint,
38 {bool setPackages: true}) async {
38 Map<String, Uri> dartLibraries = createSdkFiles(fileSystem); 39 Map<String, Uri> dartLibraries = createSdkFiles(fileSystem);
39 // 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.
40 41
41 // TODO(scheglov) Make `.packages` file optional. 42 // TODO(scheglov) Make `.packages` file optional.
42 43
43 var compilerOptions = new CompilerOptions() 44 var compilerOptions = new CompilerOptions()
44 ..fileSystem = fileSystem 45 ..fileSystem = fileSystem
45 ..byteStore = new MemoryByteStore() 46 ..byteStore = new MemoryByteStore()
46 // ..logger = new PerformanceLog(stdout) 47 // ..logger = new PerformanceLog(stdout)
47 ..strongMode = true 48 ..strongMode = true
48 ..chaseDependencies = true 49 ..chaseDependencies = true
49 ..dartLibraries = dartLibraries 50 ..dartLibraries = dartLibraries;
50 ..packagesFileUri = Uri.parse('file:///test/.packages'); 51
52 if (setPackages) {
53 compilerOptions.packagesFileUri = Uri.parse('file:///test/.packages');
54 }
51 incrementalKernelGenerator = await IncrementalKernelGenerator 55 incrementalKernelGenerator = await IncrementalKernelGenerator
52 .newInstance(compilerOptions, entryPoint, watch: watchFn); 56 .newInstance(compilerOptions, entryPoint, watch: watchFn);
53 return (await incrementalKernelGenerator.computeDelta()).newProgram; 57 return (await incrementalKernelGenerator.computeDelta()).newProgram;
54 } 58 }
55 59
56 test_compile_chain() async { 60 test_compile_chain() async {
57 writeFile('/test/.packages', 'test:lib/'); 61 writeFile('/test/.packages', 'test:lib/');
58 String aPath = '/test/lib/a.dart'; 62 String aPath = '/test/lib/a.dart';
59 String bPath = '/test/lib/b.dart'; 63 String bPath = '/test/lib/b.dart';
60 String cPath = '/test/lib/c.dart'; 64 String cPath = '/test/lib/c.dart';
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 import self as self; 227 import self as self;
224 import "dart:core" as core; 228 import "dart:core" as core;
225 229
226 static method main() → dynamic { 230 static method main() → dynamic {
227 core::double v = 2.3; 231 core::double v = 2.3;
228 } 232 }
229 '''); 233 ''');
230 } 234 }
231 } 235 }
232 236
237 test_inferPackagesFile() async {
238 writeFile('/test/.packages', 'test:lib/');
239 String aPath = '/test/lib/a.dart';
240 String bPath = '/test/lib/b.dart';
241 writeFile(aPath, 'var a = 1;');
242 Uri bUri = writeFile(bPath, r'''
243 import "package:test/a.dart";
244 var b = a;
245 ''');
246
247 // Ensures that the `.packages` file can be discovered automatically
248 // from the entry point file.
249 Program program = await getInitialState(bUri, setPackages: false);
250 Library library = _getLibrary(program, bUri);
251 expect(_getLibraryText(library), r'''
252 library;
253 import self as self;
254 import "dart:core" as core;
255 import "package:test/a.dart" as a;
256
257 static field core::int b = a::a;
258 ''');
259 }
260
233 test_watch() async { 261 test_watch() async {
234 writeFile('/test/.packages', 'test:lib/'); 262 writeFile('/test/.packages', 'test:lib/');
235 String aPath = '/test/lib/a.dart'; 263 String aPath = '/test/lib/a.dart';
236 String bPath = '/test/lib/b.dart'; 264 String bPath = '/test/lib/b.dart';
237 String cPath = '/test/lib/c.dart'; 265 String cPath = '/test/lib/c.dart';
238 Uri aUri = writeFile(aPath, ''); 266 Uri aUri = writeFile(aPath, '');
239 Uri bUri = writeFile(bPath, ''); 267 Uri bUri = writeFile(bPath, '');
240 Uri cUri = writeFile(cPath, r''' 268 Uri cUri = writeFile(cPath, r'''
241 import 'a.dart'; 269 import 'a.dart';
242 '''); 270 ''');
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 throw fail('No library found with URI "$uri"'); 380 throw fail('No library found with URI "$uri"');
353 } 381 }
354 382
355 String _getLibraryText(Library library) { 383 String _getLibraryText(Library library) {
356 StringBuffer buffer = new StringBuffer(); 384 StringBuffer buffer = new StringBuffer();
357 new Printer(buffer, syntheticNames: new NameSystem()) 385 new Printer(buffer, syntheticNames: new NameSystem())
358 .writeLibraryFile(library); 386 .writeLibraryFile(library);
359 return buffer.toString(); 387 return buffer.toString();
360 } 388 }
361 } 389 }
OLDNEW
« no previous file with comments | « pkg/front_end/lib/incremental_kernel_generator.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698