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