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

Side by Side Diff: tools/testing/dart/drt_updater.dart

Issue 841193003: cleanup to tools/testing/dart (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: one last bit Created 5 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « tools/testing/dart/dependency_graph.dart ('k') | tools/testing/dart/html_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
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.
4
5 // TODO(antonm): rename to something like test_runner_updater.
6
7 library drt_updater;
8
9 import "dart:async";
10 import "dart:io";
11
12 import "test_suite.dart";
13
14 class _DartiumUpdater {
15 String name;
16 String script;
17 String option;
18
19 bool isActive = false;
20 bool updated = false;
21 List onUpdated;
22
23 Future<ProcessResult> _updatingProcess;
24
25 _DartiumUpdater(this.name, this.script, [this.option = null]);
26
27 void update() {
28 if (!isActive) {
29 isActive = true;
30 print('Updating $name.');
31 onUpdated = [() {updated = true;} ];
32 _updatingProcess = Process.run('python', _getUpdateCommand);
33 _updatingProcess.then(_onUpdatedHandler).catchError((e) {
34 print("Error starting $script process: $e");
35 // TODO(floitsch): should we print the stacktrace?
36 return false;
37 });
38 }
39 }
40
41 List<String> get _getUpdateCommand {
42 Uri updateScript = TestUtils.dartDirUri.resolve(script);
43 List<String> command = [updateScript.toFilePath()];
44 if (null != option) {
45 command.add(option);
46 }
47 return command;
48 }
49
50 void _onUpdatedHandler(ProcessResult result) {
51 if (result.exitCode == 0) {
52 print('$name updated');
53 } else {
54 print('Failure updating $name');
55 print(' Exit code: ${result.exitCode}');
56 print(result.stdout);
57 print(result.stderr);
58 exit(1);
59 }
60 for (var callback in onUpdated ) callback();
61 }
62 }
63
64 _DartiumUpdater _contentShellUpdater;
65 _DartiumUpdater _dartiumUpdater;
66
67 _DartiumUpdater runtimeUpdater(Map configuration) {
68 String runtime = configuration['runtime'];
69 if (runtime == 'drt' && configuration['drt'] == '') {
70 // Download the default content shell from Google Storage.
71 if (_contentShellUpdater == null) {
72 _contentShellUpdater = new _DartiumUpdater('Content Shell',
73 'tools/get_archive.py',
74 'drt');
75 }
76 return _contentShellUpdater;
77 } else if (runtime == 'dartium' && configuration['dartium'] == '') {
78 // Download the default Dartium from Google Storage.
79 if (_dartiumUpdater == null) {
80 _dartiumUpdater = new _DartiumUpdater('Dartium Chrome',
81 'tools/get_archive.py',
82 'dartium');
83 }
84 return _dartiumUpdater;
85 } else {
86 return null;
87 }
88 }
OLDNEW
« no previous file with comments | « tools/testing/dart/dependency_graph.dart ('k') | tools/testing/dart/html_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698