OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2016, 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 library dart2js.serialization_compilation_test; |
| 6 |
| 7 import 'dart:async'; |
| 8 import 'package:async_helper/async_helper.dart'; |
| 9 import 'package:expect/expect.dart'; |
| 10 import 'package:compiler/src/commandline_options.dart'; |
| 11 import 'package:compiler/src/common/backend_api.dart'; |
| 12 import 'package:compiler/src/common/names.dart'; |
| 13 import 'package:compiler/src/compiler.dart'; |
| 14 import 'package:compiler/src/filenames.dart'; |
| 15 import 'memory_compiler.dart'; |
| 16 import 'serialization_helper.dart'; |
| 17 import 'serialization_test_data.dart'; |
| 18 import 'output_collector.dart'; |
| 19 |
| 20 main(List<String> args) { |
| 21 asyncTest(() async { |
| 22 Arguments arguments = new Arguments.from(args); |
| 23 String serializedData = await serializeDartCore( |
| 24 arguments: arguments, |
| 25 serializeResolvedAst: true); |
| 26 if (arguments.filename != null) { |
| 27 Uri entryPoint = Uri.base.resolve(nativeToUriPath(arguments.filename)); |
| 28 await compile(serializedData, entryPoint, null); |
| 29 } else { |
| 30 Uri entryPoint = Uri.parse('memory:main.dart'); |
| 31 // TODO(johnniwinther): Handle the remaining tests. |
| 32 for (Test test in TESTS.sublist(0, 1)) { |
| 33 await compile(serializedData, entryPoint, test, |
| 34 verbose: arguments.verbose); |
| 35 } |
| 36 } |
| 37 }); |
| 38 } |
| 39 |
| 40 Future compile(String serializedData, Uri entryPoint, Test test, |
| 41 {bool verbose: false}) async { |
| 42 String testDescription = |
| 43 test != null ? test.sourceFiles[entryPoint.path] : '${entryPoint}'; |
| 44 print('------------------------------------------------------------------'); |
| 45 print('compile ${testDescription}'); |
| 46 print('------------------------------------------------------------------'); |
| 47 OutputCollector outputCollector = new OutputCollector(); |
| 48 await runCompiler( |
| 49 entryPoint: entryPoint, |
| 50 memorySourceFiles: test != null ? test.sourceFiles : const {}, |
| 51 options: [Flags.disableTypeInference, |
| 52 Flags.disableInlining, |
| 53 Flags.noSourceMaps], |
| 54 outputProvider: outputCollector, |
| 55 beforeRun: (Compiler compiler) { |
| 56 deserialize(compiler, serializedData, deserializeResolvedAst: true); |
| 57 }); |
| 58 if (verbose) { |
| 59 print(outputCollector.getOutput('', 'js')); |
| 60 } |
| 61 } |
| 62 |
OLD | NEW |