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 'dart:io'; |
| 8 |
| 9 import 'package:scheduled_test/scheduled_test.dart'; |
| 10 |
| 11 import 'descriptor.dart' as d; |
| 12 import 'test_pub.dart'; |
| 13 |
| 14 main() { |
| 15 initConfig(); |
| 16 |
| 17 forBothPubInstallAndUpdate((command) { |
| 18 group('requires', () { |
| 19 integration('a pubspec', () { |
| 20 d.dir(appPath, []).create(); |
| 21 |
| 22 pubCommand(command, |
| 23 error: new RegExp(r'^Could not find a file named "pubspec.yaml"')); |
| 24 }); |
| 25 |
| 26 integration('a pubspec with a "name" key', () { |
| 27 d.dir(appPath, [ |
| 28 d.pubspec({"dependencies": {"foo": null}}) |
| 29 ]).create(); |
| 30 |
| 31 pubCommand(command, error: new RegExp( |
| 32 r'^pubspec.yaml is missing the required "name" field ' |
| 33 r'\(e\.g\. "name: myapp"\)\.')); |
| 34 }); |
| 35 }); |
| 36 |
| 37 integration('adds itself to the packages', () { |
| 38 // The symlink should use the name in the pubspec, not the name of the |
| 39 // directory. |
| 40 d.dir(appPath, [ |
| 41 d.pubspec({"name": "myapp_name"}), |
| 42 d.libDir('myapp_name') |
| 43 ]).create(); |
| 44 |
| 45 pubCommand(command); |
| 46 |
| 47 d.dir(packagesPath, [ |
| 48 d.dir("myapp_name", [ |
| 49 d.file('myapp_name.dart', 'main() => "myapp_name";') |
| 50 ]) |
| 51 ]).validate(); |
| 52 }); |
| 53 |
| 54 integration('does not adds itself to the packages if it has no "lib" ' |
| 55 'directory', () { |
| 56 // The symlink should use the name in the pubspec, not the name of the |
| 57 // directory. |
| 58 d.dir(appPath, [ |
| 59 d.pubspec({"name": "myapp_name"}), |
| 60 ]).create(); |
| 61 |
| 62 pubCommand(command); |
| 63 |
| 64 d.dir(packagesPath, [ |
| 65 d.nothing("myapp_name") |
| 66 ]).validate(); |
| 67 }); |
| 68 |
| 69 integration('does not add a package if it does not have a "lib" ' |
| 70 'directory', () { |
| 71 // Using a path source, but this should be true of all sources. |
| 72 d.dir('foo', [ |
| 73 d.libPubspec('foo', '0.0.0-not.used') |
| 74 ]).create(); |
| 75 |
| 76 d.dir(appPath, [ |
| 77 d.pubspec({"name": "myapp", "dependencies": {"foo": {"path": "../foo"}}}
) |
| 78 ]).create(); |
| 79 |
| 80 pubCommand(command); |
| 81 |
| 82 d.packagesDir({"foo": null}).validate(); |
| 83 }); |
| 84 |
| 85 integration('reports a solver failure', () { |
| 86 // myapp depends on foo and bar which both depend on baz with mismatched |
| 87 // descriptions. |
| 88 d.dir('deps', [ |
| 89 d.dir('foo', [ |
| 90 d.pubspec({"name": "foo", "dependencies": { |
| 91 "baz": {"path": "../baz1"} |
| 92 }}) |
| 93 ]), |
| 94 d.dir('bar', [ |
| 95 d.pubspec({"name": "bar", "dependencies": { |
| 96 "baz": {"path": "../baz2"} |
| 97 }}) |
| 98 ]), |
| 99 d.dir('baz1', [ |
| 100 d.libPubspec('baz', '0.0.0') |
| 101 ]), |
| 102 d.dir('baz2', [ |
| 103 d.libPubspec('baz', '0.0.0') |
| 104 ]) |
| 105 ]).create(); |
| 106 |
| 107 d.dir(appPath, [ |
| 108 d.pubspec({"name": "myapp", "dependencies": { |
| 109 "foo": {"path": "../deps/foo"}, |
| 110 "bar": {"path": "../deps/bar"} |
| 111 }}) |
| 112 ]).create(); |
| 113 |
| 114 pubCommand(command, |
| 115 error: new RegExp(r"^Incompatible dependencies on 'baz':")); |
| 116 }); |
| 117 }); |
| 118 } |
OLD | NEW |