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

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

Issue 2928483005: Add an incremental reloader example and a utility tool to trigger a reload by (Closed)
Patch Set: CL comments Created 3 years, 6 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/incremental/byte_store.dart'; 10 import 'package:front_end/src/incremental/byte_store.dart';
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 656
657 static field core::String a = "aaa"; 657 static field core::String a = "aaa";
658 static field core::double c = self::b; 658 static field core::double c = self::b;
659 static field core::double b = 2.3 /* from file:///test/lib/bar.dart */; 659 static field core::double b = 2.3 /* from file:///test/lib/bar.dart */;
660 static field core::String d = self::a /* from file:///test/lib/bar.dart */; 660 static field core::String d = self::a /* from file:///test/lib/bar.dart */;
661 static method main() → void {} 661 static method main() → void {}
662 '''); 662 ''');
663 } 663 }
664 } 664 }
665 665
666 test_invalidateAll() async {
667 writeFile('/test/.packages', '');
668 Uri aUri = writeFile('/test/a.dart', "import 'b.dart';\nint a = b;");
669 Uri bUri = writeFile('/test/b.dart', 'var b = 1;');
670
671 Program program = await getInitialState(aUri);
672 expect(_getLibraryText(_getLibrary(program, aUri)), contains("int a ="));
Siggi Cherem (dart-lang) 2017/06/07 20:17:11 Let me know if you prefer that I check the full te
scheglov 2017/06/07 20:26:32 Verifying only relevant parts is perfectly fine.
Siggi Cherem (dart-lang) 2017/06/07 20:51:09 I have highlighting too :) - the problem is that I
673 expect(_getLibraryText(_getLibrary(program, bUri)), contains("b = 1"));
674
675 writeFile('/test/a.dart', "import 'b.dart';\ndouble a = b;");
676 writeFile('/test/b.dart', 'var b = 2;');
677 incrementalKernelGenerator.invalidateAll();
678
679 DeltaProgram delta = await incrementalKernelGenerator.computeDelta();
680 program = delta.newProgram;
681 _assertLibraryUris(program, includes: [aUri, bUri]);
682 expect(_getLibraryText(_getLibrary(program, aUri)), contains("double a ="));
683 expect(_getLibraryText(_getLibrary(program, bUri)), contains("b = 2"));
684 }
685
666 /// Write the given [text] of the file with the given [path] into the 686 /// Write the given [text] of the file with the given [path] into the
667 /// virtual filesystem. Return the URI of the file. 687 /// virtual filesystem. Return the URI of the file.
668 Uri writeFile(String path, String text) { 688 Uri writeFile(String path, String text) {
669 Uri uri = Uri.parse('file://$path'); 689 Uri uri = Uri.parse('file://$path');
670 fileSystem.entityForUri(uri).writeAsStringSync(text); 690 fileSystem.entityForUri(uri).writeAsStringSync(text);
671 return uri; 691 return uri;
672 } 692 }
673 693
674 /// Write the given file contents to the virtual filesystem. 694 /// Write the given file contents to the virtual filesystem.
675 void writeFiles(Map<String, String> contents) { 695 void writeFiles(Map<String, String> contents) {
(...skipping 19 matching lines...) Expand all
695 throw fail('No library found with URI "$uri"'); 715 throw fail('No library found with URI "$uri"');
696 } 716 }
697 717
698 String _getLibraryText(Library library) { 718 String _getLibraryText(Library library) {
699 StringBuffer buffer = new StringBuffer(); 719 StringBuffer buffer = new StringBuffer();
700 new Printer(buffer, syntheticNames: new NameSystem()) 720 new Printer(buffer, syntheticNames: new NameSystem())
701 .writeLibraryFile(library); 721 .writeLibraryFile(library);
702 return buffer.toString(); 722 return buffer.toString();
703 } 723 }
704 } 724 }
OLDNEW
« no previous file with comments | « pkg/front_end/lib/src/incremental_kernel_generator_impl.dart ('k') | pkg/front_end/tool/vm/reload.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698