OLD | NEW |
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 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 | 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 // Test that we can compile from dill and run the generated code with d8. | 5 // Test that we can compile from dill and run the generated code with d8. |
6 library dart2js.kernel.run_from_dill_test; | 6 library dart2js.kernel.run_from_dill_test; |
7 | 7 |
8 import 'dart:async'; | 8 import 'dart:async'; |
9 import 'dart:io'; | 9 import 'dart:io'; |
10 | 10 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 Map<String, String> memorySourceFiles; | 55 Map<String, String> memorySourceFiles; |
56 if (arguments.uri != null) { | 56 if (arguments.uri != null) { |
57 entryPoint = arguments.uri; | 57 entryPoint = arguments.uri; |
58 memorySourceFiles = const <String, String>{}; | 58 memorySourceFiles = const <String, String>{}; |
59 } else { | 59 } else { |
60 entryPoint = Uri.parse('memory:main.dart'); | 60 entryPoint = Uri.parse('memory:main.dart'); |
61 memorySourceFiles = SOURCE; | 61 memorySourceFiles = SOURCE; |
62 } | 62 } |
63 | 63 |
64 Uri dillFile = | 64 Uri dillFile = |
65 await createTemp(entryPoint, memorySourceFiles, printSteps: true); | 65 await generateDill(entryPoint, memorySourceFiles, printSteps: true); |
66 String output = uriPathToNative(dillFile.resolve('out.js').path); | 66 String output = uriPathToNative(dillFile.resolve('out.js').path); |
67 List<String> dart2jsArgs = [ | 67 List<String> dart2jsArgs = [ |
68 dillFile.toString(), | 68 dillFile.toString(), |
69 '-o$output', | 69 '-o$output', |
70 Flags.loadFromDill, | 70 Flags.loadFromDill, |
71 Flags.disableTypeInference, | 71 Flags.disableTypeInference, |
72 Flags.disableInlining, | 72 Flags.disableInlining, |
73 Flags.enableAssertMessage | 73 Flags.enableAssertMessage |
74 ]; | 74 ]; |
75 print('Running: dart2js ${dart2jsArgs.join(' ')}'); | 75 print('Running: dart2js ${dart2jsArgs.join(' ')}'); |
76 | 76 |
77 await dart2js.internalMain(dart2jsArgs); | 77 await dart2js.internalMain(dart2jsArgs); |
78 | 78 |
79 print('---- run from dill --------------------------------------------'); | 79 print('---- run from dill --------------------------------------------'); |
80 ProcessResult runResult = Process.runSync(d8executable, | 80 ProcessResult runResult = Process.runSync(d8executable, |
81 ['sdk/lib/_internal/js_runtime/lib/preambles/d8.js', output]); | 81 ['sdk/lib/_internal/js_runtime/lib/preambles/d8.js', output]); |
82 String out = '${runResult.stderr}\n${runResult.stdout}'; | 82 String out = '${runResult.stderr}\n${runResult.stdout}'; |
83 print('d8 output:'); | 83 print('d8 output:'); |
84 print(out); | 84 print(out); |
85 Expect.equals(0, runResult.exitCode); | 85 Expect.equals(0, runResult.exitCode); |
86 Expect.equals(OUTPUT, runResult.stdout.replaceAll('\r\n', '\n')); | 86 Expect.equals(OUTPUT, runResult.stdout.replaceAll('\r\n', '\n')); |
87 | 87 |
88 return ResultKind.success; | 88 return ResultKind.success; |
89 } | 89 } |
OLD | NEW |