OLD | NEW |
(Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 library pub_tests; |
| 6 |
| 7 import 'package:scheduled_test/scheduled_test.dart'; |
| 8 |
| 9 import '../lib/src/exit_codes.dart' as exit_codes; |
| 10 import 'descriptor.dart' as d; |
| 11 import 'test_pub.dart'; |
| 12 |
| 13 main() { |
| 14 initConfig(); |
| 15 |
| 16 forBothPubGetAndUpgrade((command) { |
| 17 group('requires', () { |
| 18 integration('a pubspec', () { |
| 19 d.dir(appPath, []).create(); |
| 20 |
| 21 pubCommand( |
| 22 command, |
| 23 error: new RegExp( |
| 24 r'Could not find a file named "pubspec.yaml" ' r'in "[^\n]*"\.')
); |
| 25 }); |
| 26 |
| 27 integration('a pubspec with a "name" key', () { |
| 28 d.dir(appPath, [d.pubspec({ |
| 29 "dependencies": { |
| 30 "foo": null |
| 31 } |
| 32 })]).create(); |
| 33 |
| 34 pubCommand( |
| 35 command, |
| 36 error: contains('Missing the required "name" field.'), |
| 37 exitCode: exit_codes.DATA); |
| 38 }); |
| 39 }); |
| 40 |
| 41 integration('adds itself to the packages', () { |
| 42 // The symlink should use the name in the pubspec, not the name of the |
| 43 // directory. |
| 44 d.dir(appPath, [d.pubspec({ |
| 45 "name": "myapp_name" |
| 46 }), d.libDir('myapp_name')]).create(); |
| 47 |
| 48 pubCommand(command); |
| 49 |
| 50 d.dir( |
| 51 packagesPath, |
| 52 [ |
| 53 d.dir( |
| 54 "myapp_name", |
| 55 [d.file('myapp_name.dart', 'main() => "myapp_name";')])]).vali
date(); |
| 56 }); |
| 57 |
| 58 integration( |
| 59 'does not adds itself to the packages if it has no "lib" ' 'directory', |
| 60 () { |
| 61 // The symlink should use the name in the pubspec, not the name of the |
| 62 // directory. |
| 63 d.dir(appPath, [d.pubspec({ |
| 64 "name": "myapp_name" |
| 65 }),]).create(); |
| 66 |
| 67 pubCommand(command); |
| 68 |
| 69 d.dir(packagesPath, [d.nothing("myapp_name")]).validate(); |
| 70 }); |
| 71 |
| 72 integration( |
| 73 'does not add a package if it does not have a "lib" ' 'directory', |
| 74 () { |
| 75 // Using a path source, but this should be true of all sources. |
| 76 d.dir('foo', [d.libPubspec('foo', '0.0.0-not.used')]).create(); |
| 77 |
| 78 d.dir(appPath, [d.appPubspec({ |
| 79 "foo": { |
| 80 "path": "../foo" |
| 81 } |
| 82 })]).create(); |
| 83 |
| 84 pubCommand(command); |
| 85 |
| 86 d.packagesDir({ |
| 87 "foo": null |
| 88 }).validate(); |
| 89 }); |
| 90 |
| 91 integration('reports a solver failure', () { |
| 92 // myapp depends on foo and bar which both depend on baz with mismatched |
| 93 // descriptions. |
| 94 d.dir('deps', [d.dir('foo', [d.pubspec({ |
| 95 "name": "foo", |
| 96 "dependencies": { |
| 97 "baz": { |
| 98 "path": "../baz1" |
| 99 } |
| 100 } |
| 101 })]), d.dir('bar', [d.pubspec({ |
| 102 "name": "bar", |
| 103 "dependencies": { |
| 104 "baz": { |
| 105 "path": "../baz2" |
| 106 } |
| 107 } |
| 108 })]), |
| 109 d.dir('baz1', [d.libPubspec('baz', '0.0.0')]), |
| 110 d.dir('baz2', [d.libPubspec('baz', '0.0.0')])]).create(); |
| 111 |
| 112 d.dir(appPath, [d.appPubspec({ |
| 113 "foo": { |
| 114 "path": "../deps/foo" |
| 115 }, |
| 116 "bar": { |
| 117 "path": "../deps/bar" |
| 118 } |
| 119 })]).create(); |
| 120 |
| 121 pubCommand( |
| 122 command, |
| 123 error: new RegExp("^Incompatible dependencies on baz:\n")); |
| 124 }); |
| 125 |
| 126 integration('does not allow a dependency on itself', () { |
| 127 d.dir(appPath, [d.appPubspec({ |
| 128 "myapp": { |
| 129 "path": "." |
| 130 } |
| 131 })]).create(); |
| 132 |
| 133 pubCommand( |
| 134 command, |
| 135 error: contains('A package may not list itself as a dependency.'), |
| 136 exitCode: exit_codes.DATA); |
| 137 }); |
| 138 |
| 139 integration('does not allow a dev dependency on itself', () { |
| 140 d.dir(appPath, [d.pubspec({ |
| 141 "name": "myapp", |
| 142 "dev_dependencies": { |
| 143 "myapp": { |
| 144 "path": "." |
| 145 } |
| 146 } |
| 147 })]).create(); |
| 148 |
| 149 pubCommand( |
| 150 command, |
| 151 error: contains('A package may not list itself as a dependency.'), |
| 152 exitCode: exit_codes.DATA); |
| 153 }); |
| 154 }); |
| 155 } |
OLD | NEW |