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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/front_end/lib/src/vm/reload.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/front_end/lib/src/testing/hybrid_file_system.dart
diff --git a/pkg/front_end/lib/src/testing/hybrid_file_system.dart b/pkg/front_end/lib/src/testing/hybrid_file_system.dart
new file mode 100644
index 0000000000000000000000000000000000000000..e69d61d4dde2257e30691116ca9454862f693968
--- /dev/null
+++ b/pkg/front_end/lib/src/testing/hybrid_file_system.dart
@@ -0,0 +1,55 @@
+// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+/// A memory + physical file system used to mock input for tests but provide
+/// sdk sources from disk.
+library front_end.src.hybrid_file_system;
+
+import 'dart:async';
+
+import 'package:front_end/file_system.dart';
+import 'package:front_end/memory_file_system.dart';
+import 'package:front_end/physical_file_system.dart';
+
+/// A file system that mixes files from memory and a physical file system. All
+/// memory entities take priotity over file system entities.
+class HybridFileSystem implements FileSystem {
+ final MemoryFileSystem memory;
+ final PhysicalFileSystem physical = PhysicalFileSystem.instance;
+
+ HybridFileSystem(this.memory);
+
+ @override
+ FileSystemEntity entityForUri(Uri uri) => new HybridFileSystemEntity(
+ memory.entityForUri(uri), physical.entityForUri(uri));
+}
+
+/// Entity that delegates to an underlying memory or phisical file system
+/// entity.
+class HybridFileSystemEntity implements FileSystemEntity {
+ final FileSystemEntity memory;
+ final FileSystemEntity physical;
+
+ HybridFileSystemEntity(this.memory, this.physical);
+
+ FileSystemEntity _delegate;
+ Future<FileSystemEntity> get delegate async {
+ return _delegate ??= (await memory.exists()) ? memory : physical;
+ }
+
+ @override
+ Uri get uri => memory.uri;
+
+ @override
+ Future<bool> exists() async => (await delegate).exists();
+
+ @override
+ Future<DateTime> lastModified() async => (await delegate).lastModified();
+
+ @override
+ Future<List<int>> readAsBytes() async => (await delegate).readAsBytes();
+
+ @override
+ Future<String> readAsString() async => (await delegate).readAsString();
+}
« 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