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_test.dart'; | 7 import 'package:scheduled_test/scheduled_test.dart'; |
8 | 8 |
9 import '../descriptor.dart' as d; | 9 import '../descriptor.dart' as d; |
10 import '../test_pub.dart'; | 10 import '../test_pub.dart'; |
11 import '../serve/utils.dart'; | 11 import '../serve/utils.dart'; |
12 | 12 |
13 const REJECT_CONFIG_TRANSFORMER = """ | 13 const REJECT_CONFIG_TRANSFORMER = """ |
14 import 'dart:async'; | 14 import 'dart:async'; |
15 | 15 |
16 import 'package:barback/barback.dart'; | 16 import 'package:barback/barback.dart'; |
17 | 17 |
18 class RejectConfigTransformer extends Transformer { | 18 class RejectConfigTransformer extends Transformer { |
19 RejectConfigTransformer.asPlugin(BarbackSettings settings) { | 19 RejectConfigTransformer.asPlugin(BarbackSettings settings) { |
20 throw "I hate these settings!"; | 20 throw "I hate these settings!"; |
21 } | 21 } |
22 | 22 |
23 Future<bool> isPrimary(_) => new Future.value(true); | 23 Future<bool> isPrimary(_) => new Future.value(true); |
24 Future apply(Transform transform) {} | 24 Future apply(Transform transform) {} |
25 } | 25 } |
26 """; | 26 """; |
27 | 27 |
28 main() { | 28 main() { |
29 withBarbackVersions("any", () { | 29 integration("a transformer can reject is configuration", () { |
30 integration("a transformer can reject is configuration", () { | 30 d.dir(appPath, [ |
31 d.dir(appPath, [ | 31 d.pubspec({ |
32 d.pubspec({ | 32 "name": "myapp", |
33 "name": "myapp", | 33 "transformers": [{"myapp/src/transformer": {'foo': 'bar'}}] |
34 "transformers": [{"myapp/src/transformer": {'foo': 'bar'}}] | 34 }), |
35 }), | 35 d.dir("lib", [d.dir("src", [ |
36 d.dir("lib", [d.dir("src", [ | 36 d.file("transformer.dart", REJECT_CONFIG_TRANSFORMER) |
37 d.file("transformer.dart", REJECT_CONFIG_TRANSFORMER) | 37 ])]) |
38 ])]) | 38 ]).create(); |
39 ]).create(); | |
40 | 39 |
41 createLockFile('myapp', pkg: ['barback']); | 40 createLockFile('myapp', pkg: ['barback']); |
42 | 41 |
43 var pub = startPubServe(); | 42 var pub = startPubServe(); |
44 pub.stderr.expect(endsWith('Error loading transformer: I hate these ' | 43 pub.stderr.expect(endsWith('Error loading transformer: I hate these ' |
45 'settings!')); | 44 'settings!')); |
46 pub.shouldExit(1); | 45 pub.shouldExit(1); |
47 }); | 46 }); |
48 }); | |
49 } | 47 } |
OLD | NEW |