Chromium Code Reviews| Index: tests/compiler/dart2js/kernel/run_from_dill_test.dart |
| diff --git a/tests/compiler/dart2js/kernel/run_from_dill_test.dart b/tests/compiler/dart2js/kernel/run_from_dill_test.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..37492261c317f99832c8e5df7bdcb020bda02c5d |
| --- /dev/null |
| +++ b/tests/compiler/dart2js/kernel/run_from_dill_test.dart |
| @@ -0,0 +1,75 @@ |
| +// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file |
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| + |
| +// Partial test that the closed world computed from [WorldImpact]s derived from |
|
Siggi Cherem (dart-lang)
2017/06/15 18:28:55
fix doc
Johnni Winther
2017/06/16 09:25:31
Done.
|
| +// kernel is equivalent to the original computed from resolution. |
| +library dart2js.kernel.run_from_dill_test; |
| + |
| +import 'dart:async'; |
| +import 'dart:io'; |
| + |
| +import 'package:async_helper/async_helper.dart'; |
| +import 'package:expect/expect.dart'; |
| +import 'package:compiler/src/commandline_options.dart'; |
| +import 'package:compiler/src/dart2js.dart' as dart2js; |
| +import 'package:compiler/src/filenames.dart'; |
| + |
| +import 'compiler_helper.dart'; |
| +import '../sourcemaps/stacktrace_test.dart'; |
| +import '../serialization/helper.dart'; |
| + |
| +const SOURCE = const { |
| + 'main.dart': ''' |
| +main() { |
| + print('Hello World!'); |
| +} |
| +''' |
| +}; |
| + |
| +main(List<String> args) { |
| + asyncTest(() async { |
| + await mainInternal(args); |
| + }); |
| +} |
| + |
| +enum ResultKind { crashes, errors, warnings, success, failure } |
| + |
| +Future<ResultKind> mainInternal(List<String> args, |
| + {bool skipWarnings: false, bool skipErrors: false}) async { |
| + Arguments arguments = new Arguments.from(args); |
| + Uri entryPoint; |
| + Map<String, String> memorySourceFiles; |
| + if (arguments.uri != null) { |
| + entryPoint = arguments.uri; |
| + memorySourceFiles = const <String, String>{}; |
| + } else { |
| + entryPoint = Uri.parse('memory:main.dart'); |
| + memorySourceFiles = SOURCE; |
| + } |
| + |
| + Uri dillFile = |
| + await createTemp(entryPoint, memorySourceFiles, printSteps: true); |
| + String output = uriPathToNative(dillFile.resolve('out.js').path); |
| + List<String> dart2jsArgs = [ |
| + dillFile.toString(), |
| + '-o$output', |
| + Flags.loadFromDill, |
| + Flags.disableTypeInference, |
| + Flags.disableInlining, |
| + Flags.enableAssertMessage |
| + ]; |
| + print('Running: dart2js ${dart2jsArgs.join(' ')}'); |
| + |
| + await dart2js.internalMain(dart2jsArgs); |
| + |
| + print('---- run from dill --------------------------------------------'); |
| + ProcessResult runResult = Process.runSync(d8executable, |
| + ['sdk/lib/_internal/js_runtime/lib/preambles/d8.js', output]); |
| + String out = '${runResult.stderr}\n${runResult.stdout}'; |
| + print('d8 output:'); |
| + print(out); |
| + Expect.equals(0, runResult.exitCode); |
| + |
| + return ResultKind.success; |
| +} |