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

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: Code review changes Created 5 years, 8 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 | « 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..2df48c32f4556fc00e457b6eb2158be793f3ea7e 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,35 @@ 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) {
+ // TODO(nweiz): link to dartlang.org once it has download links for
+ // content shell
+ // (https://github.com/dart-lang/www.dartlang.org/issues/1164).
+ throw new ApplicationException(
+ "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
This is Rietveld 408576698