Skip to content

Commit

Permalink
merge to master
Browse files Browse the repository at this point in the history
  • Loading branch information
devoncarew committed May 19, 2015
2 parents ab78937 + 4a86f55 commit 013106d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 33 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- In `Dart.run`, deprecate the vmNewGenHeapMB and vmOldGenHeapMB options.
- Added support for passing lists of files or directories to `DartFmt.format()`.
- `Analyzer.analyzeFiles` is deprecated in favor of `Analyzer.analyze`.
- Added a `Pub.global.list()` method to list the installed applications.
- added a `TestRunner` class - a wrapper around the new `test` package.

## 0.7.0 (2015/4/20)
Expand Down
39 changes: 15 additions & 24 deletions lib/grinder_sdk.dart
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ class Pub {
}

static String version({bool quiet: false}) =>
_AppVersion.parse(_run('--version', quiet: quiet)).version;
_parseVersion(_run('--version', quiet: quiet));

static PubGlobal get global => _global;

Expand Down Expand Up @@ -289,7 +289,7 @@ class Dart2js {
}

static String version({bool quiet: false}) =>
_AppVersion.parse(_run('--version', quiet: quiet)).version;
_parseVersion(_run('--version', quiet: quiet));

static String _run(String command, {bool quiet: false}) =>
run_lib.run(_sdkBin('dart2js'), quiet: quiet, arguments: [command]);
Expand Down Expand Up @@ -321,8 +321,8 @@ class Analyzer {
run_lib.run(_sdkBin('dartanalyzer'), arguments: args);
}

static String version({bool quiet: false}) => _AppVersion.parse(run_lib.run(
_sdkBin('dartanalyzer'), quiet: quiet, arguments: ['--version'])).version;
static String version({bool quiet: false}) => _parseVersion(run_lib.run(
_sdkBin('dartanalyzer'), quiet: quiet, arguments: ['--version']));
}

/// Utility class for invoking `dartfmt` from the SDK. This wrapper requires
Expand Down Expand Up @@ -383,7 +383,7 @@ class PubGlobal {
}

/// Return the list of installed applications.
List<_AppVersion> _list() {
List<PubApp> list() {
//dart_coveralls 0.1.8
//den 0.1.3
//discoveryapis_generator 0.6.1
Expand All @@ -395,9 +395,8 @@ class PubGlobal {
var lines = stdout.trim().split('\n');
return lines.map((line) {
line = line.trim();
if (!line.contains(' ')) return new _AppVersion(line);
var parts = line.split(' ');
return new _AppVersion(parts.first, parts[1]);
if (!line.contains(' ')) return new PubApp.global(line);
return new PubApp.global(line.split(' ').first);
}).toList();
}

Expand All @@ -410,7 +409,7 @@ class PubGlobal {
void _initActivated() {
if (_activatedPackages == null) {
_activatedPackages = new Set();
_activatedPackages.addAll(_list().map((appVer) => appVer.name));
_activatedPackages.addAll(list().map((app) => app.packageName));
}
}
}
Expand Down Expand Up @@ -476,21 +475,13 @@ String _sdkBin(String name) {
}
}

/// A version/app name pair.
class _AppVersion {
final String name;
final String version;

_AppVersion(this.name, [this.version]);

static _AppVersion parse(String output) {
var lastSpace = output.lastIndexOf(' ');
if (lastSpace == -1) return new _AppVersion(output);
return new _AppVersion(
output.substring(0, lastSpace), output.substring(lastSpace + 1));
}

String toString() => '$name $version';
/// Parse the version out of strings like:
///
/// dart_coveralls 0.1.11
/// pub_cache 0.0.1 at path "/Users/foobar/projects/pub_cache"
String _parseVersion(String output) {
List<String> tokens = output.split(' ');
return tokens.length < 2 ? null : tokens[1];
}

class _PubGlobalApp extends PubApp {
Expand Down
15 changes: 6 additions & 9 deletions test/grinder_sdk_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,12 @@ main() {
expect(ctx.isFailed, false);
});

// See #166.
// test('Pub.list', () {
// return mockContext.runZoned(() {
// expect(Pub.global._list(), isNotNull);
// }).then((_) {
// expect(mockContext.logBuffer, isNotEmpty);
// expect(mockContext.isFailed, false);
// });
// });
grinderTest('Pub.list', () {
expect(Pub.global.list(), isNotNull);
}, (ctx) {
expect(ctx.logBuffer, isEmpty);
expect(ctx.isFailed, false);
});

grinderTest('Pub.isActivated', () {
expect(Pub.global.isActivated('foo'), false);
Expand Down

0 comments on commit 013106d

Please sign in to comment.