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