OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS d.file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS d.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 'package:scheduled_test/scheduled_stream.dart'; |
7 import 'package:scheduled_test/scheduled_test.dart'; | 8 import 'package:scheduled_test/scheduled_test.dart'; |
8 | 9 |
9 import '../descriptor.dart' as d; | 10 import '../descriptor.dart' as d; |
10 import '../test_pub.dart'; | 11 import '../test_pub.dart'; |
11 import '../serve/utils.dart'; | 12 import '../serve/utils.dart'; |
12 | 13 |
13 const REPLACE_FROM_LIBRARY_TRANSFORMER = """ | 14 const REPLACE_FROM_LIBRARY_TRANSFORMER = """ |
14 import 'dart:async'; | 15 import 'dart:async'; |
15 | 16 |
16 import 'package:barback/barback.dart'; | 17 import 'package:barback/barback.dart'; |
(...skipping 29 matching lines...) Expand all Loading... |
46 ]) | 47 ]) |
47 ]); | 48 ]); |
48 | 49 |
49 builder.serve("bar", "1.2.3", | 50 builder.serve("bar", "1.2.3", |
50 deps: {'barback': 'any'}, | 51 deps: {'barback': 'any'}, |
51 contents: [ | 52 contents: [ |
52 d.dir("lib", [ | 53 d.dir("lib", [ |
53 d.file("transformer.dart", replaceTransformer("Goodbye", "See ya")) | 54 d.file("transformer.dart", replaceTransformer("Goodbye", "See ya")) |
54 ]) | 55 ]) |
55 ]); | 56 ]); |
| 57 |
| 58 builder.serve("baz", "1.2.3"); |
56 }); | 59 }); |
57 | 60 |
58 d.dir(appPath, [ | 61 d.dir(appPath, [ |
59 d.pubspec({ | 62 d.pubspec({ |
60 "name": "myapp", | 63 "name": "myapp", |
61 "dependencies": { | 64 "dependencies": { |
62 "foo": "1.2.3", | 65 "foo": "1.2.3", |
63 "bar": "1.2.3" | 66 "bar": "1.2.3" |
64 }, | 67 }, |
65 "transformers": ["foo"] | 68 "transformers": ["foo"] |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 "transformers": ["foo"] | 262 "transformers": ["foo"] |
260 }) | 263 }) |
261 ]).create(); | 264 ]).create(); |
262 | 265 |
263 pubUpgrade(); | 266 pubUpgrade(); |
264 | 267 |
265 process = pubRun(args: ['myapp']); | 268 process = pubRun(args: ['myapp']); |
266 process.stdout.expect("See ya!"); | 269 process.stdout.expect("See ya!"); |
267 process.shouldExit(); | 270 process.shouldExit(); |
268 }); | 271 }); |
| 272 |
| 273 // Issue 21298. |
| 274 integration("doesn't recache when a transformer is removed", () { |
| 275 setUp(); |
| 276 |
| 277 d.dir(appPath, [ |
| 278 d.pubspec({ |
| 279 "name": "myapp", |
| 280 "dependencies": { |
| 281 "foo": "1.2.3", |
| 282 "bar": "1.2.3" |
| 283 }, |
| 284 "transformers": ["foo", "bar"] |
| 285 }), |
| 286 d.dir("bin", [ |
| 287 d.file("myapp.dart", "main() => print('Hello!');") |
| 288 ]) |
| 289 ]).create(); |
| 290 |
| 291 var process = pubRun(args: ['myapp']); |
| 292 process.stdout.expect("See ya!"); |
| 293 process.shouldExit(); |
| 294 |
| 295 d.dir(appPath, [ |
| 296 d.pubspec({ |
| 297 "name": "myapp", |
| 298 "dependencies": { |
| 299 "foo": "1.2.3", |
| 300 // Add a new dependency to trigger another "pub get". This works |
| 301 // around issue 20498. |
| 302 "baz": "1.2.3" |
| 303 }, |
| 304 "transformers": ["foo"] |
| 305 }), |
| 306 d.dir("bin", [ |
| 307 d.file("myapp.dart", "main() => print('Hello!');") |
| 308 ]) |
| 309 ]).create(); |
| 310 |
| 311 process = pubRun(args: ['myapp']); |
| 312 process.stdout.expect( |
| 313 "Your pubspec has changed, so we need to update your lockfile:"); |
| 314 process.stdout.expect(consumeThrough("Goodbye!")); |
| 315 process.shouldExit(); |
| 316 |
| 317 // "bar" should still be in the manifest, since there's no reason to |
| 318 // recompile the cache. |
| 319 d.dir(appPath, [ |
| 320 d.dir(".pub/transformers", [ |
| 321 d.file("manifest.txt", "0.1.2+3\nbar,foo"), |
| 322 d.matcherFile("transformers.snapshot", isNot(isEmpty)) |
| 323 ]) |
| 324 ]).validate(); |
| 325 }); |
269 } | 326 } |
270 | 327 |
271 String replaceTransformer(String input, String output) { | 328 String replaceTransformer(String input, String output) { |
272 return """ | 329 return """ |
273 import 'dart:async'; | 330 import 'dart:async'; |
274 | 331 |
275 import 'package:barback/barback.dart'; | 332 import 'package:barback/barback.dart'; |
276 | 333 |
277 class ReplaceTransformer extends Transformer { | 334 class ReplaceTransformer extends Transformer { |
278 ReplaceTransformer.asPlugin(); | 335 ReplaceTransformer.asPlugin(); |
279 | 336 |
280 String get allowedExtensions => '.dart'; | 337 String get allowedExtensions => '.dart'; |
281 | 338 |
282 Future apply(Transform transform) { | 339 Future apply(Transform transform) { |
283 return transform.primaryInput.readAsString().then((contents) { | 340 return transform.primaryInput.readAsString().then((contents) { |
284 transform.addOutput(new Asset.fromString( | 341 transform.addOutput(new Asset.fromString( |
285 transform.primaryInput.id, | 342 transform.primaryInput.id, |
286 contents.replaceAll("$input", "$output"))); | 343 contents.replaceAll("$input", "$output"))); |
287 }); | 344 }); |
288 } | 345 } |
289 } | 346 } |
290 """; | 347 """; |
291 } | 348 } |
OLD | NEW |