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

Side by Side Diff: tests/compiler/dart2js/kernel/closed_world_from_dill.dart

Issue 2865693002: Create closed world for hello world using .dill file (Closed)
Patch Set: Update and fix. Created 3 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
(Empty)
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
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.
4
5 // Partial test that the closed world computed from [WorldImpact]s derived from
6 // kernel is equivalent to the original computed from resolution.
7 // TODO(johnniwinther): Rename this file to `closed_wordl_from_dill_test.dart`
Siggi Cherem (dart-lang) 2017/05/15 17:05:50 I rather keep this as a test name so you can run i
Johnni Winther 2017/05/16 08:29:54 Done.
8 // when `patched_dart2js_sdk` is available on the build bot.
9 library dart2js.kernel.closed_world_from_dill_test;
10
11 import 'dart:async';
12 import 'dart:io';
13
14 import 'package:async_helper/async_helper.dart';
15 import 'package:compiler/src/commandline_options.dart';
16 import 'package:compiler/src/common.dart';
17 import 'package:compiler/src/compiler.dart';
18 import 'package:compiler/src/elements/resolution_types.dart';
19 import 'package:compiler/src/elements/types.dart';
20 import 'package:compiler/src/enqueue.dart';
21 import 'package:compiler/src/kernel/element_map.dart';
22 import 'package:compiler/src/kernel/kernel_strategy.dart';
23 import 'package:compiler/src/resolution/enum_creator.dart';
24 import 'package:compiler/src/universe/world_builder.dart';
25 import 'package:compiler/src/world.dart';
26 import 'package:expect/expect.dart';
27 import '../memory_compiler.dart';
28 import '../equivalence/check_functions.dart';
29 import '../serialization/helper.dart';
30 import 'test_helpers.dart';
31
32 import 'compiler_helper.dart';
33
34 const SOURCE = const {
35 'main.dart': '''
36 main() {
37 print('Hello World');
38 }
39 '''
40 };
41
42 main(List<String> args) {
43 asyncTest(() async {
44 await mainInternal(args);
45 });
46 }
47
48 enum ResultKind { crashes, errors, warnings, success, failure }
49
50 Future<ResultKind> mainInternal(List<String> args,
51 {bool skipWarnings: false, bool skipErrors: false}) async {
52 Arguments arguments = new Arguments.from(args);
53 Uri entryPoint;
54 Map<String, String> memorySourceFiles;
55 if (arguments.uri != null) {
56 entryPoint = arguments.uri;
57 memorySourceFiles = const <String, String>{};
58 } else {
59 entryPoint = Uri.parse('memory:main.dart');
60 memorySourceFiles = SOURCE;
61 }
62
63 enableDebugMode();
64 EnumCreator.USE_CONSTANT_MAP_IN_TO_STRING = true;
65
66 Directory dir = await Directory.systemTemp.createTemp('dart2js-with-dill');
67 print('--- create temp directory $dir -------------------------------');
68 memorySourceFiles.forEach((String name, String source) {
69 new File.fromUri(dir.uri.resolve(name)).writeAsStringSync(source);
70 });
71 entryPoint = dir.uri.resolve(entryPoint.path);
72
73 print('---- analyze-only ------------------------------------------------');
74 DiagnosticCollector collector = new DiagnosticCollector();
75 Compiler compiler1 = compilerFor(
76 entryPoint: entryPoint,
77 diagnosticHandler: collector,
78 options: [Flags.analyzeOnly, Flags.enableAssertMessage]);
79 ElementResolutionWorldBuilder.useInstantiationMap = true;
80 compiler1.resolution.retainCachesForTesting = true;
81 await compiler1.run(entryPoint);
82 if (collector.crashes.isNotEmpty) {
83 print('Skipping due to crashes.');
84 return ResultKind.crashes;
85 }
86 if (collector.errors.isNotEmpty && skipErrors) {
87 print('Skipping due to errors.');
88 return ResultKind.errors;
89 }
90 if (collector.warnings.isNotEmpty && skipWarnings) {
91 print('Skipping due to warnings.');
92 return ResultKind.warnings;
93 }
94 Expect.isFalse(compiler1.compilationFailed);
95 ResolutionEnqueuer enqueuer1 = compiler1.enqueuer.resolution;
96 ClosedWorld closedWorld1 = compiler1.resolutionWorldBuilder.closeWorld();
97
98 Compiler compiler2 =
99 await compileWithDill(entryPoint, const {}, printSteps: true);
100
101 KernelFrontEndStrategy frontEndStrategy = compiler2.frontEndStrategy;
102 KernelToElementMap elementMap = frontEndStrategy.elementMap;
103
104 Expect.isFalse(compiler2.compilationFailed);
105
106 KernelEquivalence equivalence = new KernelEquivalence(elementMap);
107
108 ResolutionEnqueuer enqueuer2 = compiler2.enqueuer.resolution;
109 ClosedWorld closedWorld2 = compiler2.resolutionWorldBuilder.closeWorld();
110
111 checkBackendUsage(closedWorld1.backendUsage, closedWorld2.backendUsage,
112 equivalence.defaultStrategy);
113
114 checkResolutionEnqueuers(closedWorld1.backendUsage, closedWorld2.backendUsage,
115 enqueuer1, enqueuer2, elementEquivalence: equivalence.entityEquivalence,
116 typeEquivalence: (ResolutionDartType a, DartType b) {
117 return equivalence.typeEquivalence(unalias(a), b);
118 }, elementFilter: elementFilter, verbose: arguments.verbose);
119
120 checkClosedWorlds(closedWorld1, closedWorld2,
121 strategy: equivalence.defaultStrategy, verbose: arguments.verbose);
122
123 return ResultKind.success;
124 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698