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

Unified Diff: tests/compiler/dart2js/serialization/helper.dart

Issue 2013763002: Add names and support for preserialized data to serialization tests (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comments. Created 4 years, 7 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
Index: tests/compiler/dart2js/serialization/helper.dart
diff --git a/tests/compiler/dart2js/serialization/helper.dart b/tests/compiler/dart2js/serialization/helper.dart
index 04716588b38a2bcfffe77324ac5a0f79bb55c9e3..a7d185c50cd941fa903774dd1fb853e8082c1372 100644
--- a/tests/compiler/dart2js/serialization/helper.dart
+++ b/tests/compiler/dart2js/serialization/helper.dart
@@ -10,6 +10,7 @@ import 'dart:io';
import 'package:compiler/src/commandline_options.dart';
import 'package:compiler/src/common/names.dart';
import 'package:compiler/src/compiler.dart';
+import 'package:compiler/src/elements/elements.dart';
import '../memory_compiler.dart';
import 'test_data.dart';
@@ -70,16 +71,45 @@ class Arguments {
saveSerializedData: saveSerializedData);
}
- Future forEachTest(List<Test> tests, Future f(int index, Test test)) async {
+ Future forEachTest(
+ SerializedData serializedData,
+ List<Test> tests,
+ TestFunction testFunction) async {
+ Uri entryPoint = Uri.parse('memory:main.dart');
int first = start ?? 0;
int last = end ?? tests.length - 1;
+
for (int index = first; index <= last; index++) {
Test test = TESTS[index];
- await f(index, test);
+ List<SerializedData> dataList =
+ await preserializeData(serializedData, test);
+ Map<String, String> sourceFiles = <String, String>{};
+ sourceFiles.addAll(test.sourceFiles);
+ if (test.preserializedSourceFiles != null) {
+ sourceFiles.addAll(test.preserializedSourceFiles);
+ }
+ List<Uri> resolutionInputs = <Uri>[];
+ for (SerializedData data in dataList) {
+ data.expandMemorySourceFiles(sourceFiles);
+ data.expandUris(resolutionInputs);
+ }
+ await testFunction(entryPoint,
+ sourceFiles: sourceFiles,
+ resolutionInputs: resolutionInputs,
+ index: index,
+ test: test,
+ verbose: verbose);
}
}
}
+typedef Future TestFunction(
+ Uri entryPoint,
+ {Map<String, String> sourceFiles,
+ List<Uri> resolutionInputs,
+ int index,
+ Test test,
+ bool verbose});
Future<SerializedData> serializeDartCore(
{Arguments arguments: const Arguments()}) async {
@@ -146,4 +176,40 @@ class SerializedData {
void expandUris(List<Uri> uris) {
uris.add(uri);
}
-}
+}
+
+String extractSerializedData(
+ Compiler compiler, Iterable<LibraryElement> libraries) {
+ BufferedEventSink sink = new BufferedEventSink();
+ compiler.serialization.serializeToSink(sink, libraries);
+ return sink.text;
+}
+
+Future<List<SerializedData>> preserializeData(
+ SerializedData serializedData, Test test) async {
+ if (test == null ||
+ test.preserializedSourceFiles == null ||
+ test.preserializedSourceFiles.isEmpty) {
+ return <SerializedData>[serializedData];
+ }
+ List<Uri> uriList = <Uri>[];
+ for (String key in test.preserializedSourceFiles.keys) {
+ uriList.add(Uri.parse('memory:$key'));
+ }
+ Compiler compiler = compilerFor(
+ memorySourceFiles:
+ serializedData.toMemorySourceFiles(test.preserializedSourceFiles),
+ resolutionInputs: serializedData.toUris(),
+ options: [Flags.analyzeOnly, Flags.analyzeMain]);
+ compiler.librariesToAnalyzeWhenRun = uriList;
+ compiler.serialization.supportSerialization = true;
+ await compiler.run(null);
+ List<LibraryElement> libraries = <LibraryElement>[];
+ for (Uri uri in uriList) {
+ libraries.add(compiler.libraryLoader.lookupLibrary(uri));
+ }
+ SerializedData additionalSerializedData =
+ new SerializedData(Uri.parse('memory:additional.data'),
+ extractSerializedData(compiler, libraries));
+ return <SerializedData>[serializedData, additionalSerializedData];
+}
« no previous file with comments | « tests/compiler/dart2js/serialization/compilation_test.dart ('k') | tests/compiler/dart2js/serialization/model_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698