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

Unified Diff: tests/compiler/dart2js/kernel/run_from_dill_test.dart

Issue 2942863002: Compile and run Hello World! (Closed)
Patch Set: Rebased Created 3 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/compiler/dart2js/kernel/compiler_helper.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..2d28c684c817238fb1d0dc45cdf2c7f86e5f0abc
--- /dev/null
+++ b/tests/compiler/dart2js/kernel/run_from_dill_test.dart
@@ -0,0 +1,74 @@
+// 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.
+
+// Test that we can compile from dill and run the generated code with d8.
+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;
+}
« no previous file with comments | « tests/compiler/dart2js/kernel/compiler_helper.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698