OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 library fletchc.test.feature_test; | 5 library dartino_compiler.test.feature_test; |
6 | 6 |
7 import 'dart:io' hide | 7 import 'dart:io' hide |
8 exitCode, | 8 exitCode, |
9 stderr, | 9 stderr, |
10 stdin, | 10 stdin, |
11 stdout; | 11 stdout; |
12 | 12 |
13 import 'dart:io' as io; | 13 import 'dart:io' as io; |
14 | 14 |
15 import 'dart:async' show | 15 import 'dart:async' show |
16 Completer, | 16 Completer, |
17 Future, | 17 Future, |
18 Stream, | 18 Stream, |
19 StreamController, | 19 StreamController, |
20 StreamIterator; | 20 StreamIterator; |
21 | 21 |
22 import 'dart:convert' show | 22 import 'dart:convert' show |
23 LineSplitter, | 23 LineSplitter, |
24 UTF8, | 24 UTF8, |
25 Utf8Decoder; | 25 Utf8Decoder; |
26 | 26 |
27 import 'package:expect/expect.dart' show | 27 import 'package:expect/expect.dart' show |
28 Expect; | 28 Expect; |
29 | 29 |
30 import 'package:fletchc/incremental/scope_information_visitor.dart' show | 30 import 'package:dartino_compiler/incremental/scope_information_visitor.dart' sho
w |
31 ScopeInformationVisitor; | 31 ScopeInformationVisitor; |
32 | 32 |
33 import 'compiler_test_case.dart' show | 33 import 'compiler_test_case.dart' show |
34 CompilerTestCase; | 34 CompilerTestCase; |
35 | 35 |
36 import 'package:compiler/src/elements/elements.dart' show | 36 import 'package:compiler/src/elements/elements.dart' show |
37 AbstractFieldElement, | 37 AbstractFieldElement, |
38 Element, | 38 Element, |
39 FieldElement, | 39 FieldElement, |
40 FunctionElement, | 40 FunctionElement, |
41 LibraryElement; | 41 LibraryElement; |
42 | 42 |
43 import 'package:compiler/src/compiler.dart' show | 43 import 'package:compiler/src/compiler.dart' show |
44 Compiler; | 44 Compiler; |
45 | 45 |
46 import 'package:compiler/src/source_file_provider.dart' show | 46 import 'package:compiler/src/source_file_provider.dart' show |
47 FormattingDiagnosticHandler, | 47 FormattingDiagnosticHandler, |
48 SourceFileProvider; | 48 SourceFileProvider; |
49 | 49 |
50 import 'package:compiler/src/io/source_file.dart' show | 50 import 'package:compiler/src/io/source_file.dart' show |
51 StringSourceFile; | 51 StringSourceFile; |
52 | 52 |
53 import 'package:fletchc/incremental/fletchc_incremental.dart' show | 53 import 'package:dartino_compiler/incremental/dartino_compiler_incremental.dart'
show |
54 IncrementalCompilationFailed, | 54 IncrementalCompilationFailed, |
55 IncrementalCompiler, | 55 IncrementalCompiler, |
56 IncrementalMode; | 56 IncrementalMode; |
57 | 57 |
58 import 'package:fletchc/vm_commands.dart' show | 58 import 'package:dartino_compiler/vm_commands.dart' show |
59 VmCommand, | 59 VmCommand, |
60 CommitChanges, | 60 CommitChanges, |
61 CommitChangesResult, | 61 CommitChangesResult, |
62 HandShakeResult, | 62 HandShakeResult, |
63 MapId; | 63 MapId; |
64 | 64 |
65 import 'package:fletchc/fletch_compiler.dart' show | 65 import 'package:dartino_compiler/dartino_compiler.dart' show |
66 FletchCompiler; | 66 DartinoCompiler; |
67 | 67 |
68 import 'package:fletchc/src/fletch_compiler_implementation.dart' show | 68 import 'package:dartino_compiler/src/dartino_compiler_implementation.dart' show |
69 OutputProvider; | 69 OutputProvider; |
70 | 70 |
71 import 'package:fletchc/src/guess_configuration.dart' show | 71 import 'package:dartino_compiler/src/guess_configuration.dart' show |
72 fletchVersion, | 72 dartinoVersion, |
73 guessFletchVm; | 73 guessDartinoVm; |
74 | 74 |
75 import 'package:fletchc/fletch_system.dart'; | 75 import 'package:dartino_compiler/dartino_system.dart'; |
76 | 76 |
77 import 'package:fletchc/vm_commands.dart' as commands_lib; | 77 import 'package:dartino_compiler/vm_commands.dart' as commands_lib; |
78 | 78 |
79 import 'package:fletchc/vm_session.dart' show | 79 import 'package:dartino_compiler/vm_session.dart' show |
80 Session; | 80 Session; |
81 | 81 |
82 import 'package:fletchc/src/fletch_backend.dart' show | 82 import 'package:dartino_compiler/src/dartino_backend.dart' show |
83 FletchBackend; | 83 DartinoBackend; |
84 | 84 |
85 import 'package:fletchc/fletch_vm.dart' show | 85 import 'package:dartino_compiler/dartino_vm.dart' show |
86 FletchVm; | 86 DartinoVm; |
87 | 87 |
88 import 'package:fletchc/debug_state.dart' as debug show | 88 import 'package:dartino_compiler/debug_state.dart' as debug show |
89 BackTraceFrame, | 89 BackTraceFrame, |
90 BackTrace; | 90 BackTrace; |
91 | 91 |
92 import 'program_result.dart'; | 92 import 'program_result.dart'; |
93 | 93 |
94 import 'package:fletchc/src/hub/exit_codes.dart' show | 94 import 'package:dartino_compiler/src/hub/exit_codes.dart' show |
95 DART_VM_EXITCODE_COMPILE_TIME_ERROR; | 95 DART_VM_EXITCODE_COMPILE_TIME_ERROR; |
96 | 96 |
97 const String PACKAGE_SCHEME = 'org.dartlang.fletch.packages'; | 97 const String PACKAGE_SCHEME = 'org.dartlang.dartino.packages'; |
98 | 98 |
99 const String CUSTOM_SCHEME = 'org.dartlang.fletch.test-case'; | 99 const String CUSTOM_SCHEME = 'org.dartlang.dartino.test-case'; |
100 | 100 |
101 final Uri customUriBase = new Uri(scheme: CUSTOM_SCHEME, path: '/'); | 101 final Uri customUriBase = new Uri(scheme: CUSTOM_SCHEME, path: '/'); |
102 | 102 |
103 typedef Future NoArgFuture(); | 103 typedef Future NoArgFuture(); |
104 | 104 |
105 compileAndRun( | 105 compileAndRun( |
106 String testName, | 106 String testName, |
107 EncodedResult encodedResult, | 107 EncodedResult encodedResult, |
108 {IncrementalMode incrementalMode}) async { | 108 {IncrementalMode incrementalMode}) async { |
109 print("Test '$testName'"); | 109 print("Test '$testName'"); |
(...skipping 14 matching lines...) Expand all Loading... |
124 if (!program.compileUpdatesShouldThrow) { | 124 if (!program.compileUpdatesShouldThrow) { |
125 // We should only update the status of hasCompileTimeError when we run | 125 // We should only update the status of hasCompileTimeError when we run |
126 // something on the VM. | 126 // something on the VM. |
127 hasCompileTimeError = program.hasCompileTimeError; | 127 hasCompileTimeError = program.hasCompileTimeError; |
128 } | 128 } |
129 | 129 |
130 print("Program version $version #$testName:"); | 130 print("Program version $version #$testName:"); |
131 print(numberedLines(program.code)); | 131 print(numberedLines(program.code)); |
132 | 132 |
133 bool compileUpdatesThrew = true; | 133 bool compileUpdatesThrew = true; |
134 FletchDelta fletchDelta; | 134 DartinoDelta dartinoDelta; |
135 if (isFirstProgram) { | 135 if (isFirstProgram) { |
136 // The first program is compiled "fully". | 136 // The first program is compiled "fully". |
137 fletchDelta = await helper.fullCompile(program); | 137 dartinoDelta = await helper.fullCompile(program); |
138 compileUpdatesThrew = false; | 138 compileUpdatesThrew = false; |
139 } else { | 139 } else { |
140 // An update to the first program, all updates are compiled as | 140 // An update to the first program, all updates are compiled as |
141 // incremental updates to the first program. | 141 // incremental updates to the first program. |
142 try { | 142 try { |
143 fletchDelta = await helper.incrementalCompile(program, version); | 143 dartinoDelta = await helper.incrementalCompile(program, version); |
144 compileUpdatesThrew = false; | 144 compileUpdatesThrew = false; |
145 } on IncrementalCompilationFailed catch (error) { | 145 } on IncrementalCompilationFailed catch (error) { |
146 if (program.compileUpdatesShouldThrow) { | 146 if (program.compileUpdatesShouldThrow) { |
147 print("Expected error in compileUpdates: $error"); | 147 print("Expected error in compileUpdates: $error"); |
148 } else { | 148 } else { |
149 print("Unexpected error in compileUpdates."); | 149 print("Unexpected error in compileUpdates."); |
150 rethrow; | 150 rethrow; |
151 } | 151 } |
152 } | 152 } |
153 } | 153 } |
154 | 154 |
155 FletchBackend backend = helper.compiler.compiler.context.backend; | 155 DartinoBackend backend = helper.compiler.compiler.context.backend; |
156 | 156 |
157 if (program.compileUpdatesShouldThrow) { | 157 if (program.compileUpdatesShouldThrow) { |
158 Expect.isFalse(isFirstProgram); | 158 Expect.isFalse(isFirstProgram); |
159 Expect.isTrue( | 159 Expect.isTrue( |
160 compileUpdatesThrew, | 160 compileUpdatesThrew, |
161 "Expected an exception in compileUpdates"); | 161 "Expected an exception in compileUpdates"); |
162 Expect.isNull(fletchDelta, "Expected update == null"); | 162 Expect.isNull(dartinoDelta, "Expected update == null"); |
163 break; | 163 break; |
164 } | 164 } |
165 | 165 |
166 if (!isFirstProgram || | 166 if (!isFirstProgram || |
167 const bool.fromEnvironment("feature_test.print_initial_commands")) { | 167 const bool.fromEnvironment("feature_test.print_initial_commands")) { |
168 for (VmCommand command in fletchDelta.commands) { | 168 for (VmCommand command in dartinoDelta.commands) { |
169 print(command); | 169 print(command); |
170 } | 170 } |
171 } | 171 } |
172 | 172 |
173 if (isFirstProgram) { | 173 if (isFirstProgram) { |
174 // Perform handshake with VM. | 174 // Perform handshake with VM. |
175 HandShakeResult handShakeResult = | 175 HandShakeResult handShakeResult = |
176 await session.handShake(fletchVersion); | 176 await session.handShake(dartinoVersion); |
177 Expect.isTrue(handShakeResult.success, "Fletch VM version mismatch"); | 177 Expect.isTrue(handShakeResult.success, "Dartino VM version mismatch"); |
178 } | 178 } |
179 | 179 |
180 CommitChangesResult result = await session.applyDelta(fletchDelta); | 180 CommitChangesResult result = await session.applyDelta(dartinoDelta); |
181 | 181 |
182 if (!result.successful) { | 182 if (!result.successful) { |
183 print("The CommitChanges() command was not successful: " | 183 print("The CommitChanges() command was not successful: " |
184 "${result.message}"); | 184 "${result.message}"); |
185 } | 185 } |
186 | 186 |
187 Expect.equals(result.successful, !program.commitChangesShouldFail, | 187 Expect.equals(result.successful, !program.commitChangesShouldFail, |
188 result.message); | 188 result.message); |
189 | 189 |
190 if (isFirstProgram) { | 190 if (isFirstProgram) { |
(...skipping 26 matching lines...) Expand all Loading... |
217 await session.restart(); | 217 await session.restart(); |
218 } | 218 } |
219 if (session.running) { | 219 if (session.running) { |
220 // Step out of main to finish execution of main. | 220 // Step out of main to finish execution of main. |
221 await session.stepOut(); | 221 await session.stepOut(); |
222 } | 222 } |
223 | 223 |
224 // Select the stack frame of callMain. | 224 // Select the stack frame of callMain. |
225 debug.BackTrace trace = await session.backTrace(); | 225 debug.BackTrace trace = await session.backTrace(); |
226 FunctionElement callMainElement = | 226 FunctionElement callMainElement = |
227 backend.fletchSystemLibrary.findLocal("callMain"); | 227 backend.dartinoSystemLibrary.findLocal("callMain"); |
228 FletchFunction callMain = | 228 DartinoFunction callMain = |
229 helper.system.lookupFunctionByElement(callMainElement); | 229 helper.system.lookupFunctionByElement(callMainElement); |
230 debug.BackTraceFrame mainFrame = | 230 debug.BackTraceFrame mainFrame = |
231 trace.frames.firstWhere( | 231 trace.frames.firstWhere( |
232 (debug.BackTraceFrame frame) => frame.function == callMain); | 232 (debug.BackTraceFrame frame) => frame.function == callMain); |
233 int frame = trace.frames.indexOf(mainFrame); | 233 int frame = trace.frames.indexOf(mainFrame); |
234 Expect.notEquals(1, frame); | 234 Expect.notEquals(1, frame); |
235 session.selectFrame(frame); | 235 session.selectFrame(frame); |
236 print(trace.format()); | 236 print(trace.format()); |
237 | 237 |
238 List<String> actualMessages = session.stdoutSink.takeLines(); | 238 List<String> actualMessages = session.stdoutSink.takeLines(); |
239 | 239 |
240 List<String> messages = new List<String>.from(program.messages); | 240 List<String> messages = new List<String>.from(program.messages); |
241 if (program.hasCompileTimeError) { | 241 if (program.hasCompileTimeError) { |
242 print("Compile-time error expected"); | 242 print("Compile-time error expected"); |
243 // TODO(ahe): The compile-time error message shouldn't be printed by | 243 // TODO(ahe): The compile-time error message shouldn't be printed by |
244 // the Fletch VM. | 244 // the Dartino VM. |
245 | 245 |
246 // Find the compile-time error message in the actual output, and | 246 // Find the compile-time error message in the actual output, and |
247 // remove all lines after it. | 247 // remove all lines after it. |
248 int compileTimeErrorIndex = -1; | 248 int compileTimeErrorIndex = -1; |
249 for (int i = 0; i < actualMessages.length; i++) { | 249 for (int i = 0; i < actualMessages.length; i++) { |
250 if (actualMessages[i].startsWith("Compile error:")) { | 250 if (actualMessages[i].startsWith("Compile error:")) { |
251 compileTimeErrorIndex = i; | 251 compileTimeErrorIndex = i; |
252 break; | 252 break; |
253 } | 253 } |
254 } | 254 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 // to propagate the exitCode back to test.dart, so we can have Fail/Crash | 295 // to propagate the exitCode back to test.dart, so we can have Fail/Crash |
296 // outcomes of these tests. | 296 // outcomes of these tests. |
297 await session.waitForCompletion(); | 297 await session.waitForCompletion(); |
298 | 298 |
299 int actualExitCode = await session.exitCode; | 299 int actualExitCode = await session.exitCode; |
300 // TODO(ahe): We should expect exit code 0, and instead be able to detect | 300 // TODO(ahe): We should expect exit code 0, and instead be able to detect |
301 // compile-time errors directly via the session. | 301 // compile-time errors directly via the session. |
302 int expectedExitCode = hasCompileTimeError | 302 int expectedExitCode = hasCompileTimeError |
303 ? DART_VM_EXITCODE_COMPILE_TIME_ERROR : 0; | 303 ? DART_VM_EXITCODE_COMPILE_TIME_ERROR : 0; |
304 Expect.equals( | 304 Expect.equals( |
305 expectedExitCode, actualExitCode, "Unexpected exit code from fletch VM"); | 305 expectedExitCode, actualExitCode, "Unexpected exit code from dartino VM"); |
306 } | 306 } |
307 | 307 |
308 class SerializeScopeTestCase extends CompilerTestCase { | 308 class SerializeScopeTestCase extends CompilerTestCase { |
309 final String source; | 309 final String source; |
310 | 310 |
311 final String scopeInfo; | 311 final String scopeInfo; |
312 | 312 |
313 final Compiler compiler = null; // TODO(ahe): Provide a compiler. | 313 final Compiler compiler = null; // TODO(ahe): Provide a compiler. |
314 | 314 |
315 SerializeScopeTestCase( | 315 SerializeScopeTestCase( |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 this.futures, | 411 this.futures, |
412 this.exitCode) | 412 this.exitCode) |
413 : super(vmSocket, compiler, new BytesSink(), null); | 413 : super(vmSocket, compiler, new BytesSink(), null); |
414 | 414 |
415 // Refines type of [stdoutSink]. | 415 // Refines type of [stdoutSink]. |
416 BytesSink get stdoutSink => super.stdoutSink; | 416 BytesSink get stdoutSink => super.stdoutSink; |
417 | 417 |
418 void writeStdout(String s) { | 418 void writeStdout(String s) { |
419 // Unfortunately, print will always add a newline, and the alternative is | 419 // Unfortunately, print will always add a newline, and the alternative is |
420 // to use stdout.write. However, to make it easier to debug problems in | 420 // to use stdout.write. However, to make it easier to debug problems in |
421 // this and other fletch_tests, everything that is printed to stdout ends | 421 // this and other dartino_tests, everything that is printed to stdout ends |
422 // up on the console of test.dart. This is good enough for testing, but DO | 422 // up on the console of test.dart. This is good enough for testing, but DO |
423 // NOT COPY TO PRODUCTION CODE. | 423 // NOT COPY TO PRODUCTION CODE. |
424 print(s); | 424 print(s); |
425 } | 425 } |
426 | 426 |
427 void writeStdoutLine(String s) { | 427 void writeStdoutLine(String s) { |
428 print(s); | 428 print(s); |
429 } | 429 } |
430 | 430 |
431 /// Add [future] to this session. All futures that can fail after calling | 431 /// Add [future] to this session. All futures that can fail after calling |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 sb.writeln("Problem #${++problemCount}:"); | 463 sb.writeln("Problem #${++problemCount}:"); |
464 sb.writeln(error); | 464 sb.writeln(error); |
465 sb.writeln(""); | 465 sb.writeln(""); |
466 } | 466 } |
467 } | 467 } |
468 await stdoutFuture; | 468 await stdoutFuture; |
469 List<String> stdoutLines = stdoutSink.takeLines(); | 469 List<String> stdoutLines = stdoutSink.takeLines(); |
470 List<String> stderrLines = await stderrFuture; | 470 List<String> stderrLines = await stderrFuture; |
471 if (stdoutLines.isNotEmpty) { | 471 if (stdoutLines.isNotEmpty) { |
472 sb.writeln("Problem #${++problemCount}:"); | 472 sb.writeln("Problem #${++problemCount}:"); |
473 sb.writeln("Unexpected stdout from fletch-vm:"); | 473 sb.writeln("Unexpected stdout from dartino-vm:"); |
474 for (String line in stdoutLines) { | 474 for (String line in stdoutLines) { |
475 sb.writeln(line); | 475 sb.writeln(line); |
476 } | 476 } |
477 sb.writeln(""); | 477 sb.writeln(""); |
478 } | 478 } |
479 if (stderrLines.isNotEmpty) { | 479 if (stderrLines.isNotEmpty) { |
480 sb.writeln("Problem #${++problemCount}:"); | 480 sb.writeln("Problem #${++problemCount}:"); |
481 sb.writeln("Unexpected stderr from fletch-vm:"); | 481 sb.writeln("Unexpected stderr from dartino-vm:"); |
482 for (String line in stderrLines) { | 482 for (String line in stderrLines) { |
483 sb.writeln(line); | 483 sb.writeln(line); |
484 } | 484 } |
485 sb.writeln(""); | 485 sb.writeln(""); |
486 } | 486 } |
487 if (problemCount > 0) { | 487 if (problemCount > 0) { |
488 throw new StateError('Test has $problemCount problem(s). Details:\n$sb'); | 488 throw new StateError('Test has $problemCount problem(s). Details:\n$sb'); |
489 } | 489 } |
490 } | 490 } |
491 | 491 |
492 static Future<String> convertErrorToString(Future future) { | 492 static Future<String> convertErrorToString(Future future) { |
493 return future.then((_) => null).catchError((error, stackTrace) { | 493 return future.then((_) => null).catchError((error, stackTrace) { |
494 return "$error\n$stackTrace"; | 494 return "$error\n$stackTrace"; |
495 }); | 495 }); |
496 } | 496 } |
497 | 497 |
498 static Future<TestSession> spawnVm( | 498 static Future<TestSession> spawnVm( |
499 IncrementalCompiler compiler, | 499 IncrementalCompiler compiler, |
500 {String testName}) async { | 500 {String testName}) async { |
501 String vmPath = guessFletchVm(null).toFilePath(); | 501 String vmPath = guessDartinoVm(null).toFilePath(); |
502 | 502 |
503 List<Future> futures = <Future>[]; | 503 List<Future> futures = <Future>[]; |
504 void recordFuture(String name, Future future) { | 504 void recordFuture(String name, Future future) { |
505 if (future != null) { | 505 if (future != null) { |
506 futures.add(convertErrorToString(future)); | 506 futures.add(convertErrorToString(future)); |
507 } | 507 } |
508 } | 508 } |
509 | 509 |
510 List<String> vmOptions = <String>[ | 510 List<String> vmOptions = <String>[ |
511 '-Xvalidate-heaps', | 511 '-Xvalidate-heaps', |
512 ]; | 512 ]; |
513 | 513 |
514 print("Running '$vmPath ${vmOptions.join(" ")}'"); | 514 print("Running '$vmPath ${vmOptions.join(" ")}'"); |
515 var environment = getProcessEnvironment(testName); | 515 var environment = getProcessEnvironment(testName); |
516 FletchVm fletchVm = await FletchVm.start( | 516 DartinoVm dartinoVm = await DartinoVm.start( |
517 vmPath, arguments: vmOptions, environment: environment); | 517 vmPath, arguments: vmOptions, environment: environment); |
518 | 518 |
519 // Unlike [fletchvm.stdoutLines] and [fletchvm.stderrLines], their | 519 // Unlike [dartinovm.stdoutLines] and [dartinovm.stderrLines], their |
520 // corresponding controller cannot produce an error. | 520 // corresponding controller cannot produce an error. |
521 StreamController<String> stdoutController = new StreamController<String>(); | 521 StreamController<String> stdoutController = new StreamController<String>(); |
522 StreamController<String> stderrController = new StreamController<String>(); | 522 StreamController<String> stderrController = new StreamController<String>(); |
523 recordFuture("stdout", fletchVm.stdoutLines.listen((String line) { | 523 recordFuture("stdout", dartinoVm.stdoutLines.listen((String line) { |
524 print('fletch_vm_stdout: $line'); | 524 print('dartino_vm_stdout: $line'); |
525 stdoutController.add(line); | 525 stdoutController.add(line); |
526 }).asFuture().whenComplete(stdoutController.close)); | 526 }).asFuture().whenComplete(stdoutController.close)); |
527 recordFuture("stderr", fletchVm.stderrLines.listen((String line) { | 527 recordFuture("stderr", dartinoVm.stderrLines.listen((String line) { |
528 print('fletch_vm_stderr: $line'); | 528 print('dartino_vm_stderr: $line'); |
529 stderrController.add(line); | 529 stderrController.add(line); |
530 }).asFuture().whenComplete(stderrController.close)); | 530 }).asFuture().whenComplete(stderrController.close)); |
531 | 531 |
532 Completer<int> exitCodeCompleter = new Completer<int>(); | 532 Completer<int> exitCodeCompleter = new Completer<int>(); |
533 | 533 |
534 // TODO(ahe): If the VM crashes on startup, this will never complete. This | 534 // TODO(ahe): If the VM crashes on startup, this will never complete. This |
535 // makes this program hang forever. But the exitCode completer might | 535 // makes this program hang forever. But the exitCode completer might |
536 // actually be ready to give us a crashed exit code. Exiting early with a | 536 // actually be ready to give us a crashed exit code. Exiting early with a |
537 // failure in case exitCode is ready before server.first or having a | 537 // failure in case exitCode is ready before server.first or having a |
538 // timeout on server.first would be possible solutions. | 538 // timeout on server.first would be possible solutions. |
539 var vmSocket = await fletchVm.connect(); | 539 var vmSocket = await dartinoVm.connect(); |
540 recordFuture("vmSocket", vmSocket.done); | 540 recordFuture("vmSocket", vmSocket.done); |
541 | 541 |
542 TestSession session = new TestSession( | 542 TestSession session = new TestSession( |
543 vmSocket, compiler, fletchVm.process, | 543 vmSocket, compiler, dartinoVm.process, |
544 new StreamIterator(stdoutController.stream), | 544 new StreamIterator(stdoutController.stream), |
545 stderrController.stream, | 545 stderrController.stream, |
546 futures, exitCodeCompleter.future); | 546 futures, exitCodeCompleter.future); |
547 | 547 |
548 recordFuture("exitCode", fletchVm.exitCode.then((int exitCode) { | 548 recordFuture("exitCode", dartinoVm.exitCode.then((int exitCode) { |
549 print("VM exited with exit code: $exitCode."); | 549 print("VM exited with exit code: $exitCode."); |
550 exitCodeCompleter.complete(exitCode); | 550 exitCodeCompleter.complete(exitCode); |
551 })); | 551 })); |
552 | 552 |
553 return session; | 553 return session; |
554 } | 554 } |
555 | 555 |
556 static Map<String, String> getProcessEnvironment(String testName) { | 556 static Map<String, String> getProcessEnvironment(String testName) { |
557 if (testName == null) return null; | 557 if (testName == null) return null; |
558 | 558 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
595 } | 595 } |
596 } | 596 } |
597 | 597 |
598 class IncrementalTestHelper { | 598 class IncrementalTestHelper { |
599 final Uri packageConfig; | 599 final Uri packageConfig; |
600 | 600 |
601 final IoInputProvider inputProvider; | 601 final IoInputProvider inputProvider; |
602 | 602 |
603 final IncrementalCompiler compiler; | 603 final IncrementalCompiler compiler; |
604 | 604 |
605 FletchSystem system; | 605 DartinoSystem system; |
606 | 606 |
607 IncrementalTestHelper.internal( | 607 IncrementalTestHelper.internal( |
608 this.packageConfig, | 608 this.packageConfig, |
609 this.inputProvider, | 609 this.inputProvider, |
610 this.compiler); | 610 this.compiler); |
611 | 611 |
612 factory IncrementalTestHelper(IncrementalMode incrementalMode) { | 612 factory IncrementalTestHelper(IncrementalMode incrementalMode) { |
613 Uri packageConfig = Uri.base.resolve('.packages'); | 613 Uri packageConfig = Uri.base.resolve('.packages'); |
614 IoInputProvider inputProvider = new IoInputProvider(packageConfig); | 614 IoInputProvider inputProvider = new IoInputProvider(packageConfig); |
615 FormattingDiagnosticHandler diagnosticHandler = | 615 FormattingDiagnosticHandler diagnosticHandler = |
616 new FormattingDiagnosticHandler(inputProvider); | 616 new FormattingDiagnosticHandler(inputProvider); |
617 IncrementalCompiler compiler = new IncrementalCompiler( | 617 IncrementalCompiler compiler = new IncrementalCompiler( |
618 packageConfig: packageConfig, | 618 packageConfig: packageConfig, |
619 inputProvider: inputProvider, | 619 inputProvider: inputProvider, |
620 diagnosticHandler: diagnosticHandler, | 620 diagnosticHandler: diagnosticHandler, |
621 outputProvider: new OutputProvider(), | 621 outputProvider: new OutputProvider(), |
622 support: incrementalMode, | 622 support: incrementalMode, |
623 platform: "fletch_mobile.platform"); | 623 platform: "dartino_mobile.platform"); |
624 return new IncrementalTestHelper.internal( | 624 return new IncrementalTestHelper.internal( |
625 packageConfig, | 625 packageConfig, |
626 inputProvider, | 626 inputProvider, |
627 compiler); | 627 compiler); |
628 } | 628 } |
629 | 629 |
630 Future<FletchDelta> fullCompile(ProgramResult program) async { | 630 Future<DartinoDelta> fullCompile(ProgramResult program) async { |
631 Map<String, String> code = computeCode(program); | 631 Map<String, String> code = computeCode(program); |
632 inputProvider.sources.clear(); | 632 inputProvider.sources.clear(); |
633 code.forEach((String name, String code) { | 633 code.forEach((String name, String code) { |
634 inputProvider.sources[customUriBase.resolve(name)] = code; | 634 inputProvider.sources[customUriBase.resolve(name)] = code; |
635 }); | 635 }); |
636 | 636 |
637 await compiler.compile(customUriBase.resolve('main.dart'), customUriBase); | 637 await compiler.compile(customUriBase.resolve('main.dart'), customUriBase); |
638 FletchDelta delta = compiler.compiler.context.backend.computeDelta(); | 638 DartinoDelta delta = compiler.compiler.context.backend.computeDelta(); |
639 system = delta.system; | 639 system = delta.system; |
640 return delta; | 640 return delta; |
641 } | 641 } |
642 | 642 |
643 Future<FletchDelta> incrementalCompile( | 643 Future<DartinoDelta> incrementalCompile( |
644 ProgramResult program, | 644 ProgramResult program, |
645 int version) async { | 645 int version) async { |
646 Map<String, String> code = computeCode(program); | 646 Map<String, String> code = computeCode(program); |
647 Map<Uri, Uri> uriMap = <Uri, Uri>{}; | 647 Map<Uri, Uri> uriMap = <Uri, Uri>{}; |
648 for (String name in code.keys) { | 648 for (String name in code.keys) { |
649 Uri uri = customUriBase.resolve('$name?v$version'); | 649 Uri uri = customUriBase.resolve('$name?v$version'); |
650 inputProvider.cachedSources[uri] = new Future.value(code[name]); | 650 inputProvider.cachedSources[uri] = new Future.value(code[name]); |
651 uriMap[customUriBase.resolve(name)] = uri; | 651 uriMap[customUriBase.resolve(name)] = uri; |
652 } | 652 } |
653 FletchDelta delta = await compiler.compileUpdates( | 653 DartinoDelta delta = await compiler.compileUpdates( |
654 system, uriMap, logVerbose: logger, logTime: logger); | 654 system, uriMap, logVerbose: logger, logTime: logger); |
655 system = delta.system; | 655 system = delta.system; |
656 return delta; | 656 return delta; |
657 } | 657 } |
658 | 658 |
659 Map<String, String> computeCode(ProgramResult program) { | 659 Map<String, String> computeCode(ProgramResult program) { |
660 return program.code is String | 660 return program.code is String |
661 ? <String,String>{ 'main.dart': program.code } | 661 ? <String,String>{ 'main.dart': program.code } |
662 : program.code; | 662 : program.code; |
663 } | 663 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
704 | 704 |
705 Future<List<int>> readUtf8BytesFromUri(Uri uri) { | 705 Future<List<int>> readUtf8BytesFromUri(Uri uri) { |
706 throw "not supported"; | 706 throw "not supported"; |
707 } | 707 } |
708 | 708 |
709 static String readCachedFile(Uri uri) { | 709 static String readCachedFile(Uri uri) { |
710 return cachedFiles.putIfAbsent( | 710 return cachedFiles.putIfAbsent( |
711 uri, () => new File.fromUri(uri).readAsStringSync()); | 711 uri, () => new File.fromUri(uri).readAsStringSync()); |
712 } | 712 } |
713 } | 713 } |
OLD | NEW |