| Index: tools/testing/dart/dartino_session_command.dart
|
| diff --git a/tools/testing/dart/fletch_session_command.dart b/tools/testing/dart/dartino_session_command.dart
|
| similarity index 79%
|
| rename from tools/testing/dart/fletch_session_command.dart
|
| rename to tools/testing/dart/dartino_session_command.dart
|
| index f385006fe2b180abcf75760518b3c82cf9faf60d..893d6c4222a2ca4fe96ee32b224d5f614f3a149b 100644
|
| --- a/tools/testing/dart/fletch_session_command.dart
|
| +++ b/tools/testing/dart/dartino_session_command.dart
|
| @@ -2,11 +2,11 @@
|
| // for details. All rights reserved. Use of this source code is governed by a
|
| // BSD-style license that can be found in the LICENSE.md file.
|
|
|
| -/// Provides a [Command] interface for interacting with a Fletch driver session.
|
| +/// Provides a [Command] interface for interacting with a Dartino driver session.
|
| ///
|
| /// Normally, this is used by test.dart, but is also has a [main] method that
|
| /// makes it possible to run a test outside test.dart.
|
| -library test.fletch_session_command;
|
| +library test.dartino_session_command;
|
|
|
| import 'dart:async' show
|
| Completer,
|
| @@ -37,16 +37,16 @@ import 'test_runner.dart' show
|
| import 'decode_exit_code.dart' show
|
| DecodeExitCode;
|
|
|
| -import '../../../pkg/fletchc/lib/src/hub/exit_codes.dart' show
|
| +import '../../../pkg/dartino_compiler/lib/src/hub/exit_codes.dart' show
|
| COMPILER_EXITCODE_CONNECTION_ERROR,
|
| COMPILER_EXITCODE_CRASH,
|
| DART_VM_EXITCODE_COMPILE_TIME_ERROR,
|
| DART_VM_EXITCODE_UNCAUGHT_EXCEPTION;
|
|
|
| -import '../../../pkg/fletchc/lib/fletch_vm.dart' show
|
| - FletchVm;
|
| +import '../../../pkg/dartino_compiler/lib/dartino_vm.dart' show
|
| + DartinoVm;
|
|
|
| -const String settingsFileNameFlag = "test.fletch_settings_file_name";
|
| +const String settingsFileNameFlag = "test.dartino_settings_file_name";
|
| const String settingsFileName =
|
| const String.fromEnvironment(settingsFileNameFlag);
|
|
|
| @@ -55,20 +55,20 @@ const String settingsFileName =
|
| // TODO(ahe): Lower this to 5 seconds.
|
| const int defaultTimeout = 20;
|
|
|
| -final Queue<FletchSessionMirror> sessions = new Queue<FletchSessionMirror>();
|
| +final Queue<DartinoSessionMirror> sessions = new Queue<DartinoSessionMirror>();
|
|
|
| int sessionCount = 0;
|
|
|
| -/// Return an available [FletchSessionMirror] or construct a new.
|
| -FletchSessionMirror getAvailableSession() {
|
| +/// Return an available [DartinoSessionMirror] or construct a new.
|
| +DartinoSessionMirror getAvailableSession() {
|
| if (sessions.isEmpty) {
|
| - return new FletchSessionMirror(sessionCount++);
|
| + return new DartinoSessionMirror(sessionCount++);
|
| } else {
|
| return sessions.removeFirst();
|
| }
|
| }
|
|
|
| -void returnSession(FletchSessionMirror session) {
|
| +void returnSession(DartinoSessionMirror session) {
|
| sessions.addLast(session);
|
| }
|
|
|
| @@ -112,7 +112,7 @@ String explainExitCode(int code) {
|
| return exit_message;
|
| }
|
|
|
| -class FletchSessionCommand implements Command {
|
| +class DartinoSessionCommand implements Command {
|
| final String executable;
|
| final String script;
|
| final List<String> arguments;
|
| @@ -120,22 +120,22 @@ class FletchSessionCommand implements Command {
|
| final String snapshotFileName;
|
| final String settingsFileName;
|
|
|
| - FletchSessionCommand(
|
| + DartinoSessionCommand(
|
| this.executable,
|
| this.script,
|
| this.arguments,
|
| this.environmentOverrides,
|
| {this.snapshotFileName,
|
| - this.settingsFileName: ".fletch-settings"});
|
| + this.settingsFileName: ".dartino-settings"});
|
|
|
| - String get displayName => "fletch_session";
|
| + String get displayName => "dartino_session";
|
|
|
| int get maxNumRetries => 0;
|
|
|
| String get reproductionCommand {
|
| var dartVm = Uri.parse(executable).resolve('dart');
|
| - String fletchPath = Uri.parse(executable).resolve('fletch-vm').toString();
|
| - String versionFlag = '-Dfletch.version=`$fletchPath --version`';
|
| + String dartinoPath = Uri.parse(executable).resolve('dartino-vm').toString();
|
| + String versionFlag = '-Ddartino.version=`$dartinoPath --version`';
|
| String settingsFileFlag = "-D$settingsFileNameFlag=$settingsFileName";
|
|
|
| return """
|
| @@ -149,20 +149,20 @@ There are three ways to reproduce this error:
|
|
|
| ${Platform.executable} -c $settingsFileFlag \\
|
| $versionFlag \\
|
| - tools/testing/dart/fletch_session_command.dart $executable \\
|
| + tools/testing/dart/dartino_session_command.dart $executable \\
|
| ${arguments.join(' ')}
|
|
|
|
|
| - 2. Run the helper program `tests/fletchc/run.dart` under `gdb` using
|
| + 2. Run the helper program `tests/dartino_compiler/run.dart` under `gdb` using
|
| `set follow-fork-mode child`. This can be confusing, but makes it
|
| easy to run a reproduction command in a loop:
|
|
|
| gdb -ex 'set follow-fork-mode child' -ex run --args \\
|
| $dartVm $settingsFileFlag \\
|
| $versionFlag \\
|
| - -c tests/fletchc/run.dart $script
|
| + -c tests/dartino_compiler/run.dart $script
|
|
|
| - 3. Run the `fletch-vm` in gdb and attach to it via the helper program. This
|
| + 3. Run the `dartino-vm` in gdb and attach to it via the helper program. This
|
| is the easiest way to debug using both gdb and lldb. You need to start two
|
| processes, each in their own terminal window:
|
|
|
| @@ -170,13 +170,13 @@ There are three ways to reproduce this error:
|
|
|
| $dartVm $settingsFileFlag \\
|
| $versionFlag \\
|
| - -c -DattachToVm=54321 tests/fletchc/run.dart $script
|
| + -c -DattachToVm=54321 tests/dartino_compiler/run.dart $script
|
|
|
|
|
| """;
|
| }
|
|
|
| - Future<FletchTestCommandOutput> run(
|
| + Future<DartinoTestCommandOutput> run(
|
| int timeout,
|
| bool verbose,
|
| {bool superVerbose: false}) async {
|
| @@ -191,12 +191,12 @@ There are three ways to reproduce this error:
|
| return compilerFail("Compiler options not implemented: $options");
|
| }
|
|
|
| - FletchSessionHelper fletch =
|
| - new FletchSessionHelper(
|
| + DartinoSessionHelper dartino =
|
| + new DartinoSessionHelper(
|
| getAvailableSession(), executable, environmentOverrides,
|
| verbose, superVerbose);
|
|
|
| - fletch.sessionMirror.printLoggedCommands(fletch.stdout, executable);
|
| + dartino.sessionMirror.printLoggedCommands(dartino.stdout, executable);
|
|
|
| Stopwatch sw = new Stopwatch()..start();
|
| int exitCode;
|
| @@ -204,26 +204,26 @@ There are three ways to reproduce this error:
|
| try {
|
| Future vmTerminationFuture;
|
| try {
|
| - await fletch.createSession(settingsFileName);
|
| + await dartino.createSession(settingsFileName);
|
|
|
| - // Now that the session is created, start a Fletch VM.
|
| - String vmSocketAddress = await fletch.spawnVm();
|
| - // Timeout of the VM is implemented by shutting down the Fletch VM
|
| + // Now that the session is created, start a Dartino VM.
|
| + String vmSocketAddress = await dartino.spawnVm();
|
| + // Timeout of the VM is implemented by shutting down the Dartino VM
|
| // after [timeout] seconds. This ensures that compilation+runtime never
|
| // exceed [timeout] seconds (plus whatever time is spent in setting up
|
| // the session above).
|
| - vmTerminationFuture = fletch.shutdownVm(timeout);
|
| - await fletch.runInSession(["attach", "tcp_socket", vmSocketAddress]);
|
| + vmTerminationFuture = dartino.shutdownVm(timeout);
|
| + await dartino.runInSession(["attach", "tcp_socket", vmSocketAddress]);
|
| if (snapshotFileName != null) {
|
| - exitCode = await fletch.runInSession(
|
| + exitCode = await dartino.runInSession(
|
| ["export", script, 'to', 'file', snapshotFileName],
|
| checkExitCode: false, timeout: timeout);
|
| } else {
|
| - exitCode = await fletch.runInSession(["compile", script],
|
| + exitCode = await dartino.runInSession(["compile", script],
|
| checkExitCode: false, timeout: timeout);
|
| - fletch.stderr.writeln("Compilation took: ${sw.elapsed}");
|
| + dartino.stderr.writeln("Compilation took: ${sw.elapsed}");
|
| if (exitCode == 0) {
|
| - exitCode = await fletch.runInSession(
|
| + exitCode = await dartino.runInSession(
|
| ["run", "--terminate-debugger"],
|
| checkExitCode: false, timeout: timeout);
|
| }
|
| @@ -231,36 +231,36 @@ There are three ways to reproduce this error:
|
| } finally {
|
| if (exitCode == COMPILER_EXITCODE_CRASH) {
|
| // If the compiler crashes, chances are that it didn't close the
|
| - // connection to the Fletch VM. So we kill it.
|
| - fletch.killVmProcess(ProcessSignal.SIGTERM);
|
| + // connection to the Dartino VM. So we kill it.
|
| + dartino.killVmProcess(ProcessSignal.SIGTERM);
|
| }
|
| int vmExitCode = await vmTerminationFuture;
|
| - fletch.stdout.writeln("Fletch VM exitcode is $vmExitCode "
|
| + dartino.stdout.writeln("Dartino VM exitcode is $vmExitCode "
|
| "${explainExitCode(vmExitCode)}\n"
|
| - "Exit code reported by ${fletch.executable} is $exitCode "
|
| + "Exit code reported by ${dartino.executable} is $exitCode "
|
| "${explainExitCode(exitCode)}\n");
|
| if (exitCode == COMPILER_EXITCODE_CONNECTION_ERROR) {
|
| - fletch.stderr.writeln("Connection error from compiler");
|
| + dartino.stderr.writeln("Connection error from compiler");
|
| exitCode = vmExitCode;
|
| } else if (exitCode != vmExitCode) {
|
| - if (!fletch.killedVmProcess || vmExitCode == null ||
|
| + if (!dartino.killedVmProcess || vmExitCode == null ||
|
| vmExitCode >= 0) {
|
| throw new UnexpectedExitCode(
|
| - vmExitCode, "${fletch.executable}-vm", <String>[]);
|
| + vmExitCode, "${dartino.executable}-vm", <String>[]);
|
| }
|
| }
|
| }
|
| } on UnexpectedExitCode catch (error) {
|
| - fletch.stderr.writeln("$error");
|
| + dartino.stderr.writeln("$error");
|
| exitCode = combineExitCodes(exitCode, error.exitCode);
|
| try {
|
| if (!endedSession) {
|
| // TODO(ahe): Only end if there's a crash.
|
| endedSession = true;
|
| - await fletch.run(["x-end", "session", fletch.sessionName]);
|
| + await dartino.run(["x-end", "session", dartino.sessionName]);
|
| }
|
| } on UnexpectedExitCode catch (error) {
|
| - fletch.stderr.writeln("$error");
|
| + dartino.stderr.writeln("$error");
|
| // TODO(ahe): Error ignored, long term we should be able to guarantee
|
| // that shutting down a session never leads to an error.
|
| }
|
| @@ -268,23 +268,23 @@ There are three ways to reproduce this error:
|
|
|
| if (exitCode == null) {
|
| exitCode = COMPILER_EXITCODE_CRASH;
|
| - fletch.stdout.writeln(
|
| + dartino.stdout.writeln(
|
| '**test.py** could not determine a good exitcode, using $exitCode.');
|
| }
|
|
|
| if (endedSession) {
|
| - returnSession(new FletchSessionMirror(fletch.sessionMirror.id));
|
| + returnSession(new DartinoSessionMirror(dartino.sessionMirror.id));
|
| } else {
|
| - returnSession(fletch.sessionMirror);
|
| + returnSession(dartino.sessionMirror);
|
| }
|
|
|
| - return new FletchTestCommandOutput(
|
| - this, exitCode, fletch.hasTimedOut,
|
| - fletch.combinedStdout, fletch.combinedStderr, sw.elapsed, -1);
|
| + return new DartinoTestCommandOutput(
|
| + this, exitCode, dartino.hasTimedOut,
|
| + dartino.combinedStdout, dartino.combinedStderr, sw.elapsed, -1);
|
| }
|
|
|
| - FletchTestCommandOutput compilerFail(String message) {
|
| - return new FletchTestCommandOutput(
|
| + DartinoTestCommandOutput compilerFail(String message) {
|
| + return new DartinoTestCommandOutput(
|
| this, DART_VM_EXITCODE_COMPILE_TIME_ERROR, false, <int>[],
|
| UTF8.encode(message), const Duration(seconds: 0), -1);
|
| }
|
| @@ -299,11 +299,11 @@ There are three ways to reproduce this error:
|
| get outputIsUpToDate => throw "not supported";
|
| }
|
|
|
| -/// [compiler] is assumed to be coming from `fletch` in which case
|
| +/// [compiler] is assumed to be coming from `dartino` in which case
|
| /// [COMPILER_EXITCODE_CRASH], [DART_VM_EXITCODE_COMPILE_TIME_ERROR], and
|
| /// [DART_VM_EXITCODE_UNCAUGHT_EXCEPTION] all represent a compiler crash.
|
| ///
|
| -/// [runtime] is assumed to be coming from `fletch-vm` in which case which case
|
| +/// [runtime] is assumed to be coming from `dartino-vm` in which case which case
|
| /// [DART_VM_EXITCODE_COMPILE_TIME_ERROR], and
|
| /// [DART_VM_EXITCODE_UNCAUGHT_EXCEPTION] is just the result of running a test
|
| /// that has an error (not a crash).
|
| @@ -346,8 +346,8 @@ class UnexpectedExitCode extends Error {
|
| }
|
| }
|
|
|
| -class FletchTestCommandOutput extends CommandOutputImpl with DecodeExitCode {
|
| - FletchTestCommandOutput(
|
| +class DartinoTestCommandOutput extends CommandOutputImpl with DecodeExitCode {
|
| + DartinoTestCommandOutput(
|
| Command command,
|
| int exitCode,
|
| bool timedOut,
|
| @@ -409,10 +409,10 @@ class BytesOutputSink implements Sink<List<int>> {
|
| }
|
| }
|
|
|
| -class FletchSessionHelper {
|
| +class DartinoSessionHelper {
|
| final String executable;
|
|
|
| - final FletchSessionMirror sessionMirror;
|
| + final DartinoSessionMirror sessionMirror;
|
|
|
| final String sessionName;
|
|
|
| @@ -436,8 +436,8 @@ class FletchSessionHelper {
|
|
|
| bool hasTimedOut = false;
|
|
|
| - FletchSessionHelper(
|
| - FletchSessionMirror sessionMirror,
|
| + DartinoSessionHelper(
|
| + DartinoSessionMirror sessionMirror,
|
| this.executable,
|
| this.environmentOverrides,
|
| this.isVerbose,
|
| @@ -501,7 +501,7 @@ class FletchSessionHelper {
|
|
|
| int exitCode = await exitCodeWithTimeout(process, timeout, () {
|
| stdout.writeln(
|
| - "\n=> Reached command timeout (sent SIGTERM to fletch-vm)");
|
| + "\n=> Reached command timeout (sent SIGTERM to dartino-vm)");
|
| thisCommandTimedout = true;
|
| hasTimedOut = true;
|
| if (vmProcess != null) {
|
| @@ -540,9 +540,9 @@ class FletchSessionHelper {
|
| }
|
|
|
| Future<String> spawnVm() async {
|
| - FletchVm fletchVm = await FletchVm.start(
|
| + DartinoVm dartinoVm = await DartinoVm.start(
|
| "$executable-vm", environment: environmentOverrides);
|
| - vmProcess = fletchVm.process;
|
| + vmProcess = dartinoVm.process;
|
| String commandDescription = "$executable-vm";
|
| if (isVerbose) {
|
| print("Running $commandDescription");
|
| @@ -552,10 +552,10 @@ class FletchSessionHelper {
|
| stdout.writeln('$commandDescriptionForLog &');
|
|
|
| Future stdoutFuture =
|
| - fletchVm.stdoutLines.listen(vmStdout.writeln).asFuture();
|
| + dartinoVm.stdoutLines.listen(vmStdout.writeln).asFuture();
|
| bool isFirstStderrLine = true;
|
| Future stderrFuture =
|
| - fletchVm.stderrLines.listen(
|
| + dartinoVm.stderrLines.listen(
|
| (String line) {
|
| if (isFirstStderrLine) {
|
| vmStdout.writeln(commandDescriptionForLog);
|
| @@ -565,24 +565,24 @@ class FletchSessionHelper {
|
| })
|
| .asFuture();
|
|
|
| - vmExitCodeFuture = fletchVm.exitCode.then((int exitCode) async {
|
| - if (isVerbose) print("Exiting Fletch VM with exit code $exitCode.");
|
| + vmExitCodeFuture = dartinoVm.exitCode.then((int exitCode) async {
|
| + if (isVerbose) print("Exiting Dartino VM with exit code $exitCode.");
|
| await stdoutFuture;
|
| - if (isVerbose) print("Stdout of Fletch VM process closed.");
|
| + if (isVerbose) print("Stdout of Dartino VM process closed.");
|
| await stderrFuture;
|
| - if (isVerbose) print("Stderr of Fletch VM process closed.");
|
| + if (isVerbose) print("Stderr of Dartino VM process closed.");
|
| return exitCode;
|
| });
|
|
|
| - return "${fletchVm.host}:${fletchVm.port}";
|
| + return "${dartinoVm.host}:${dartinoVm.port}";
|
| }
|
|
|
| - /// Returns a future that completes when the fletch VM exits using
|
| + /// Returns a future that completes when the dartino VM exits using
|
| /// [exitCodeWithTimeout] to ensure termination within [timeout] seconds.
|
| Future<int> shutdownVm(int timeout) async {
|
| await exitCodeWithTimeout(vmProcess, timeout, () {
|
| stdout.writeln(
|
| - "\n**fletch-vm** Reached total timeout (sent SIGTERM to fletch-vm)");
|
| + "\n**dartino-vm** Reached total timeout (sent SIGTERM to dartino-vm)");
|
| killedVmProcess = true;
|
| hasTimedOut = true;
|
| });
|
| @@ -635,8 +635,8 @@ Future<int> exitCodeWithTimeout(
|
| return exitCode;
|
| }
|
|
|
| -/// Represents a session in the persistent Fletch client process.
|
| -class FletchSessionMirror {
|
| +/// Represents a session in the persistent Dartino client process.
|
| +class DartinoSessionMirror {
|
| static const int RINGBUFFER_SIZE = 15;
|
|
|
| final int id;
|
| @@ -645,7 +645,7 @@ class FletchSessionMirror {
|
|
|
| bool isCreated = false;
|
|
|
| - FletchSessionMirror(this.id);
|
| + DartinoSessionMirror(this.id);
|
|
|
| void logCommand(List<String> command) {
|
| internalLoggedCommands.add(command);
|
| @@ -679,10 +679,10 @@ Future<Null> main(List<String> arguments) async {
|
| String script = arguments[1];
|
| arguments = arguments.skip(2).toList();
|
| Map<String, String> environmentOverrides = <String, String>{};
|
| - FletchSessionCommand command = new FletchSessionCommand(
|
| + DartinoSessionCommand command = new DartinoSessionCommand(
|
| executable, script, arguments, environmentOverrides,
|
| settingsFileName: settingsFileName);
|
| - FletchTestCommandOutput output =
|
| + DartinoTestCommandOutput output =
|
| await command.run(0, true, superVerbose: true);
|
| print("Test outcome: ${output.decodeExitCode()}");
|
| }
|
|
|