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

Side by Side Diff: tests/compiler/dart2js/serialization/model_test.dart

Issue 2004833003: Support multiple resolution inputs from command line. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Fix and check library separation 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 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';
11 import 'package:compiler/src/closure.dart'; 11 import 'package:compiler/src/closure.dart';
12 import 'package:compiler/src/commandline_options.dart'; 12 import 'package:compiler/src/commandline_options.dart';
13 import 'package:compiler/src/compiler.dart'; 13 import 'package:compiler/src/compiler.dart';
14 import 'package:compiler/src/elements/elements.dart'; 14 import 'package:compiler/src/elements/elements.dart';
15 import 'package:compiler/src/filenames.dart'; 15 import 'package:compiler/src/filenames.dart';
16 import 'package:compiler/src/serialization/equivalence.dart'; 16 import 'package:compiler/src/serialization/equivalence.dart';
17 import 'package:compiler/src/tree/nodes.dart'; 17 import 'package:compiler/src/tree/nodes.dart';
18 import 'package:compiler/src/universe/class_set.dart'; 18 import 'package:compiler/src/universe/class_set.dart';
19 import '../memory_compiler.dart'; 19 import '../memory_compiler.dart';
20 import 'helper.dart'; 20 import 'helper.dart';
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 String serializedData = await serializeDartCore(arguments: arguments); 27 SerializedData serializedData =
28 await serializeDartCore(arguments: arguments);
28 if (arguments.filename != null) { 29 if (arguments.filename != null) {
29 Uri entryPoint = Uri.base.resolve(nativeToUriPath(arguments.filename)); 30 Uri entryPoint = Uri.base.resolve(nativeToUriPath(arguments.filename));
30 await checkModels(serializedData, entryPoint); 31 await checkModels(serializedData, entryPoint);
31 } else { 32 } else {
32 Uri entryPoint = Uri.parse('memory:main.dart'); 33 Uri entryPoint = Uri.parse('memory:main.dart');
33 arguments.forEachTest(TESTS, (int index, Test test) async { 34 arguments.forEachTest(TESTS, (int index, Test test) async {
34 print('=============================================================='); 35 print('==============================================================');
35 print(test.sourceFiles); 36 print(test.sourceFiles);
36 await checkModels( 37 await checkModels(
37 serializedData, 38 serializedData,
38 entryPoint, 39 entryPoint,
39 sourceFiles: test.sourceFiles, 40 memorySourceFiles: test.sourceFiles,
40 verbose: arguments.verbose); 41 verbose: arguments.verbose);
41 }); 42 });
42 } 43 }
43 }); 44 });
44 } 45 }
45 46
46 Future checkModels( 47 Future checkModels(
47 String serializedData, 48 SerializedData serializedData,
48 Uri entryPoint, 49 Uri entryPoint,
49 {Map<String, String> sourceFiles: const <String, String>{}, 50 {Map<String, String> memorySourceFiles: const <String, String>{},
50 bool verbose: false}) async { 51 bool verbose: false}) async {
51 52
52 print('------------------------------------------------------------------'); 53 print('------------------------------------------------------------------');
53 print('compile normal'); 54 print('compile normal');
54 print('------------------------------------------------------------------'); 55 print('------------------------------------------------------------------');
55 Compiler compilerNormal = compilerFor( 56 Compiler compilerNormal = compilerFor(
56 memorySourceFiles: sourceFiles, 57 memorySourceFiles: memorySourceFiles,
57 options: [Flags.analyzeOnly]); 58 options: [Flags.analyzeOnly]);
58 compilerNormal.resolution.retainCachesForTesting = true; 59 compilerNormal.resolution.retainCachesForTesting = true;
59 await compilerNormal.run(entryPoint); 60 await compilerNormal.run(entryPoint);
60 compilerNormal.phase = Compiler.PHASE_DONE_RESOLVING; 61 compilerNormal.phase = Compiler.PHASE_DONE_RESOLVING;
61 compilerNormal.world.populate(); 62 compilerNormal.world.populate();
62 compilerNormal.backend.onResolutionComplete(); 63 compilerNormal.backend.onResolutionComplete();
63 64
64 print('------------------------------------------------------------------'); 65 print('------------------------------------------------------------------');
65 print('compile deserialized'); 66 print('compile deserialized');
66 print('------------------------------------------------------------------'); 67 print('------------------------------------------------------------------');
67 Compiler compilerDeserialized = compilerFor( 68 Compiler compilerDeserialized = compilerFor(
68 memorySourceFiles: sourceFiles, 69 memorySourceFiles: serializedData.toMemorySourceFiles(memorySourceFiles),
70 resolutionInputs: serializedData.toUris(),
69 options: [Flags.analyzeOnly]); 71 options: [Flags.analyzeOnly]);
70 compilerDeserialized.resolution.retainCachesForTesting = true; 72 compilerDeserialized.resolution.retainCachesForTesting = true;
71 compilerDeserialized.serialization.deserializeFromText(serializedData);
72 await compilerDeserialized.run(entryPoint); 73 await compilerDeserialized.run(entryPoint);
73 compilerDeserialized.phase = Compiler.PHASE_DONE_RESOLVING; 74 compilerDeserialized.phase = Compiler.PHASE_DONE_RESOLVING;
74 compilerDeserialized.world.populate(); 75 compilerDeserialized.world.populate();
75 compilerDeserialized.backend.onResolutionComplete(); 76 compilerDeserialized.backend.onResolutionComplete();
76 77
77 checkAllImpacts( 78 checkAllImpacts(
78 compilerNormal, compilerDeserialized, 79 compilerNormal, compilerDeserialized,
79 verbose: verbose); 80 verbose: verbose);
80 81
81 checkSets( 82 checkSets(
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 return true; 392 return true;
392 } 393 }
393 394
394 String nodeToString(Node node) { 395 String nodeToString(Node node) {
395 String text = '$node'; 396 String text = '$node';
396 if (text.length > 40) { 397 if (text.length > 40) {
397 return '(${node.runtimeType}) ${text.substring(0, 37)}...'; 398 return '(${node.runtimeType}) ${text.substring(0, 37)}...';
398 } 399 }
399 return '(${node.runtimeType}) $text'; 400 return '(${node.runtimeType}) $text';
400 } 401 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698