Chromium Code Reviews| 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/unittest.dart'); | 10 #import('../../../pkg/unittest/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: ['install'], | 17 schedulePub(args: ['install'], |
| 18 error: const RegExp(@'^Could not find a file named "pubspec.yaml"'), | 18 error: const RegExp(r'^Could not find a file named "pubspec.yaml"'), |
|
nweiz
2012/09/26 00:49:52
This "." should be escaped.
Bob Nystrom
2012/09/26 01:14:42
Done.
| |
| 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: ['install'], | 29 schedulePub(args: ['install'], |
| 30 error: const RegExp(@'^pubspec.yaml is missing the required "name" ' | 30 error: const RegExp(r'^pubspec.yaml is missing the required "name" ' |
| 31 @'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('foo'), | 43 libDir('foo'), |
| 44 ]).scheduleCreate(); | 44 ]).scheduleCreate(); |
| 45 | 45 |
| 46 schedulePub(args: ['install'], | 46 schedulePub(args: ['install'], |
| 47 output: const RegExp(@"Dependencies installed!$")); | 47 output: const RegExp(r"Dependencies installed!$")); |
| 48 | 48 |
| 49 dir(packagesPath, [ | 49 dir(packagesPath, [ |
| 50 dir("myapp_name", [ | 50 dir("myapp_name", [ |
| 51 file('foo.dart', 'main() => "foo";') | 51 file('foo.dart', 'main() => "foo";') |
| 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: ['install'], | 65 schedulePub(args: ['install'], |
| 66 output: const RegExp(@"Dependencies installed!$")); | 66 output: const RegExp(r"Dependencies installed!$")); |
| 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: ['install'], | 90 schedulePub(args: ['install'], |
| 91 error: const RegExp(@'Warning: Package "foo" does not have a "lib" ' | 91 error: const RegExp(r'Warning: Package "foo" does not have a "lib" ' |
| 92 'directory.'), | 92 'directory.'), |
| 93 output: const RegExp(@"Dependencies installed!$")); | 93 output: const RegExp(r"Dependencies installed!$")); |
| 94 | 94 |
| 95 run(); | 95 run(); |
| 96 }); | 96 }); |
| 97 | 97 |
| 98 test('overwrites the existing packages directory', () { | 98 test('overwrites the existing packages directory', () { |
| 99 dir(appPath, [ | 99 dir(appPath, [ |
| 100 appPubspec([]), | 100 appPubspec([]), |
| 101 dir('packages', [ | 101 dir('packages', [ |
| 102 dir('foo'), | 102 dir('foo'), |
| 103 dir('myapp'), | 103 dir('myapp'), |
| 104 ]), | 104 ]), |
| 105 libDir('myapp') | 105 libDir('myapp') |
| 106 ]).scheduleCreate(); | 106 ]).scheduleCreate(); |
| 107 | 107 |
| 108 schedulePub(args: ['install'], | 108 schedulePub(args: ['install'], |
| 109 output: const RegExp(@"Dependencies installed!$")); | 109 output: const RegExp(r"Dependencies installed!$")); |
| 110 | 110 |
| 111 dir(packagesPath, [ | 111 dir(packagesPath, [ |
| 112 nothing('foo'), | 112 nothing('foo'), |
| 113 dir('myapp', [file('myapp.dart', 'main() => "myapp";')]) | 113 dir('myapp', [file('myapp.dart', 'main() => "myapp";')]) |
| 114 ]).scheduleValidate(); | 114 ]).scheduleValidate(); |
| 115 | 115 |
| 116 run(); | 116 run(); |
| 117 }); | 117 }); |
| 118 | 118 |
| 119 group('creates a packages directory in', () { | 119 group('creates a packages directory in', () { |
| 120 test('"test/" and its subdirectories', () { | 120 test('"test/" and its subdirectories', () { |
| 121 dir(appPath, [ | 121 dir(appPath, [ |
| 122 appPubspec([]), | 122 appPubspec([]), |
| 123 libDir('foo'), | 123 libDir('foo'), |
| 124 dir("test", [dir("subtest")]) | 124 dir("test", [dir("subtest")]) |
| 125 ]).scheduleCreate(); | 125 ]).scheduleCreate(); |
| 126 | 126 |
| 127 schedulePub(args: ['install'], | 127 schedulePub(args: ['install'], |
| 128 output: const RegExp(@"Dependencies installed!$")); | 128 output: const RegExp(r"Dependencies installed!$")); |
| 129 | 129 |
| 130 dir(appPath, [ | 130 dir(appPath, [ |
| 131 dir("test", [ | 131 dir("test", [ |
| 132 dir("packages", [ | 132 dir("packages", [ |
| 133 dir("myapp", [ | 133 dir("myapp", [ |
| 134 file('foo.dart', 'main() => "foo";') | 134 file('foo.dart', 'main() => "foo";') |
| 135 ]) | 135 ]) |
| 136 ]), | 136 ]), |
| 137 dir("subtest", [ | 137 dir("subtest", [ |
| 138 dir("packages", [ | 138 dir("packages", [ |
| 139 dir("myapp", [ | 139 dir("myapp", [ |
| 140 file('foo.dart', 'main() => "foo";') | 140 file('foo.dart', 'main() => "foo";') |
| 141 ]) | 141 ]) |
| 142 ]) | 142 ]) |
| 143 ]) | 143 ]) |
| 144 ]) | 144 ]) |
| 145 ]).scheduleValidate(); | 145 ]).scheduleValidate(); |
| 146 | 146 |
| 147 run(); | 147 run(); |
| 148 }); | 148 }); |
| 149 | 149 |
| 150 test('"example/" and its subdirectories', () { | 150 test('"example/" and its subdirectories', () { |
| 151 dir(appPath, [ | 151 dir(appPath, [ |
| 152 appPubspec([]), | 152 appPubspec([]), |
| 153 libDir('foo'), | 153 libDir('foo'), |
| 154 dir("example", [dir("subexample")]) | 154 dir("example", [dir("subexample")]) |
| 155 ]).scheduleCreate(); | 155 ]).scheduleCreate(); |
| 156 | 156 |
| 157 schedulePub(args: ['install'], | 157 schedulePub(args: ['install'], |
| 158 output: const RegExp(@"Dependencies installed!$")); | 158 output: const RegExp(r"Dependencies installed!$")); |
| 159 | 159 |
| 160 dir(appPath, [ | 160 dir(appPath, [ |
| 161 dir("example", [ | 161 dir("example", [ |
| 162 dir("packages", [ | 162 dir("packages", [ |
| 163 dir("myapp", [ | 163 dir("myapp", [ |
| 164 file('foo.dart', 'main() => "foo";') | 164 file('foo.dart', 'main() => "foo";') |
| 165 ]) | 165 ]) |
| 166 ]), | 166 ]), |
| 167 dir("subexample", [ | 167 dir("subexample", [ |
| 168 dir("packages", [ | 168 dir("packages", [ |
| 169 dir("myapp", [ | 169 dir("myapp", [ |
| 170 file('foo.dart', 'main() => "foo";') | 170 file('foo.dart', 'main() => "foo";') |
| 171 ]) | 171 ]) |
| 172 ]) | 172 ]) |
| 173 ]) | 173 ]) |
| 174 ]) | 174 ]) |
| 175 ]).scheduleValidate(); | 175 ]).scheduleValidate(); |
| 176 | 176 |
| 177 run(); | 177 run(); |
| 178 }); | 178 }); |
| 179 | 179 |
| 180 test('"web/" and its subdirectories', () { | 180 test('"web/" and its subdirectories', () { |
| 181 dir(appPath, [ | 181 dir(appPath, [ |
| 182 appPubspec([]), | 182 appPubspec([]), |
| 183 libDir('foo'), | 183 libDir('foo'), |
| 184 dir("web", [dir("subweb")]) | 184 dir("web", [dir("subweb")]) |
| 185 ]).scheduleCreate(); | 185 ]).scheduleCreate(); |
| 186 | 186 |
| 187 schedulePub(args: ['install'], | 187 schedulePub(args: ['install'], |
| 188 output: const RegExp(@"Dependencies installed!$")); | 188 output: const RegExp(r"Dependencies installed!$")); |
| 189 | 189 |
| 190 dir(appPath, [ | 190 dir(appPath, [ |
| 191 dir("web", [ | 191 dir("web", [ |
| 192 dir("packages", [ | 192 dir("packages", [ |
| 193 dir("myapp", [ | 193 dir("myapp", [ |
| 194 file('foo.dart', 'main() => "foo";') | 194 file('foo.dart', 'main() => "foo";') |
| 195 ]) | 195 ]) |
| 196 ]), | 196 ]), |
| 197 dir("subweb", [ | 197 dir("subweb", [ |
| 198 dir("packages", [ | 198 dir("packages", [ |
| 199 dir("myapp", [ | 199 dir("myapp", [ |
| 200 file('foo.dart', 'main() => "foo";') | 200 file('foo.dart', 'main() => "foo";') |
| 201 ]) | 201 ]) |
| 202 ]) | 202 ]) |
| 203 ]) | 203 ]) |
| 204 ]) | 204 ]) |
| 205 ]).scheduleValidate(); | 205 ]).scheduleValidate(); |
| 206 | 206 |
| 207 run(); | 207 run(); |
| 208 }); | 208 }); |
| 209 | 209 |
| 210 test('"bin/"', () { | 210 test('"bin/"', () { |
| 211 dir(appPath, [ | 211 dir(appPath, [ |
| 212 appPubspec([]), | 212 appPubspec([]), |
| 213 libDir('foo'), | 213 libDir('foo'), |
| 214 dir("bin") | 214 dir("bin") |
| 215 ]).scheduleCreate(); | 215 ]).scheduleCreate(); |
| 216 | 216 |
| 217 schedulePub(args: ['install'], | 217 schedulePub(args: ['install'], |
| 218 output: const RegExp(@"Dependencies installed!$")); | 218 output: const RegExp(r"Dependencies installed!$")); |
| 219 | 219 |
| 220 dir(appPath, [ | 220 dir(appPath, [ |
| 221 dir("bin", [ | 221 dir("bin", [ |
| 222 dir("packages", [ | 222 dir("packages", [ |
| 223 dir("myapp", [ | 223 dir("myapp", [ |
| 224 file('foo.dart', 'main() => "foo";') | 224 file('foo.dart', 'main() => "foo";') |
| 225 ]) | 225 ]) |
| 226 ]) | 226 ]) |
| 227 ]) | 227 ]) |
| 228 ]).scheduleValidate(); | 228 ]).scheduleValidate(); |
| 229 | 229 |
| 230 run(); | 230 run(); |
| 231 }); | 231 }); |
| 232 }); | 232 }); |
| 233 | 233 |
| 234 // TODO(rnystrom): Remove this when old layout support is removed. (#4964) | 234 // TODO(rnystrom): Remove this when old layout support is removed. (#4964) |
| 235 test('shows a warning if the entrypoint uses the old layout', () { | 235 test('shows a warning if the entrypoint uses the old layout', () { |
| 236 // The symlink should use the name in the pubspec, not the name of the | 236 // The symlink should use the name in the pubspec, not the name of the |
| 237 // directory. | 237 // directory. |
| 238 dir(appPath, [ | 238 dir(appPath, [ |
| 239 pubspec({"name": "myapp_name"}), | 239 pubspec({"name": "myapp_name"}), |
| 240 file("foo.dart", 'main() => "foo";'), | 240 file("foo.dart", 'main() => "foo";'), |
| 241 ]).scheduleCreate(); | 241 ]).scheduleCreate(); |
| 242 | 242 |
| 243 schedulePub(args: ['install'], | 243 schedulePub(args: ['install'], |
| 244 error: ''' | 244 error: ''' |
| 245 Warning: Package "myapp_name" is using a deprecated layout. | 245 Warning: Package "myapp_name" is using a deprecated layout. |
| 246 See http://www.dartlang.org/docs/pub-package-manager/package-layout.html for details. | 246 See http://www.dartlang.org/docs/pub-package-manager/package-layout.html for details. |
| 247 ''', | 247 ''', |
| 248 output: const RegExp(@"Dependencies installed!$")); | 248 output: const RegExp(r"Dependencies installed!$")); |
| 249 | 249 |
| 250 run(); | 250 run(); |
| 251 }); | 251 }); |
| 252 } | 252 } |
| OLD | NEW |