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

Side by Side Diff: tests/compiler/dart2js/serialization/model_test.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, 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
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 library dart2js.serialization_model_test; 5 library dart2js.serialization_model_test;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:io'; 8 import 'dart:io';
9 import 'package:async_helper/async_helper.dart'; 9 import 'package:async_helper/async_helper.dart';
10 import 'package:expect/expect.dart'; 10 import 'package:expect/expect.dart';
(...skipping 10 matching lines...) Expand all
21 import 'test_data.dart'; 21 import 'test_data.dart';
22 import 'test_helper.dart'; 22 import 'test_helper.dart';
23 23
24 main(List<String> args) { 24 main(List<String> args) {
25 asyncTest(() async { 25 asyncTest(() async {
26 Arguments arguments = new Arguments.from(args); 26 Arguments arguments = new Arguments.from(args);
27 SerializedData serializedData = 27 SerializedData serializedData =
28 await serializeDartCore(arguments: arguments); 28 await serializeDartCore(arguments: arguments);
29 if (arguments.filename != null) { 29 if (arguments.filename != null) {
30 Uri entryPoint = Uri.base.resolve(nativeToUriPath(arguments.filename)); 30 Uri entryPoint = Uri.base.resolve(nativeToUriPath(arguments.filename));
31 await checkModels(serializedData, entryPoint); 31 await checkModels(entryPoint,
32 sourceFiles: serializedData.toMemorySourceFiles(),
33 resolutionInputs: serializedData.toUris());
32 } else { 34 } else {
33 Uri entryPoint = Uri.parse('memory:main.dart'); 35 Uri entryPoint = Uri.parse('memory:main.dart');
34 arguments.forEachTest(TESTS, (int index, Test test) async { 36 arguments.forEachTest(serializedData, TESTS, checkModels);
35 print('==============================================================');
36 print(test.sourceFiles);
37 await checkModels(
38 serializedData,
39 entryPoint,
40 memorySourceFiles: test.sourceFiles,
41 verbose: arguments.verbose);
42 });
43 } 37 }
44 }); 38 });
45 } 39 }
46 40
47 Future checkModels( 41 Future checkModels(
48 SerializedData serializedData,
49 Uri entryPoint, 42 Uri entryPoint,
50 {Map<String, String> memorySourceFiles: const <String, String>{}, 43 {Map<String, String> sourceFiles: const <String, String>{},
51 bool verbose: false}) async { 44 List<Uri> resolutionInputs,
45 int index,
46 Test test,
47 bool verbose: false}) async {
52 48
49 String testDescription = test != null ? test.name : '${entryPoint}';
50 String id = index != null ? '$index: ' : '';
53 print('------------------------------------------------------------------'); 51 print('------------------------------------------------------------------');
54 print('compile normal'); 52 print('compile normal ${id}${testDescription}');
55 print('------------------------------------------------------------------'); 53 print('------------------------------------------------------------------');
56 Compiler compilerNormal = compilerFor( 54 Compiler compilerNormal = compilerFor(
57 memorySourceFiles: memorySourceFiles, 55 memorySourceFiles: sourceFiles,
58 options: [Flags.analyzeOnly]); 56 options: [Flags.analyzeOnly]);
59 compilerNormal.resolution.retainCachesForTesting = true; 57 compilerNormal.resolution.retainCachesForTesting = true;
60 await compilerNormal.run(entryPoint); 58 await compilerNormal.run(entryPoint);
61 compilerNormal.phase = Compiler.PHASE_DONE_RESOLVING; 59 compilerNormal.phase = Compiler.PHASE_DONE_RESOLVING;
62 compilerNormal.world.populate(); 60 compilerNormal.world.populate();
63 compilerNormal.backend.onResolutionComplete(); 61 compilerNormal.backend.onResolutionComplete();
64 62
65 print('------------------------------------------------------------------'); 63 print('------------------------------------------------------------------');
66 print('compile deserialized'); 64 print('compile deserialized ${id}${testDescription}');
67 print('------------------------------------------------------------------'); 65 print('------------------------------------------------------------------');
68 Compiler compilerDeserialized = compilerFor( 66 Compiler compilerDeserialized = compilerFor(
69 memorySourceFiles: serializedData.toMemorySourceFiles(memorySourceFiles), 67 memorySourceFiles: sourceFiles,
70 resolutionInputs: serializedData.toUris(), 68 resolutionInputs: resolutionInputs,
71 options: [Flags.analyzeOnly]); 69 options: [Flags.analyzeOnly]);
72 compilerDeserialized.resolution.retainCachesForTesting = true; 70 compilerDeserialized.resolution.retainCachesForTesting = true;
73 await compilerDeserialized.run(entryPoint); 71 await compilerDeserialized.run(entryPoint);
74 compilerDeserialized.phase = Compiler.PHASE_DONE_RESOLVING; 72 compilerDeserialized.phase = Compiler.PHASE_DONE_RESOLVING;
75 compilerDeserialized.world.populate(); 73 compilerDeserialized.world.populate();
76 compilerDeserialized.backend.onResolutionComplete(); 74 compilerDeserialized.backend.onResolutionComplete();
77 75
78 checkAllImpacts( 76 checkAllImpacts(
79 compilerNormal, compilerDeserialized, 77 compilerNormal, compilerDeserialized,
80 verbose: verbose); 78 verbose: verbose);
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 return true; 390 return true;
393 } 391 }
394 392
395 String nodeToString(Node node) { 393 String nodeToString(Node node) {
396 String text = '$node'; 394 String text = '$node';
397 if (text.length > 40) { 395 if (text.length > 40) {
398 return '(${node.runtimeType}) ${text.substring(0, 37)}...'; 396 return '(${node.runtimeType}) ${text.substring(0, 37)}...';
399 } 397 }
400 return '(${node.runtimeType}) $text'; 398 return '(${node.runtimeType}) $text';
401 } 399 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/serialization/helper.dart ('k') | tests/compiler/dart2js/serialization/resolved_ast_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698