| 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_stream.dart'; |
| 8 import 'package:scheduled_test/scheduled_test.dart'; | 8 import 'package:scheduled_test/scheduled_test.dart'; |
| 9 | 9 |
| 10 import '../descriptor.dart' as d; | 10 import '../descriptor.dart' as d; |
| 11 import '../test_pub.dart'; | 11 import '../test_pub.dart'; |
| 12 import '../serve/utils.dart'; | 12 import '../serve/utils.dart'; |
| 13 | 13 |
| 14 const REJECT_CONFIG_TRANSFORMER = """ | 14 const REJECT_CONFIG_TRANSFORMER = """ |
| 15 import 'dart:async'; | 15 import 'dart:async'; |
| 16 | 16 |
| 17 import 'package:barback/barback.dart'; | 17 import 'package:barback/barback.dart'; |
| 18 | 18 |
| 19 class RejectConfigTransformer extends Transformer { | 19 class RejectConfigTransformer extends Transformer { |
| 20 RejectConfigTransformer.asPlugin(BarbackSettings settings) { | 20 RejectConfigTransformer.asPlugin(BarbackSettings settings) { |
| 21 throw "I hate these settings!"; | 21 throw "I hate these settings!"; |
| 22 } | 22 } |
| 23 | 23 |
| 24 Future<bool> isPrimary(_) => new Future.value(true); | 24 Future<bool> isPrimary(_) => new Future.value(true); |
| 25 Future apply(Transform transform) {} | 25 Future apply(Transform transform) {} |
| 26 } | 26 } |
| 27 """; | 27 """; |
| 28 | 28 |
| 29 main() { | 29 main() { |
| 30 withBarbackVersions("any", () { | 30 integration("multiple transformers in the same phase reject their " |
| 31 integration("multiple transformers in the same phase reject their " | 31 "configurations", () { |
| 32 "configurations", () { | 32 d.dir(appPath, [ |
| 33 d.dir(appPath, [ | 33 d.pubspec({ |
| 34 d.pubspec({ | 34 "name": "myapp", |
| 35 "name": "myapp", | 35 "transformers": [[ |
| 36 "transformers": [[ | 36 {"myapp/src/transformer": {'foo': 'bar'}}, |
| 37 {"myapp/src/transformer": {'foo': 'bar'}}, | 37 {"myapp/src/transformer": {'baz': 'bang'}}, |
| 38 {"myapp/src/transformer": {'baz': 'bang'}}, | 38 {"myapp/src/transformer": {'qux': 'fblthp'}} |
| 39 {"myapp/src/transformer": {'qux': 'fblthp'}} | 39 ]] |
| 40 ]] | 40 }), |
| 41 }), | 41 d.dir("lib", [d.dir("src", [ |
| 42 d.dir("lib", [d.dir("src", [ | 42 d.file("transformer.dart", REJECT_CONFIG_TRANSFORMER) |
| 43 d.file("transformer.dart", REJECT_CONFIG_TRANSFORMER) | 43 ])]) |
| 44 ])]) | 44 ]).create(); |
| 45 ]).create(); | |
| 46 | 45 |
| 47 createLockFile('myapp', pkg: ['barback']); | 46 createLockFile('myapp', pkg: ['barback']); |
| 48 | 47 |
| 49 // We should see three instances of the error message, once for each | 48 // We should see three instances of the error message, once for each |
| 50 // use of the transformer. | 49 // use of the transformer. |
| 51 var pub = startPubServe(); | 50 var pub = startPubServe(); |
| 52 for (var i = 0; i < 3; i++) { | 51 for (var i = 0; i < 3; i++) { |
| 53 pub.stderr.expect(consumeThrough(endsWith('Error loading transformer: ' | 52 pub.stderr.expect(consumeThrough(endsWith('Error loading transformer: ' |
| 54 'I hate these settings!'))); | 53 'I hate these settings!'))); |
| 55 } | 54 } |
| 56 pub.shouldExit(1); | 55 pub.shouldExit(1); |
| 57 }); | 56 }); |
| 58 }); | |
| 59 } | 57 } |
| OLD | NEW |