Chromium Code Reviews| Index: utils/tests/pub/pub_tests.dart |
| diff --git a/utils/tests/pub/pub_tests.dart b/utils/tests/pub/pub_tests.dart |
| index 53456fd48cdff396c75090e8c39e45b90674bb78..055e06c31392371fc5ece8b9c9b0506e18f234c2 100644 |
| --- a/utils/tests/pub/pub_tests.dart |
| +++ b/utils/tests/pub/pub_tests.dart |
| @@ -4,11 +4,66 @@ |
| #library('pub_tests'); |
| -// TODO(rnystrom): Better path to unittest. |
| +#import('dart:io'); |
| + |
| +#import('test_pub.dart'); |
| #import('../../../lib/unittest/unittest_vm.dart'); |
| main() { |
| - test('should pass', () { |
| - expect(1).equals(1); |
| + group('running pub with no command', () { |
| + testOutput('displays usage', |
| + [], |
| + ''' |
| + Pub is a package manager for Dart. |
| + |
| + Usage: |
| + |
| + pub command [arguments] |
| + |
| + The commands are: |
| + |
| + version print Pub version |
| + |
| + Use "pub help [command]" for more information about a command.'''); |
| + }); |
| + |
| + group('the version command', () { |
| + testOutput('displays the current version', |
| + ['version'], 'Pub 0.0.0'); |
| }); |
| + |
| + group('an unknown command', () { |
| + testOutput('displays an error message', |
| + ['quylthulg'], |
| + ''' |
| + Unknown command "quylthulg". |
| + Run "pub help" to see available commands.''', |
| + exitCode: 64); |
| + }); |
| +} |
| + |
| +void testPub(String description, List<String> arguments, String expectedOutput) { |
|
nweiz
2012/03/30 00:38:37
This name doesn't match that being used in main(),
Bob Nystrom
2012/03/30 01:06:17
Oops, old code. Deleted.
|
| + // TODO(bob): Figure out how to invoke pub correctly. |
| + Expect.fail('args = ${new Options().script}'); |
|
nweiz
2012/03/30 00:38:37
Debugging line?
|
| + |
| + final process = new Process.start('pub', arguments); |
| + |
| + final output = <String>[]; |
| + final outStream = new StringInputStream(process.stdout); |
| + outStream.onLine = () { |
| + var line = outStream.readLine(); |
| + while (line != null) { |
| + output.add(line); |
| + line = outStream.readLine(); |
| + } |
| + }; |
| + |
| + process.onError = (error) { |
| + Expect.fail('Failed to run pub: $error'); |
| + }; |
| + |
| + process.onExit = (exitCode) { |
| + Expect.equals(exitCode, 0, 'Pub returned non-zero exit code.'); |
| + validateOutput(expectedOutput, output); |
| + }; |
| } |
|
nweiz
2012/03/30 00:38:37
How does this async stuff integrate into the testi
Bob Nystrom
2012/03/30 01:06:17
Yeah, this is dead code. The real code is in test_
|