mirror of
https://github.com/dart-lang/sdk
synced 2024-09-15 22:51:29 +00:00
Clean up some warnings and deprecated calls.
Review URL: https://codereview.chromium.org//12262056 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@18550 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
parent
e2ef36a751
commit
10f7ad94ae
|
@ -28,8 +28,8 @@ Future<List<String>> run(List<String> args,
|
|||
environment: environment);
|
||||
}).then((result) {
|
||||
if (!result.success) throw new Exception(
|
||||
'Git error. Command: git ${Strings.join(args, " ")}\n'
|
||||
'${Strings.join(result.stderr, "\n")}');
|
||||
'Git error. Command: git ${args.join(" ")}\n'
|
||||
'${result.stderr.join("\n")}');
|
||||
|
||||
return result.stdout;
|
||||
});
|
||||
|
|
|
@ -79,7 +79,7 @@ class GitSource extends Source {
|
|||
|
||||
if (!description.isEmpty) {
|
||||
var plural = description.length > 1;
|
||||
var keys = Strings.join(description.keys, ', ');
|
||||
var keys = description.keys.join(', ');
|
||||
throw new FormatException("Invalid key${plural ? 's' : ''}: $keys.");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -187,7 +187,7 @@ Future<List<String>> listDir(dir,
|
|||
// aren't guaranteed to be called in a certain order. So far, they seem to.
|
||||
if (done) {
|
||||
log.fine("Listed directory ${dir.path}:\n"
|
||||
"${Strings.join(contents, '\n')}");
|
||||
"${contents.join('\n')}");
|
||||
completer.complete(contents);
|
||||
}
|
||||
};
|
||||
|
@ -681,7 +681,7 @@ Future _doProcess(Function fn, String executable, List<String> args, workingDir,
|
|||
Future timeout(Future input, int milliseconds, String description) {
|
||||
bool completed = false;
|
||||
var completer = new Completer();
|
||||
var timer = new Timer(new Duration(milliseconds: milliseconds), () {
|
||||
var timer = new Timer(new Duration(milliseconds: milliseconds), (_) {
|
||||
completed = true;
|
||||
completer.completeError(new TimeoutException(
|
||||
'Timed out while $description.'));
|
||||
|
@ -770,8 +770,8 @@ Future<bool> _extractTarGzWindows(Stream<List<int>> stream,
|
|||
}).then((result) {
|
||||
if (result.exitCode != 0) {
|
||||
throw 'Could not un-gzip (exit code ${result.exitCode}). Error:\n'
|
||||
'${Strings.join(result.stdout, "\n")}\n'
|
||||
'${Strings.join(result.stderr, "\n")}';
|
||||
'${result.stdout.join("\n")}\n'
|
||||
'${result.stderr.join("\n")}';
|
||||
}
|
||||
// Find the tar file we just created since we don't know its name.
|
||||
return listDir(tempDir);
|
||||
|
@ -791,8 +791,8 @@ Future<bool> _extractTarGzWindows(Stream<List<int>> stream,
|
|||
}).then((result) {
|
||||
if (result.exitCode != 0) {
|
||||
throw 'Could not un-tar (exit code ${result.exitCode}). Error:\n'
|
||||
'${Strings.join(result.stdout, "\n")}\n'
|
||||
'${Strings.join(result.stderr, "\n")}';
|
||||
'${result.stdout.join("\n")}\n'
|
||||
'${result.stderr.join("\n")}';
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
|
|
@ -110,7 +110,7 @@ Future ioAsync(String startMessage, Future operation,
|
|||
/// Logs the spawning of an [executable] process with [arguments] at [IO]
|
||||
/// level.
|
||||
void process(String executable, List<String> arguments) {
|
||||
io("Spawning $executable ${Strings.join(arguments, ' ')}");
|
||||
io("Spawning $executable ${arguments.join(' ')}");
|
||||
}
|
||||
|
||||
/// Logs the results of running [executable].
|
||||
|
|
|
@ -118,7 +118,7 @@ Credentials _loadCredentials(SystemCache cache) {
|
|||
if (_credentials != null) return _credentials;
|
||||
|
||||
var path = _credentialsFile(cache);
|
||||
if (!fileExists(path)) return;
|
||||
if (!fileExists(path)) return null;
|
||||
|
||||
var credentials = new Credentials.fromJson(readTextFile(path));
|
||||
if (credentials.isExpired && !credentials.canRefresh) {
|
||||
|
|
|
@ -158,7 +158,8 @@ Future defer(callback()) {
|
|||
/// Returns a [Future] that completes in [milliseconds].
|
||||
Future sleep(int milliseconds) {
|
||||
var completer = new Completer();
|
||||
new Timer(new Duration(milliseconds: milliseconds), completer.complete);
|
||||
new Timer(new Duration(milliseconds: milliseconds),
|
||||
(_) => completer.complete());
|
||||
return completer.future;
|
||||
}
|
||||
|
||||
|
@ -326,10 +327,10 @@ String mapToQuery(Map<String, String> map) {
|
|||
value = (value == null || value.isEmpty) ? null : encodeUriComponent(value);
|
||||
pairs.add([key, value]);
|
||||
});
|
||||
return Strings.join(pairs.map((pair) {
|
||||
return pairs.map((pair) {
|
||||
if (pair[1] == null) return pair[0];
|
||||
return "${pair[0]}=${pair[1]}";
|
||||
}), "&");
|
||||
}).join("&");
|
||||
}
|
||||
|
||||
/// Add all key/value pairs from [source] to [destination], overwriting any
|
||||
|
|
|
@ -75,7 +75,7 @@ abstract class Validator {
|
|||
if (!errors.isEmpty) {
|
||||
log.error("Missing requirements:");
|
||||
for (var error in errors) {
|
||||
log.error("* ${Strings.join(error.split('\n'), '\n ')}");
|
||||
log.error("* ${error.split('\n').join('\n ')}");
|
||||
}
|
||||
log.error("");
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ abstract class Validator {
|
|||
if (!warnings.isEmpty) {
|
||||
log.warning("Suggestions:");
|
||||
for (var warning in warnings) {
|
||||
log.warning("* ${Strings.join(warning.split('\n'), '\n ')}");
|
||||
log.warning("* ${warning.split('\n').join('\n ')}");
|
||||
}
|
||||
log.warning("");
|
||||
}
|
||||
|
|
|
@ -116,7 +116,7 @@ class CommandLineConfiguration extends Configuration {
|
|||
String _indent(String str) {
|
||||
// TODO(nweiz): Use this simpler code once issue 2980 is fixed.
|
||||
// return str.replaceAll(new RegExp("^", multiLine: true), " ");
|
||||
return Strings.join(str.split("\n").map((line) => " $line"), "\n");
|
||||
return str.split("\n").map((line) => " $line").join("\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -580,7 +580,7 @@ void schedulePub({List args, Pattern output, Pattern error,
|
|||
failures.addAll(result.stderr.map((line) => '| $line'));
|
||||
}
|
||||
|
||||
throw new ExpectException(Strings.join(failures, '\n'));
|
||||
throw new ExpectException(failures.join('\n'));
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -743,7 +743,7 @@ void _validateOutput(List<String> failures, String pipe, Pattern expected,
|
|||
|
||||
void _validateOutputRegex(List<String> failures, String pipe,
|
||||
RegExp expected, List<String> actual) {
|
||||
var actualText = Strings.join(actual, '\n');
|
||||
var actualText = actual.join('\n');
|
||||
if (actualText.contains(expected)) return;
|
||||
|
||||
if (actual.length == 0) {
|
||||
|
@ -952,8 +952,7 @@ class FileDescriptor extends Descriptor {
|
|||
/// Loads the contents of the file.
|
||||
ByteStream load(List<String> path) {
|
||||
if (!path.isEmpty) {
|
||||
var joinedPath = Strings.join(path, '/');
|
||||
throw "Can't load $joinedPath from within $name: not a directory.";
|
||||
throw "Can't load ${path.join('/')} from within $name: not a directory.";
|
||||
}
|
||||
|
||||
return new ByteStream.fromBytes(contents);
|
||||
|
@ -1019,7 +1018,7 @@ class DirectoryDescriptor extends Descriptor {
|
|||
}
|
||||
}
|
||||
|
||||
throw "Directory $name doesn't contain ${Strings.join(path, '/')}.";
|
||||
throw "Directory $name doesn't contain ${path.join('/')}.";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1103,7 +1102,7 @@ class GitRepoDescriptor extends DirectoryDescriptor {
|
|||
});
|
||||
}
|
||||
|
||||
Future<String> _runGit(List<String> args, Directory workingDir) {
|
||||
Future<List<String>> _runGit(List<String> args, Directory workingDir) {
|
||||
// Explicitly specify the committer information. Git needs this to commit
|
||||
// and we don't want to rely on the buildbots having this already set up.
|
||||
var environment = {
|
||||
|
@ -1151,8 +1150,7 @@ class TarFileDescriptor extends Descriptor {
|
|||
/// Loads the contents of this tar file.
|
||||
ByteStream load(List<String> path) {
|
||||
if (!path.isEmpty) {
|
||||
var joinedPath = Strings.join(path, '/');
|
||||
throw "Can't load $joinedPath from within $name: not a directory.";
|
||||
throw "Can't load ${path.join('/')} from within $name: not a directory.";
|
||||
}
|
||||
|
||||
var controller = new StreamController<List<int>>();
|
||||
|
@ -1186,8 +1184,8 @@ class NothingDescriptor extends Descriptor {
|
|||
if (path.isEmpty) {
|
||||
throw "Can't load the contents of $name: it doesn't exist.";
|
||||
} else {
|
||||
throw "Can't load ${Strings.join(path, '/')} from within $name: $name "
|
||||
"doesn't exist.";
|
||||
throw "Can't load ${path.join('/')} from within $name: $name doesn't "
|
||||
"exist.";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -133,9 +133,9 @@ main() {
|
|||
});
|
||||
|
||||
integration('has "authors" instead of "author"', () {
|
||||
var package = package("test_pkg", "1.0.0");
|
||||
package["authors"] = [package.remove("author")];
|
||||
dir(appPath, [pubspec(package)]).scheduleCreate();
|
||||
var pkg = package("test_pkg", "1.0.0");
|
||||
pkg["authors"] = [pkg.remove("author")];
|
||||
dir(appPath, [pubspec(pkg)]).scheduleCreate();
|
||||
expectNoValidationError(pubspecField);
|
||||
});
|
||||
|
||||
|
@ -206,67 +206,67 @@ main() {
|
|||
setUp(scheduleNormalPackage);
|
||||
|
||||
integration('is missing the "homepage" field', () {
|
||||
var package = package("test_pkg", "1.0.0");
|
||||
package.remove("homepage");
|
||||
dir(appPath, [pubspec(package)]).scheduleCreate();
|
||||
var pkg = package("test_pkg", "1.0.0");
|
||||
pkg.remove("homepage");
|
||||
dir(appPath, [pubspec(pkg)]).scheduleCreate();
|
||||
|
||||
expectValidationError(pubspecField);
|
||||
});
|
||||
|
||||
integration('is missing the "description" field', () {
|
||||
var package = package("test_pkg", "1.0.0");
|
||||
package.remove("description");
|
||||
dir(appPath, [pubspec(package)]).scheduleCreate();
|
||||
var pkg = package("test_pkg", "1.0.0");
|
||||
pkg.remove("description");
|
||||
dir(appPath, [pubspec(pkg)]).scheduleCreate();
|
||||
|
||||
expectValidationError(pubspecField);
|
||||
});
|
||||
|
||||
integration('is missing the "author" field', () {
|
||||
var package = package("test_pkg", "1.0.0");
|
||||
package.remove("author");
|
||||
dir(appPath, [pubspec(package)]).scheduleCreate();
|
||||
var pkg = package("test_pkg", "1.0.0");
|
||||
pkg.remove("author");
|
||||
dir(appPath, [pubspec(pkg)]).scheduleCreate();
|
||||
|
||||
expectValidationError(pubspecField);
|
||||
});
|
||||
|
||||
integration('has a single author without an email', () {
|
||||
var package = package("test_pkg", "1.0.0");
|
||||
package["author"] = "Nathan Weizenbaum";
|
||||
dir(appPath, [pubspec(package)]).scheduleCreate();
|
||||
var pkg = package("test_pkg", "1.0.0");
|
||||
pkg["author"] = "Nathan Weizenbaum";
|
||||
dir(appPath, [pubspec(pkg)]).scheduleCreate();
|
||||
|
||||
expectValidationWarning(pubspecField);
|
||||
});
|
||||
|
||||
integration('has one of several authors without an email', () {
|
||||
var package = package("test_pkg", "1.0.0");
|
||||
package.remove("author");
|
||||
package["authors"] = [
|
||||
var pkg = package("test_pkg", "1.0.0");
|
||||
pkg.remove("author");
|
||||
pkg["authors"] = [
|
||||
"Bob Nystrom <rnystrom@google.com>",
|
||||
"Nathan Weizenbaum",
|
||||
"John Messerly <jmesserly@google.com>"
|
||||
];
|
||||
dir(appPath, [pubspec(package)]).scheduleCreate();
|
||||
dir(appPath, [pubspec(pkg)]).scheduleCreate();
|
||||
|
||||
expectValidationWarning(pubspecField);
|
||||
});
|
||||
|
||||
integration('has a single author without a name', () {
|
||||
var package = package("test_pkg", "1.0.0");
|
||||
package["author"] = "<nweiz@google.com>";
|
||||
dir(appPath, [pubspec(package)]).scheduleCreate();
|
||||
var pkg = package("test_pkg", "1.0.0");
|
||||
pkg["author"] = "<nweiz@google.com>";
|
||||
dir(appPath, [pubspec(pkg)]).scheduleCreate();
|
||||
|
||||
expectValidationWarning(pubspecField);
|
||||
});
|
||||
|
||||
integration('has one of several authors without a name', () {
|
||||
var package = package("test_pkg", "1.0.0");
|
||||
package.remove("author");
|
||||
package["authors"] = [
|
||||
var pkg = package("test_pkg", "1.0.0");
|
||||
pkg.remove("author");
|
||||
pkg["authors"] = [
|
||||
"Bob Nystrom <rnystrom@google.com>",
|
||||
"<nweiz@google.com>",
|
||||
"John Messerly <jmesserly@google.com>"
|
||||
];
|
||||
dir(appPath, [pubspec(package)]).scheduleCreate();
|
||||
dir(appPath, [pubspec(pkg)]).scheduleCreate();
|
||||
|
||||
expectValidationWarning(pubspecField);
|
||||
});
|
||||
|
|
|
@ -465,11 +465,11 @@ class MockSource extends Source {
|
|||
: _packages = <String, Map<Version, Package>>{};
|
||||
|
||||
Future<List<Version>> getVersions(String name, String description) {
|
||||
return fakeAsync(() => _packages[description].keys.toList());
|
||||
return defer(() => _packages[description].keys.toList());
|
||||
}
|
||||
|
||||
Future<Pubspec> describe(PackageId id) {
|
||||
return fakeAsync(() {
|
||||
return defer(() {
|
||||
return _packages[id.name][id.version].pubspec;
|
||||
});
|
||||
}
|
||||
|
@ -526,15 +526,6 @@ class MockVersionlessSource extends Source {
|
|||
}
|
||||
}
|
||||
|
||||
Future fakeAsync(callback()) {
|
||||
var completer = new Completer();
|
||||
Timer.run(() {
|
||||
completer.complete(callback());
|
||||
});
|
||||
|
||||
return completer.future;
|
||||
}
|
||||
|
||||
Pair<String, Source> parseSource(String name) {
|
||||
var match = new RegExp(r"(.*) from (.*)").firstMatch(name);
|
||||
if (match == null) return new Pair<String, Source>(name, source1);
|
||||
|
|
Loading…
Reference in a new issue