| 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'); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 version print Pub version | 24 version print Pub version |
| 25 | 25 |
| 26 Use "pub help [command]" for more information about a command. | 26 Use "pub help [command]" for more information about a command. |
| 27 """; | 27 """; |
| 28 | 28 |
| 29 final VERSION_STRING = ''' | 29 final VERSION_STRING = ''' |
| 30 Pub 0.0.0 | 30 Pub 0.0.0 |
| 31 '''; | 31 '''; |
| 32 | 32 |
| 33 main() { | 33 main() { |
| 34 testPub('running pub with no command displays usage', | 34 test('running pub with no command displays usage', () => |
| 35 args: [], | 35 runPub(args: [], output: USAGE_STRING)); |
| 36 output: USAGE_STRING); | |
| 37 | 36 |
| 38 testPub('running pub with just --help displays usage', | 37 test('running pub with just --help displays usage', () => |
| 39 args: ['--help'], | 38 runPub(args: ['--help'], output: USAGE_STRING)); |
| 40 output: USAGE_STRING); | |
| 41 | 39 |
| 42 testPub('running pub with just -h displays usage', | 40 test('running pub with just -h displays usage', () => |
| 43 args: ['-h'], | 41 runPub(args: ['-h'], output: USAGE_STRING)); |
| 44 output: USAGE_STRING); | |
| 45 | 42 |
| 46 testPub('running pub with just --version displays version', | 43 test('running pub with just --version displays version', () => |
| 47 args: ['--version'], | 44 runPub(args: ['--version'], output: VERSION_STRING)); |
| 48 output: VERSION_STRING); | |
| 49 | 45 |
| 50 group('an unknown command', () { | 46 group('an unknown command', () { |
| 51 testPub('displays an error message', | 47 test('displays an error message', () { |
| 52 args: ['quylthulg'], | 48 runPub(args: ['quylthulg'], |
| 53 output: ''' | 49 output: ''' |
| 54 Unknown command "quylthulg". | 50 Unknown command "quylthulg". |
| 55 Run "pub help" to see available commands. | 51 Run "pub help" to see available commands. |
| 56 ''', | 52 ''', |
| 57 exitCode: 64); | 53 exitCode: 64); |
| 54 }); |
| 58 }); | 55 }); |
| 59 | 56 |
| 60 group('pub list', listCommand); | 57 group('pub list', listCommand); |
| 61 group('pub install', installCommand); | 58 group('pub install', installCommand); |
| 62 group('pub version', versionCommand); | 59 group('pub version', versionCommand); |
| 63 } | 60 } |
| 64 | 61 |
| 65 listCommand() { | 62 listCommand() { |
| 66 group('cache', () { | 63 group('cache', () { |
| 67 testPub('treats an empty directory as a package', | 64 test('treats an empty directory as a package', () { |
| 68 cache: [ | 65 dir(cachePath, [ |
| 69 dir('sdk', [ | 66 dir('sdk', [ |
| 70 dir('apple'), | 67 dir('apple'), |
| 71 dir('banana'), | 68 dir('banana'), |
| 72 dir('cherry') | 69 dir('cherry') |
| 73 ]) | 70 ]) |
| 74 ], | 71 ]).scheduleCreate(); |
| 75 args: ['list', 'cache'], | 72 |
| 76 output: ''' | 73 runPub(args: ['list', 'cache'], |
| 77 From system cache: | 74 output: ''' |
| 78 apple from sdk | 75 From system cache: |
| 79 banana from sdk | 76 apple from sdk |
| 80 cherry from sdk | 77 banana from sdk |
| 81 '''); | 78 cherry from sdk |
| 79 '''); |
| 80 }); |
| 82 }); | 81 }); |
| 83 } | 82 } |
| 84 | 83 |
| 85 installCommand() { | 84 installCommand() { |
| 86 testPub('adds a dependent package', | 85 test('adds a dependent package', () { |
| 87 sdk: [ | 86 dir(sdkPath, [ |
| 88 dir('lib', [ | 87 dir('lib', [ |
| 89 dir('foo', [ | 88 dir('foo', [ |
| 90 file('foo.dart', 'main() => "foo";') | 89 file('foo.dart', 'main() => "foo";') |
| 91 ]) | 90 ]) |
| 92 ]) | 91 ]) |
| 93 ], | 92 ]).scheduleCreate(); |
| 94 app: dir('myapp', [ | 93 |
| 94 dir(appPath, [ |
| 95 file('pubspec', 'dependencies:\n- foo') | 95 file('pubspec', 'dependencies:\n- foo') |
| 96 ]), | 96 ]).scheduleCreate(); |
| 97 args: ['install'], | 97 |
| 98 expectedPackageDir: [ | 98 dir(packagesPath, [ |
| 99 dir('foo', [ | 99 dir('foo', [ |
| 100 file('foo.dart', 'main() => "foo";') | 100 file('foo.dart', 'main() => "foo";') |
| 101 ]) | 101 ]) |
| 102 ], | 102 ]).scheduleValidate(); |
| 103 output: ''' | |
| 104 Dependencies installed! | |
| 105 '''); | |
| 106 | 103 |
| 107 testPub('adds a transitively dependent package', | 104 runPub(args: ['install'], |
| 108 sdk: [ | 105 output: ''' |
| 106 Dependencies installed! |
| 107 '''); |
| 108 }); |
| 109 |
| 110 test('adds a transitively dependent package', () { |
| 111 dir(sdkPath, [ |
| 109 dir('lib', [ | 112 dir('lib', [ |
| 110 dir('foo', [ | 113 dir('foo', [ |
| 111 file('foo.dart', 'main() => "foo";'), | 114 file('foo.dart', 'main() => "foo";'), |
| 112 file('pubspec', 'dependencies:\n- bar') | 115 file('pubspec', 'dependencies:\n- bar') |
| 113 ]), | 116 ]), |
| 114 dir('bar', [ | 117 dir('bar', [ |
| 115 file('bar.dart', 'main() => "bar";'), | 118 file('bar.dart', 'main() => "bar";'), |
| 116 ]) | 119 ]) |
| 117 ]) | 120 ]) |
| 118 ], | 121 ]).scheduleCreate(); |
| 119 app: dir('myapp', [ | 122 |
| 123 dir(appPath, [ |
| 120 file('pubspec', 'dependencies:\n- foo') | 124 file('pubspec', 'dependencies:\n- foo') |
| 121 ]), | 125 ]).scheduleCreate(); |
| 122 args: ['install'], | 126 |
| 123 expectedPackageDir: [ | 127 dir(packagesPath, [ |
| 124 dir('foo', [ | 128 dir('foo', [ |
| 125 file('foo.dart', 'main() => "foo";') | 129 file('foo.dart', 'main() => "foo";') |
| 126 ]), | 130 ]), |
| 127 dir('bar', [ | 131 dir('bar', [ |
| 128 file('bar.dart', 'main() => "bar";'), | 132 file('bar.dart', 'main() => "bar";'), |
| 129 ]) | 133 ]) |
| 130 ], | 134 ]).scheduleValidate(); |
| 131 output: ''' | 135 |
| 132 Dependencies installed! | 136 runPub(args: ['install'], |
| 133 '''); | 137 output: ''' |
| 138 Dependencies installed! |
| 139 '''); |
| 140 }); |
| 134 } | 141 } |
| 135 | 142 |
| 136 versionCommand() { | 143 versionCommand() { |
| 137 testPub('displays the current version', | 144 test('displays the current version', () => |
| 138 args: ['version'], | 145 runPub(args: ['version'], output: VERSION_STRING)); |
| 139 output: VERSION_STRING); | |
| 140 } | 146 } |
| OLD | NEW |