| 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 '../../../../pkg/unittest/lib/unittest.dart'; |
| 9 import '../test_pub.dart'; | 10 import '../test_pub.dart'; |
| 10 import '../../../../pkg/unittest/lib/unittest.dart'; | |
| 11 | 11 |
| 12 main() { | 12 main() { |
| 13 group('requires', () { | 13 group('requires', () { |
| 14 test('a pubspec', () { | 14 integration('a pubspec', () { |
| 15 dir(appPath, []).scheduleCreate(); | 15 dir(appPath, []).scheduleCreate(); |
| 16 | 16 |
| 17 schedulePub(args: ['update'], | 17 schedulePub(args: ['update'], |
| 18 error: new RegExp(r'^Could not find a file named "pubspec.yaml"'), | 18 error: new RegExp(r'^Could not find a file named "pubspec.yaml"'), |
| 19 exitCode: 1); | 19 exitCode: 1); |
| 20 | |
| 21 run(); | |
| 22 }); | 20 }); |
| 23 | 21 |
| 24 test('a pubspec with a "name" key', () { | 22 integration('a pubspec with a "name" key', () { |
| 25 dir(appPath, [ | 23 dir(appPath, [ |
| 26 pubspec({"dependencies": {"foo": null}}) | 24 pubspec({"dependencies": {"foo": null}}) |
| 27 ]).scheduleCreate(); | 25 ]).scheduleCreate(); |
| 28 | 26 |
| 29 schedulePub(args: ['update'], | 27 schedulePub(args: ['update'], |
| 30 error: new RegExp(r'^pubspec.yaml is missing the required "name" ' | 28 error: new RegExp(r'^pubspec.yaml is missing the required "name" ' |
| 31 r'field \(e\.g\. "name: myapp"\)\.'), | 29 r'field \(e\.g\. "name: myapp"\)\.'), |
| 32 exitCode: 1); | 30 exitCode: 1); |
| 33 | |
| 34 run(); | |
| 35 }); | 31 }); |
| 36 }); | 32 }); |
| 37 | 33 |
| 38 test('adds itself to the packages', () { | 34 integration('adds itself to the packages', () { |
| 39 // The symlink should use the name in the pubspec, not the name of the | 35 // The symlink should use the name in the pubspec, not the name of the |
| 40 // directory. | 36 // directory. |
| 41 dir(appPath, [ | 37 dir(appPath, [ |
| 42 pubspec({"name": "myapp_name"}), | 38 pubspec({"name": "myapp_name"}), |
| 43 libDir('myapp_name') | 39 libDir('myapp_name') |
| 44 ]).scheduleCreate(); | 40 ]).scheduleCreate(); |
| 45 | 41 |
| 46 schedulePub(args: ['update'], | 42 schedulePub(args: ['update'], |
| 47 output: new RegExp(r"Dependencies updated!$")); | 43 output: new RegExp(r"Dependencies updated!$")); |
| 48 | 44 |
| 49 dir(packagesPath, [ | 45 dir(packagesPath, [ |
| 50 dir("myapp_name", [ | 46 dir("myapp_name", [ |
| 51 file('myapp_name.dart', 'main() => "myapp_name";') | 47 file('myapp_name.dart', 'main() => "myapp_name";') |
| 52 ]) | 48 ]) |
| 53 ]).scheduleValidate(); | 49 ]).scheduleValidate(); |
| 54 | |
| 55 run(); | |
| 56 }); | 50 }); |
| 57 | 51 |
| 58 test('does not adds itself to the packages if it has no "lib" directory', () { | 52 integration('does not adds itself to the packages if it has no "lib" ' |
| 53 'directory', () { |
| 59 // The symlink should use the name in the pubspec, not the name of the | 54 // The symlink should use the name in the pubspec, not the name of the |
| 60 // directory. | 55 // directory. |
| 61 dir(appPath, [ | 56 dir(appPath, [ |
| 62 pubspec({"name": "myapp_name"}), | 57 pubspec({"name": "myapp_name"}), |
| 63 ]).scheduleCreate(); | 58 ]).scheduleCreate(); |
| 64 | 59 |
| 65 schedulePub(args: ['update'], | 60 schedulePub(args: ['update'], |
| 66 output: new RegExp(r"Dependencies updated!$")); | 61 output: new RegExp(r"Dependencies updated!$")); |
| 67 | 62 |
| 68 dir(packagesPath, [ | 63 dir(packagesPath, [ |
| 69 nothing("myapp_name") | 64 nothing("myapp_name") |
| 70 ]).scheduleValidate(); | 65 ]).scheduleValidate(); |
| 71 | |
| 72 run(); | |
| 73 }); | 66 }); |
| 74 | 67 |
| 75 test('does not add a package if it does not have a "lib" directory', () { | 68 integration('does not add a package if it does not have a "lib" ' |
| 69 'directory', () { |
| 76 // Using an SDK source, but this should be true of all sources. | 70 // Using an SDK source, but this should be true of all sources. |
| 77 dir(sdkPath, [ | 71 dir(sdkPath, [ |
| 78 file('revision', '1234'), | 72 file('revision', '1234'), |
| 79 dir('pkg', [ | 73 dir('pkg', [ |
| 80 dir('foo', [ | 74 dir('foo', [ |
| 81 libPubspec('foo', '0.0.0-not.used') | 75 libPubspec('foo', '0.0.0-not.used') |
| 82 ]) | 76 ]) |
| 83 ]) | 77 ]) |
| 84 ]).scheduleCreate(); | 78 ]).scheduleCreate(); |
| 85 | 79 |
| 86 dir(appPath, [ | 80 dir(appPath, [ |
| 87 pubspec({"name": "myapp", "dependencies": {"foo": {"sdk": "foo"}}}) | 81 pubspec({"name": "myapp", "dependencies": {"foo": {"sdk": "foo"}}}) |
| 88 ]).scheduleCreate(); | 82 ]).scheduleCreate(); |
| 89 | 83 |
| 90 schedulePub(args: ['update'], | 84 schedulePub(args: ['update'], |
| 91 output: new RegExp(r"Dependencies updated!$")); | 85 output: new RegExp(r"Dependencies updated!$")); |
| 92 | 86 |
| 93 packagesDir({"foo": null}).scheduleValidate(); | 87 packagesDir({"foo": null}).scheduleValidate(); |
| 94 | |
| 95 run(); | |
| 96 }); | 88 }); |
| 97 } | 89 } |
| OLD | NEW |