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

Side by Side Diff: pkg/front_end/test/src/incremental/file_state_test.dart

Issue 2929363002: Implement GC for FileState(s). (Closed)
Patch Set: 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
« no previous file with comments | « pkg/front_end/lib/src/incremental_kernel_generator_impl.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/memory_file_system.dart'; 7 import 'package:front_end/memory_file_system.dart';
8 import 'package:front_end/src/fasta/translate_uri.dart'; 8 import 'package:front_end/src/fasta/translate_uri.dart';
9 import 'package:front_end/src/incremental/file_state.dart'; 9 import 'package:front_end/src/incremental/file_state.dart';
10 import 'package:test/test.dart'; 10 import 'package:test/test.dart';
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 foo() { 134 foo() {
135 print(22); 135 print(22);
136 } 136 }
137 bar() { 137 bar() {
138 print(33); 138 print(33);
139 } 139 }
140 baz() => 44; 140 baz() => 44;
141 '''); 141 ''');
142 } 142 }
143 143
144 test_gc() async {
145 var a = writeFile('/a.dart', '');
146 var b = writeFile('/b.dart', '');
147 var c = writeFile('/c.dart', 'import "a.dart";');
148 var d = writeFile('/d.dart', 'import "b.dart";');
149 var e = writeFile(
150 '/e.dart',
151 r'''
152 import "c.dart";
153 import "d.dart";
154 ''');
155
156 var eFile = await fsState.getFile(e);
157
158 // The root and four files.
159 expect(fsState.fileUris, contains(e));
160 expect(fsState.fileUris, contains(a));
161 expect(fsState.fileUris, contains(b));
162 expect(fsState.fileUris, contains(c));
163 expect(fsState.fileUris, contains(d));
164
165 // No changes after GC.
166 fsState.gc(e);
167 expect(fsState.fileUris, contains(e));
168 expect(fsState.fileUris, contains(a));
169 expect(fsState.fileUris, contains(b));
170 expect(fsState.fileUris, contains(c));
171 expect(fsState.fileUris, contains(d));
172
173 // Update e.dart so that it does not reference c.dart anymore.
174 // Then GC removes both c.dart and a.dart it references.
175 writeFile(
176 '/e.dart',
177 r'''
178 import "d.dart";
179 ''');
180 await eFile.refresh();
181 fsState.gc(e);
182 expect(fsState.fileUris, contains(e));
183 expect(fsState.fileUris, isNot(contains(a)));
184 expect(fsState.fileUris, contains(b));
185 expect(fsState.fileUris, isNot(contains(c)));
186 expect(fsState.fileUris, contains(d));
187 }
188
144 test_getFile() async { 189 test_getFile() async {
145 var a = writeFile('/a.dart', ''); 190 var a = writeFile('/a.dart', '');
146 var b = writeFile('/b.dart', ''); 191 var b = writeFile('/b.dart', '');
147 var c = writeFile('/c.dart', ''); 192 var c = writeFile('/c.dart', '');
148 var d = writeFile( 193 var d = writeFile(
149 '/d.dart', 194 '/d.dart',
150 r''' 195 r'''
151 import "a.dart"; 196 import "a.dart";
152 export "b.dart"; 197 export "b.dart";
153 part "c.dart"; 198 part "c.dart";
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 Uri _writeFileDirectives(String path, 388 Uri _writeFileDirectives(String path,
344 {List<String> imports: const [], List<String> exports: const []}) { 389 {List<String> imports: const [], List<String> exports: const []}) {
345 return writeFile( 390 return writeFile(
346 path, 391 path,
347 ''' 392 '''
348 ${imports.map((uri) => 'import "$uri";').join('\n')} 393 ${imports.map((uri) => 'import "$uri";').join('\n')}
349 ${exports.map((uri) => 'export "$uri";').join('\n')} 394 ${exports.map((uri) => 'export "$uri";').join('\n')}
350 '''); 395 ''');
351 } 396 }
352 } 397 }
OLDNEW
« no previous file with comments | « pkg/front_end/lib/src/incremental_kernel_generator_impl.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698