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

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

Issue 2993393002: Enforce single computeDelta() invocation. (Closed)
Patch Set: 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
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/byte_store/byte_store.dart'; 10 import 'package:front_end/src/byte_store/byte_store.dart';
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 compilerOptions.packagesFileUri = Uri.parse('file:///test/.packages'); 53 compilerOptions.packagesFileUri = Uri.parse('file:///test/.packages');
54 } 54 }
55 incrementalKernelGenerator = await IncrementalKernelGenerator 55 incrementalKernelGenerator = await IncrementalKernelGenerator
56 .newInstance(compilerOptions, entryPoint, watch: watchFn); 56 .newInstance(compilerOptions, entryPoint, watch: watchFn);
57 return (await incrementalKernelGenerator.computeDelta()).newProgram; 57 return (await incrementalKernelGenerator.computeDelta()).newProgram;
58 } 58 }
59 59
60 test_acceptLastDelta() async { 60 test_acceptLastDelta() async {
61 writeFile('/test/.packages', 'test:lib/'); 61 writeFile('/test/.packages', 'test:lib/');
62 String path = '/test/lib/test.dart'; 62 String path = '/test/lib/test.dart';
63 Uri uri = writeFile(path, 'var v = 1;'); 63 Uri uri = writeFile(path, '');
64 64
65 await getInitialState(uri); 65 await getInitialState(uri);
66 incrementalKernelGenerator.acceptLastDelta(); 66 incrementalKernelGenerator.acceptLastDelta();
67 67
68 // Attempt to accept the second time. 68 // Attempt to accept the second time.
69 expect(() { 69 expect(() {
70 incrementalKernelGenerator.acceptLastDelta(); 70 incrementalKernelGenerator.acceptLastDelta();
71 }, throwsStateError); 71 }, throwsStateError);
72 } 72 }
73 73
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 expect(_getLibraryText(library), r'''library; 216 expect(_getLibraryText(library), r'''library;
217 import self as self; 217 import self as self;
218 import "dart:core" as core; 218 import "dart:core" as core;
219 import "dart:async" as asy; 219 import "dart:async" as asy;
220 220
221 static field core::int a = 1; 221 static field core::int a = 1;
222 static field asy::Future<core::String> b; 222 static field asy::Future<core::String> b;
223 '''); 223 ''');
224 } 224 }
225 225
226 test_computeDelta_hasAnotherRunning() async {
227 writeFile('/test/.packages', 'test:lib/');
228 String path = '/test/lib/test.dart';
229 Uri uri = writeFile(path, '');
230
231 await getInitialState(uri);
232 incrementalKernelGenerator.acceptLastDelta();
233
234 // Run, but don't wait.
235 incrementalKernelGenerator.computeDelta();
Siggi Cherem (dart-lang) 2017/08/10 22:43:29 we might want to store the future returned by this
scheglov 2017/08/10 23:46:49 Done.
236
237 // Run another, this causes StateError.
238 try {
239 await incrementalKernelGenerator.computeDelta();
Siggi Cherem (dart-lang) 2017/08/10 22:43:29 Could this be flaky? In particular, is it at all
scheglov 2017/08/10 23:46:49 I changed computeDelta() to check _isComputeDeltaE
240 fail('StateError expected.');
241 } on StateError {}
Siggi Cherem (dart-lang) 2017/08/10 22:43:29 there are two reasons why computeDelta could throw
scheglov 2017/08/10 23:46:50 Well, there is no great way to do this. I had to u
242 }
243
226 test_inferPackagesFile() async { 244 test_inferPackagesFile() async {
227 writeFile('/test/.packages', 'test:lib/'); 245 writeFile('/test/.packages', 'test:lib/');
228 String aPath = '/test/lib/a.dart'; 246 String aPath = '/test/lib/a.dart';
229 String bPath = '/test/lib/b.dart'; 247 String bPath = '/test/lib/b.dart';
230 writeFile(aPath, 'var a = 1;'); 248 writeFile(aPath, 'var a = 1;');
231 Uri bUri = writeFile(bPath, r''' 249 Uri bUri = writeFile(bPath, r'''
232 import "package:test/a.dart"; 250 import "package:test/a.dart";
233 var b = a; 251 var b = a;
234 '''); 252 ''');
235 253
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 throw fail('No library found with URI "$uri"'); 491 throw fail('No library found with URI "$uri"');
474 } 492 }
475 493
476 String _getLibraryText(Library library) { 494 String _getLibraryText(Library library) {
477 StringBuffer buffer = new StringBuffer(); 495 StringBuffer buffer = new StringBuffer();
478 new Printer(buffer, syntheticNames: new NameSystem()) 496 new Printer(buffer, syntheticNames: new NameSystem())
479 .writeLibraryFile(library); 497 .writeLibraryFile(library);
480 return buffer.toString(); 498 return buffer.toString();
481 } 499 }
482 } 500 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698