Index: tests/compiler/dart2js/serialization/helper.dart |
diff --git a/tests/compiler/dart2js/serialization/helper.dart b/tests/compiler/dart2js/serialization/helper.dart |
index cde182f22e2b5ff548f7a41838936ca591c4c278..04716588b38a2bcfffe77324ac5a0f79bb55c9e3 100644 |
--- a/tests/compiler/dart2js/serialization/helper.dart |
+++ b/tests/compiler/dart2js/serialization/helper.dart |
@@ -81,17 +81,18 @@ class Arguments { |
} |
-Future<String> serializeDartCore( |
+Future<SerializedData> serializeDartCore( |
{Arguments arguments: const Arguments()}) async { |
+ Uri uri = Uri.parse('memory:${arguments.serializedDataFileName}'); |
print('------------------------------------------------------------------'); |
print('serialize dart:core'); |
print('------------------------------------------------------------------'); |
- String serializedData; |
+ SerializedData serializedData; |
if (arguments.loadSerializedData) { |
File file = new File(arguments.serializedDataFileName); |
if (file.existsSync()) { |
print('Loading data from $file'); |
- serializedData = file.readAsStringSync(); |
+ serializedData = new SerializedData(uri, file.readAsStringSync()); |
} |
} |
if (serializedData == null) { |
@@ -102,12 +103,47 @@ Future<String> serializeDartCore( |
BufferedEventSink sink = new BufferedEventSink(); |
compiler.serialization.serializeToSink( |
sink, compiler.libraryLoader.libraries); |
- serializedData = sink.text; |
+ serializedData = new SerializedData(uri, sink.text); |
if (arguments.saveSerializedData) { |
File file = new File(arguments.serializedDataFileName); |
print('Saving data to $file'); |
- file.writeAsStringSync(serializedData); |
+ file.writeAsStringSync(serializedData.data); |
} |
} |
return serializedData; |
} |
+ |
+class SerializedData { |
+ final Uri uri; |
+ final String data; |
+ |
+ SerializedData(this.uri, this.data); |
+ |
+ Map<String, String> toMemorySourceFiles([Map<String, String> input]) { |
+ Map<String, String> sourceFiles = <String, String>{}; |
+ if (input != null) { |
+ sourceFiles.addAll(input); |
+ } |
+ expandMemorySourceFiles(sourceFiles); |
+ return sourceFiles; |
+ } |
+ |
+ void expandMemorySourceFiles(Map<String, String> sourceFiles) { |
+ if (uri.scheme == 'memory') { |
+ sourceFiles[uri.path] = data; |
+ } |
+ } |
+ |
+ List<Uri> toUris([List<Uri> input]) { |
+ List<Uri> uris = <Uri>[]; |
+ if (input != null) { |
+ uris.addAll(input); |
+ } |
+ expandUris(uris); |
+ return uris; |
+ } |
+ |
+ void expandUris(List<Uri> uris) { |
+ uris.add(uri); |
+ } |
+} |