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