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