| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 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 | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #library('pub_tests'); | 5 #library('pub_tests'); |
| 6 | 6 |
| 7 #import('dart:io'); | 7 #import('dart:io'); |
| 8 | 8 |
| 9 #import('test_pub.dart'); | 9 #import('test_pub.dart'); |
| 10 #import('../../../lib/unittest/unittest.dart'); | 10 #import('../../../lib/unittest/unittest.dart'); |
| 11 | 11 |
| 12 main() { | 12 main() { |
| 13 group('running pub with no command', () { | 13 group('running pub with no command', () { |
| 14 testPub('displays usage', | 14 testPub('displays usage', |
| 15 args: [], | 15 args: [], |
| 16 output: ''' | 16 output: """ |
| 17 Pub is a package manager for Dart. | 17 Pub is a package manager for Dart. |
| 18 | 18 |
| 19 Usage: | 19 Usage: |
| 20 | 20 |
| 21 pub command [arguments] | 21 pub command [arguments] |
| 22 | 22 |
| 23 The commands are: | 23 The commands are: |
| 24 | 24 |
| 25 list print the contents of repositories | 25 list print the contents of repositories |
| 26 update update a package's dependencies |
| 26 version print Pub version | 27 version print Pub version |
| 27 | 28 |
| 28 Use "pub help [command]" for more information about a command.'''); | 29 Use "pub help [command]" for more information about a command. |
| 30 """); |
| 29 }); | 31 }); |
| 30 | 32 |
| 31 group('an unknown command', () { | 33 group('an unknown command', () { |
| 32 testPub('displays an error message', | 34 testPub('displays an error message', |
| 33 args: ['quylthulg'], | 35 args: ['quylthulg'], |
| 34 output: ''' | 36 output: ''' |
| 35 Unknown command "quylthulg". | 37 Unknown command "quylthulg". |
| 36 Run "pub help" to see available commands.''', | 38 Run "pub help" to see available commands. |
| 39 ''', |
| 37 exitCode: 64); | 40 exitCode: 64); |
| 38 }); | 41 }); |
| 39 | 42 |
| 40 listCommand(); | 43 group('pub list', listCommand); |
| 41 versionCommand(); | 44 group('pub update', updateCommand); |
| 45 group('pub version', versionCommand); |
| 42 } | 46 } |
| 43 | 47 |
| 44 listCommand() { | 48 listCommand() { |
| 45 group('list cache', () { | 49 group('cache', () { |
| 46 testPub('treats an empty directory as a package', | 50 testPub('treats an empty directory as a package', |
| 47 cache: [ | 51 cache: [ |
| 48 dir('apple'), | 52 dir('apple'), |
| 49 dir('banana'), | 53 dir('banana'), |
| 50 dir('cherry') | 54 dir('cherry') |
| 51 ], | 55 ], |
| 52 args: ['list', 'cache'], | 56 args: ['list', 'cache'], |
| 53 output: ''' | 57 output: ''' |
| 54 apple | 58 apple |
| 55 banana | 59 banana |
| 56 cherry'''); | 60 cherry |
| 61 '''); |
| 57 }); | 62 }); |
| 58 } | 63 } |
| 59 | 64 |
| 65 updateCommand() { |
| 66 testPub('adds a dependent package', |
| 67 cache: [ |
| 68 dir('foo', [ |
| 69 file('foo.dart', 'main() => "foo";') |
| 70 ]) |
| 71 ], |
| 72 app: dir('myapp', [ |
| 73 file('pubspec', 'foo') |
| 74 ]), |
| 75 args: ['update'], |
| 76 expectedPackageDir: [ |
| 77 dir('foo', [ |
| 78 file('foo.dart', 'main() => "foo";') |
| 79 ]) |
| 80 ], |
| 81 output: ''); |
| 82 |
| 83 testPub('adds a transitively dependent package', |
| 84 cache: [ |
| 85 dir('foo', [ |
| 86 file('foo.dart', 'main() => "foo";'), |
| 87 file('pubspec', 'bar') |
| 88 ]), |
| 89 dir('bar', [ |
| 90 file('bar.dart', 'main() => "bar";'), |
| 91 ]) |
| 92 ], |
| 93 app: dir('myapp', [ |
| 94 file('pubspec', 'foo') |
| 95 ]), |
| 96 args: ['update'], |
| 97 expectedPackageDir: [ |
| 98 dir('foo', [ |
| 99 file('foo.dart', 'main() => "foo";') |
| 100 ]), |
| 101 dir('bar', [ |
| 102 file('bar.dart', 'main() => "bar";'), |
| 103 ]) |
| 104 ], |
| 105 output: ''); |
| 106 } |
| 107 |
| 60 versionCommand() { | 108 versionCommand() { |
| 61 group('the version command', () { | 109 testPub('displays the current version', |
| 62 testPub('displays the current version', | 110 args: ['version'], |
| 63 args: ['version'], | 111 output: ''' |
| 64 output: 'Pub 0.0.0'); | 112 Pub 0.0.0 |
| 65 }); | 113 '''); |
| 66 } | 114 } |
| OLD | NEW |