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

Side by Side Diff: tests/dartino_compiler/run.dart

Issue 1659163007: Rename fletch -> dartino (Closed) Base URL: https://github.com/dartino/sdk.git@master
Patch Set: address comments Created 4 years, 10 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
1 // Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dartino 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.md file. 3 // BSD-style license that can be found in the LICENSE.md file.
4 4
5 library fletchc.test.run; 5 library dartino_compiler.test.run;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'dart:io'; 9 import 'dart:io';
10 10
11 import 'dart:io' as io; 11 import 'dart:io' as io;
12 12
13 import 'package:fletchc/src/hub/session_manager.dart'; 13 import 'package:dartino_compiler/src/hub/session_manager.dart';
14 14
15 import 'package:fletchc/src/worker/developer.dart'; 15 import 'package:dartino_compiler/src/worker/developer.dart';
16 16
17 import 'package:fletchc/src/worker/developer.dart' as developer; 17 import 'package:dartino_compiler/src/worker/developer.dart' as developer;
18 18
19 import 'package:fletchc/src/verbs/infrastructure.dart' show fileUri; 19 import 'package:dartino_compiler/src/verbs/infrastructure.dart' show fileUri;
20 20
21 import 'package:fletchc/src/device_type.dart' show 21 import 'package:dartino_compiler/src/device_type.dart' show
22 DeviceType, 22 DeviceType,
23 parseDeviceType; 23 parseDeviceType;
24 24
25 const String userVmAddress = const String.fromEnvironment("attachToVm"); 25 const String userVmAddress = const String.fromEnvironment("attachToVm");
26 26
27 const String exportTo = const String.fromEnvironment("snapshot"); 27 const String exportTo = const String.fromEnvironment("snapshot");
28 28
29 const String userPackages = const String.fromEnvironment("packages"); 29 const String userPackages = const String.fromEnvironment("packages");
30 30
31 const String userAgentAddress = const String.fromEnvironment("agent"); 31 const String userAgentAddress = const String.fromEnvironment("agent");
32 32
33 const String fletchSettingsFile = 33 const String dartinoSettingsFile =
34 const String.fromEnvironment("test.fletch_settings_file_name"); 34 const String.fromEnvironment("test.dartino_settings_file_name");
35 35
36 /// Enables printing of Compiler/VM protocol commands after each compilation. 36 /// Enables printing of Compiler/VM protocol commands after each compilation.
37 const bool printCommands = const bool.fromEnvironment("printCommands"); 37 const bool printCommands = const bool.fromEnvironment("printCommands");
38 38
39 /// Enables pretty printing the Fletch system (the compilation result) after 39 /// Enables pretty printing the Dartino system (the compilation result) after
40 /// each compilation. 40 /// each compilation.
41 const bool printSystem = const bool.fromEnvironment("printSystem"); 41 const bool printSystem = const bool.fromEnvironment("printSystem");
42 42
43 class FletchRunner { 43 class DartinoRunner {
44 Future<Null> attach(SessionState state) async { 44 Future<Null> attach(SessionState state) async {
45 if (userVmAddress == null) { 45 if (userVmAddress == null) {
46 await startAndAttachDirectly(state, Uri.base); 46 await startAndAttachDirectly(state, Uri.base);
47 } else { 47 } else {
48 Address address = parseAddress(userVmAddress); 48 Address address = parseAddress(userVmAddress);
49 await attachToVm(address.host, address.port, state); 49 await attachToVm(address.host, address.port, state);
50 } 50 }
51 } 51 }
52 52
53 Future<Settings> computeSettings() async { 53 Future<Settings> computeSettings() async {
54 if (fletchSettingsFile != null) { 54 if (dartinoSettingsFile != null) {
55 return await readSettings(fileUri(fletchSettingsFile, Uri.base)); 55 return await readSettings(fileUri(dartinoSettingsFile, Uri.base));
56 } 56 }
57 Address agentAddress = 57 Address agentAddress =
58 userAgentAddress == null ? null : parseAddress(userAgentAddress); 58 userAgentAddress == null ? null : parseAddress(userAgentAddress);
59 return new Settings( 59 return new Settings(
60 fileUri(userPackages == null ? ".packages" : userPackages, Uri.base), 60 fileUri(userPackages == null ? ".packages" : userPackages, Uri.base),
61 ["--verbose"], 61 ["--verbose"],
62 <String, String>{ 62 <String, String>{
63 "foo": "1", 63 "foo": "1",
64 "bar": "baz", 64 "bar": "baz",
65 }, 65 },
(...skipping 28 matching lines...) Expand all
94 } 94 }
95 await attach(state); 95 await attach(state);
96 state.stdoutSink.attachCommandSender(stdout.add); 96 state.stdoutSink.attachCommandSender(stdout.add);
97 state.stderrSink.attachCommandSender(stderr.add); 97 state.stderrSink.attachCommandSender(stderr.add);
98 98
99 if (exportTo != null) { 99 if (exportTo != null) {
100 await developer.export(state, fileUri(exportTo, Uri.base)); 100 await developer.export(state, fileUri(exportTo, Uri.base));
101 } else { 101 } else {
102 await developer.run(state); 102 await developer.run(state);
103 } 103 }
104 if (state.fletchVm != null) { 104 if (state.dartinoVm != null) {
105 int exitCode = await state.fletchVm.exitCode; 105 int exitCode = await state.dartinoVm.exitCode;
106 print("$script: Fletch VM exit code: $exitCode"); 106 print("$script: Dartino VM exit code: $exitCode");
107 if (exitCode != expectedExitCode) { 107 if (exitCode != expectedExitCode) {
108 return exitCode; 108 return exitCode;
109 } 109 }
110 } 110 }
111 } 111 }
112 print(state.getLog()); 112 print(state.getLog());
113 return 0; 113 return 0;
114 } 114 }
115 } 115 }
116 116
117 main(List<String> arguments) async { 117 main(List<String> arguments) async {
118 io.exitCode = await new FletchRunner().run(arguments); 118 io.exitCode = await new DartinoRunner().run(arguments);
119 } 119 }
120 120
121 void checkExitCode(int expected, int actual) { 121 void checkExitCode(int expected, int actual) {
122 if (expected != actual) { 122 if (expected != actual) {
123 throw "Unexpected exit code: $expected != $actual"; 123 throw "Unexpected exit code: $expected != $actual";
124 } 124 }
125 } 125 }
126 126
127 Future<Null> test() async { 127 Future<Null> test() async {
128 checkExitCode( 128 checkExitCode(
129 0, await new FletchRunner().run( 129 0, await new DartinoRunner().run(
130 <String>['tests/language/application_test.dart'])); 130 <String>['tests/language/application_test.dart']));
131 } 131 }
132 132
133 Future<Null> testIncrementalDebugInfo() async { 133 Future<Null> testIncrementalDebugInfo() async {
134 checkExitCode( 134 checkExitCode(
135 0, await new FletchRunner().run( 135 0, await new DartinoRunner().run(
136 <String>['tests/fletchc/test_incremental_debug_info.dart', 136 <String>['tests/dartino_compiler/test_incremental_debug_info.dart',
137 'tests/fletchc/test_incremental_debug_info.dart'], 137 'tests/dartino_compiler/test_incremental_debug_info.dart'],
138 expectedExitCode: 255)); 138 expectedExitCode: 255));
139 } 139 }
140 140
141 // TODO(ahe): Move this method into FletchRunner and use computeSettings. 141 // TODO(ahe): Move this method into DartinoRunner and use computeSettings.
142 Future<Null> export( 142 Future<Null> export(
143 String script, String snapshot, {bool binaryProgramInfo: false, 143 String script, String snapshot, {bool binaryProgramInfo: false,
144 Map<String, String> constants: const <String, String> {}}) async { 144 Map<String, String> constants: const <String, String> {}}) async {
145 Settings settings; 145 Settings settings;
146 if (fletchSettingsFile == null) { 146 if (dartinoSettingsFile == null) {
147 settings = new Settings( 147 settings = new Settings(
148 fileUri(".packages", Uri.base), 148 fileUri(".packages", Uri.base),
149 <String>[], 149 <String>[],
150 constants, 150 constants,
151 null, 151 null,
152 null, 152 null,
153 IncrementalMode.none); 153 IncrementalMode.none);
154 } else { 154 } else {
155 settings = await readSettings(fileUri(fletchSettingsFile, Uri.base)); 155 settings = await readSettings(fileUri(dartinoSettingsFile, Uri.base));
156 } 156 }
157 SessionState state = createSessionState("test", settings); 157 SessionState state = createSessionState("test", settings);
158 await compile(fileUri(script, Uri.base), state, Uri.base); 158 await compile(fileUri(script, Uri.base), state, Uri.base);
159 await startAndAttachDirectly(state, Uri.base); 159 await startAndAttachDirectly(state, Uri.base);
160 state.stdoutSink.attachCommandSender(stdout.add); 160 state.stdoutSink.attachCommandSender(stdout.add);
161 state.stderrSink.attachCommandSender(stderr.add); 161 state.stderrSink.attachCommandSender(stderr.add);
162 await developer.export( 162 await developer.export(
163 state, fileUri(snapshot, Uri.base), binaryProgramInfo: binaryProgramInfo); 163 state, fileUri(snapshot, Uri.base), binaryProgramInfo: binaryProgramInfo);
164 } 164 }
OLDNEW
« no previous file with comments | « tests/dartino_compiler/incremental/tests_with_expectations.dart ('k') | tests/dartino_compiler/serialize_settings_tests.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698