Chromium Code Reviews

Unified Diff: lib/src/runner/browser/content_shell.dart

Issue 1080903003: Detect an expired content shell and emit a nice error. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
« no previous file with comments | « no previous file | lib/src/runner/browser/server.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/runner/browser/content_shell.dart
diff --git a/lib/src/runner/browser/content_shell.dart b/lib/src/runner/browser/content_shell.dart
index fe4fef2d134f9bb417e1fa1c610d2a7473025aad..b7791465b51afad18294ad376ddad6a59704b52f 100644
--- a/lib/src/runner/browser/content_shell.dart
+++ b/lib/src/runner/browser/content_shell.dart
@@ -5,10 +5,15 @@
library test.runner.browser.content_shell;
import 'dart:async';
+import 'dart:convert';
import 'dart:io';
+import '../application_exception.dart';
import 'browser.dart';
+/// A converter that transforms a byte stream into a stream of lines.
+final _lines = UTF8.decoder.fuse(const LineSplitter());
+
/// A class for running an instance of the Dartium content shell.
///
/// Most of the communication with the browser is expected to happen via HTTP,
@@ -37,15 +42,32 @@ class ContentShell implements Browser {
ContentShell(url, {String executable}) {
if (executable == null) executable = _defaultExecutable();
+ // Whether we killed content shell because it used an expired Dart version.
+ var expired = false;
+
// Don't return a Future here because there's no need for the caller to wait
// for the process to actually start. They should just wait for the HTTP
// request instead.
Process.start(executable, ["--dump-render-tree", url.toString()],
environment: {"DART_FLAGS": "--checked"}).then((process) {
+ _lines.bind(process.stderr).listen((line) {
+ if (line != "[dartToStderr]: Dartium build has expired") return;
+ expired = true;
+ process.kill();
+ });
+
_process = process;
_onProcessStartedCompleter.complete();
return _process.exitCode;
}).then((exitCode) {
+ if (expired) {
+ throw new ApplicationException(
kevmoo 2015/04/14 22:52:12 Add a TODO to point to the dart site for content_s
nweiz 2015/04/14 23:05:31 Done.
+ "You're using an expired content_shell. Upgrade to the latest "
+ "version:\n"
+ "http://gsdview.appspot.com/dart-archive/channels/stable/release/"
+ "latest/dartium/");
+ }
+
if (exitCode != 0) throw "Content shell failed with exit code $exitCode.";
}).then(_onExitCompleter.complete)
.catchError(_onExitCompleter.completeError);
« no previous file with comments | « no previous file | lib/src/runner/browser/server.dart » ('j') | no next file with comments »

Powered by Google App Engine