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

Side by Side Diff: pkg/front_end/lib/src/testing/hybrid_file_system.dart

Issue 2925953002: Add integration test: hot reload + incremental compiler (Closed)
Patch Set: address 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
« no previous file with comments | « no previous file | pkg/front_end/lib/src/vm/reload.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 /// A memory + physical file system used to mock input for tests but provide
6 /// sdk sources from disk.
7 library front_end.src.hybrid_file_system;
8
9 import 'dart:async';
10
11 import 'package:front_end/file_system.dart';
12 import 'package:front_end/memory_file_system.dart';
13 import 'package:front_end/physical_file_system.dart';
14
15 /// A file system that mixes files from memory and a physical file system. All
16 /// memory entities take priotity over file system entities.
17 class HybridFileSystem implements FileSystem {
18 final MemoryFileSystem memory;
19 final PhysicalFileSystem physical = PhysicalFileSystem.instance;
20
21 HybridFileSystem(this.memory);
22
23 @override
24 FileSystemEntity entityForUri(Uri uri) => new HybridFileSystemEntity(
25 memory.entityForUri(uri), physical.entityForUri(uri));
26 }
27
28 /// Entity that delegates to an underlying memory or phisical file system
29 /// entity.
30 class HybridFileSystemEntity implements FileSystemEntity {
31 final FileSystemEntity memory;
32 final FileSystemEntity physical;
33
34 HybridFileSystemEntity(this.memory, this.physical);
35
36 FileSystemEntity _delegate;
37 Future<FileSystemEntity> get delegate async {
38 return _delegate ??= (await memory.exists()) ? memory : physical;
39 }
40
41 @override
42 Uri get uri => memory.uri;
43
44 @override
45 Future<bool> exists() async => (await delegate).exists();
46
47 @override
48 Future<DateTime> lastModified() async => (await delegate).lastModified();
49
50 @override
51 Future<List<int>> readAsBytes() async => (await delegate).readAsBytes();
52
53 @override
54 Future<String> readAsString() async => (await delegate).readAsString();
55 }
OLDNEW
« no previous file with comments | « no previous file | pkg/front_end/lib/src/vm/reload.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698