| 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 final USAGE_STRING = """ | 12 final USAGE_STRING = """ |
| 13 Pub is a package manager for Dart. | 13 Pub is a package manager for Dart. |
| 14 | 14 |
| 15 Usage: | 15 Usage: |
| 16 | 16 |
| 17 pub command [arguments] | 17 pub command [arguments] |
| 18 | 18 |
| 19 The commands are: | 19 The commands are: |
| 20 | 20 |
| 21 install install the current package's dependencies |
| 21 list print the contents of repositories | 22 list print the contents of repositories |
| 22 update update the current package's dependencies to the latest versions | 23 update update the current package's dependencies to the latest versions |
| 23 version print Pub version | 24 version print Pub version |
| 24 | 25 |
| 25 Use "pub help [command]" for more information about a command. | 26 Use "pub help [command]" for more information about a command. |
| 26 """; | 27 """; |
| 27 | 28 |
| 28 final VERSION_STRING = ''' | 29 final VERSION_STRING = ''' |
| 29 Pub 0.0.0 | 30 Pub 0.0.0 |
| 30 '''; | 31 '''; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 50 testPub('displays an error message', | 51 testPub('displays an error message', |
| 51 args: ['quylthulg'], | 52 args: ['quylthulg'], |
| 52 output: ''' | 53 output: ''' |
| 53 Unknown command "quylthulg". | 54 Unknown command "quylthulg". |
| 54 Run "pub help" to see available commands. | 55 Run "pub help" to see available commands. |
| 55 ''', | 56 ''', |
| 56 exitCode: 64); | 57 exitCode: 64); |
| 57 }); | 58 }); |
| 58 | 59 |
| 59 group('pub list', listCommand); | 60 group('pub list', listCommand); |
| 60 group('pub update', updateCommand); | 61 group('pub install', installCommand); |
| 61 group('pub version', versionCommand); | 62 group('pub version', versionCommand); |
| 62 } | 63 } |
| 63 | 64 |
| 64 listCommand() { | 65 listCommand() { |
| 65 group('cache', () { | 66 group('cache', () { |
| 66 testPub('treats an empty directory as a package', | 67 testPub('treats an empty directory as a package', |
| 67 cache: [ | 68 cache: [ |
| 68 dir('apple'), | 69 dir('sdk', [ |
| 69 dir('banana'), | 70 dir('apple'), |
| 70 dir('cherry') | 71 dir('banana'), |
| 72 dir('cherry') |
| 73 ]) |
| 71 ], | 74 ], |
| 72 args: ['list', 'cache'], | 75 args: ['list', 'cache'], |
| 73 output: ''' | 76 output: ''' |
| 74 apple | 77 From system cache: |
| 75 banana | 78 apple from sdk |
| 76 cherry | 79 banana from sdk |
| 80 cherry from sdk |
| 77 '''); | 81 '''); |
| 78 }); | 82 }); |
| 79 } | 83 } |
| 80 | 84 |
| 81 updateCommand() { | 85 installCommand() { |
| 82 testPub('adds a dependent package', | 86 testPub('adds a dependent package', |
| 83 cache: [ | 87 sdk: [ |
| 84 dir('foo', [ | 88 dir('lib', [ |
| 85 file('foo.dart', 'main() => "foo";') | 89 dir('foo', [ |
| 90 file('foo.dart', 'main() => "foo";') |
| 91 ]) |
| 86 ]) | 92 ]) |
| 87 ], | 93 ], |
| 88 app: dir('myapp', [ | 94 app: dir('myapp', [ |
| 89 file('pubspec', 'dependencies:\n- foo') | 95 file('pubspec', 'dependencies:\n- foo') |
| 90 ]), | 96 ]), |
| 91 args: ['update'], | 97 args: ['install'], |
| 92 expectedPackageDir: [ | 98 expectedPackageDir: [ |
| 93 dir('foo', [ | 99 dir('foo', [ |
| 94 file('foo.dart', 'main() => "foo";') | 100 file('foo.dart', 'main() => "foo";') |
| 95 ]) | 101 ]) |
| 96 ], | 102 ], |
| 97 output: ''); | 103 output: ''' |
| 104 Dependencies installed! |
| 105 '''); |
| 98 | 106 |
| 99 testPub('adds a transitively dependent package', | 107 testPub('adds a transitively dependent package', |
| 100 cache: [ | 108 sdk: [ |
| 101 dir('foo', [ | 109 dir('lib', [ |
| 102 file('foo.dart', 'main() => "foo";'), | 110 dir('foo', [ |
| 103 file('pubspec', 'dependencies:\n- bar') | 111 file('foo.dart', 'main() => "foo";'), |
| 104 ]), | 112 file('pubspec', 'dependencies:\n- bar') |
| 105 dir('bar', [ | 113 ]), |
| 106 file('bar.dart', 'main() => "bar";'), | 114 dir('bar', [ |
| 115 file('bar.dart', 'main() => "bar";'), |
| 116 ]) |
| 107 ]) | 117 ]) |
| 108 ], | 118 ], |
| 109 app: dir('myapp', [ | 119 app: dir('myapp', [ |
| 110 file('pubspec', 'dependencies:\n- foo') | 120 file('pubspec', 'dependencies:\n- foo') |
| 111 ]), | 121 ]), |
| 112 args: ['update'], | 122 args: ['install'], |
| 113 expectedPackageDir: [ | 123 expectedPackageDir: [ |
| 114 dir('foo', [ | 124 dir('foo', [ |
| 115 file('foo.dart', 'main() => "foo";') | 125 file('foo.dart', 'main() => "foo";') |
| 116 ]), | 126 ]), |
| 117 dir('bar', [ | 127 dir('bar', [ |
| 118 file('bar.dart', 'main() => "bar";'), | 128 file('bar.dart', 'main() => "bar";'), |
| 119 ]) | 129 ]) |
| 120 ], | 130 ], |
| 121 output: ''); | 131 output: ''' |
| 132 Dependencies installed! |
| 133 '''); |
| 122 } | 134 } |
| 123 | 135 |
| 124 versionCommand() { | 136 versionCommand() { |
| 125 testPub('displays the current version', | 137 testPub('displays the current version', |
| 126 args: ['version'], | 138 args: ['version'], |
| 127 output: VERSION_STRING); | 139 output: VERSION_STRING); |
| 128 } | 140 } |
| OLD | NEW |