Files
sdk/tools/testing/dart/runtime_updater.dart
T
Bob Nystrom ba2e4aff24 Some minor clean-up in test.dart.
- Fix fuzzy arrow errors.
- Default the Dart repo URI so it doesn't always need to be explicitly
  set.
- Run dartfmt on everything.
- Move some members out of the garbage bin "TestUtils" class:
  - Move the stuff around the Dart repo directory to a new Repository
    class.
  - Move absolute() into Path where it belongs.
  - Move workingDirectory in Path since it is a Path.
  - Delete the random number stuff since it was apparently unused.

Change-Id: I3dab3a4f1713b7a749e64b6776149d05a0ce1b69
Reviewed-on: https://dart-review.googlesource.com/14502
Commit-Queue: Bob Nystrom <rnystrom@google.com>
Reviewed-by: William Hesse <whesse@google.com>
2017-10-19 19:05:58 +00:00

53 lines
1.3 KiB
Dart

// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'dart:async';
import 'dart:io';
import 'repository.dart';
Future _contentShellFuture;
/// Runs "tools/get_archive.py" to download and install Content Shell.
Future updateContentShell(String drtPath) {
if (_contentShellFuture == null) {
_contentShellFuture =
new _RuntimeUpdater('Content Shell', 'tools/get_archive.py', 'drt')
.update();
}
return _contentShellFuture;
}
class _RuntimeUpdater {
String _name;
String _script;
String _option;
_RuntimeUpdater(this._name, this._script, [this._option]);
Future update() async {
try {
print('Updating $_name...');
var arguments = [Repository.uri.resolve(_script).toFilePath()];
if (_option != null) arguments.add(_option);
var result = await Process.run('python', arguments);
if (result.exitCode == 0) {
print('Updated $_name.');
} else {
print('Failed to update $_name (exit code ${result.exitCode}):');
print(result.stdout);
print(result.stderr);
exit(1);
}
} catch (error) {
print("Error starting $_script process: $error");
exit(1);
}
}
}