OLD | NEW |
1 // Copyright (c) 2013, 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 | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 | |
5 library pub_tests; | 1 library pub_tests; |
6 | |
7 import 'dart:convert'; | 2 import 'dart:convert'; |
8 | |
9 import '../../descriptor.dart' as d; | 3 import '../../descriptor.dart' as d; |
10 import '../../test_pub.dart'; | 4 import '../../test_pub.dart'; |
11 import '../../serve/utils.dart'; | 5 import '../../serve/utils.dart'; |
12 | |
13 final transformer = """ | 6 final transformer = """ |
14 import 'dart:async'; | 7 import 'dart:async'; |
15 import 'dart:convert'; | 8 import 'dart:convert'; |
16 | 9 |
17 import 'package:barback/barback.dart'; | 10 import 'package:barback/barback.dart'; |
18 | 11 |
19 class ConfigTransformer extends Transformer { | 12 class ConfigTransformer extends Transformer { |
20 final BarbackSettings settings; | 13 final BarbackSettings settings; |
21 | 14 |
22 ConfigTransformer.asPlugin(this.settings); | 15 ConfigTransformer.asPlugin(this.settings); |
(...skipping 15 matching lines...) Expand all Loading... |
38 String get allowedExtensions => '.txt'; | 31 String get allowedExtensions => '.txt'; |
39 | 32 |
40 Future apply(Transform transform) { | 33 Future apply(Transform transform) { |
41 return transform.primaryInput.readAsString().then((contents) { | 34 return transform.primaryInput.readAsString().then((contents) { |
42 var id = transform.primaryInput.id.changeExtension(".out"); | 35 var id = transform.primaryInput.id.changeExtension(".out"); |
43 transform.addOutput(new Asset.fromString(id, "\$contents.out")); | 36 transform.addOutput(new Asset.fromString(id, "\$contents.out")); |
44 }); | 37 }); |
45 } | 38 } |
46 } | 39 } |
47 """; | 40 """; |
48 | |
49 main() { | 41 main() { |
50 initConfig(); | 42 initConfig(); |
51 withBarbackVersions("any", () { | 43 withBarbackVersions("any", () { |
52 integration("with configuration, only instantiates configurable " | 44 integration( |
53 "transformers", () { | 45 "with configuration, only instantiates configurable " "transformers", |
54 var configuration = {"param": ["list", "of", "values"]}; | 46 () { |
55 | 47 var configuration = { |
56 d.dir(appPath, [ | 48 "param": ["list", "of", "values"] |
57 d.pubspec({ | 49 }; |
58 "name": "myapp", | 50 d.dir(appPath, [d.pubspec({ |
59 "transformers": [{"myapp/src/transformer": configuration}] | 51 "name": "myapp", |
60 }), | 52 "transformers": [{ |
61 d.dir("lib", [d.dir("src", [ | 53 "myapp/src/transformer": configuration |
62 d.file("transformer.dart", transformer) | 54 }] |
63 ])]), | 55 }), |
64 d.dir("web", [ | 56 d.dir("lib", [d.dir("src", [d.file("transformer.dart", transformer)]
)]), |
65 d.file("foo.txt", "foo") | 57 d.dir("web", [d.file("foo.txt", "foo")])]).create(); |
66 ]) | 58 createLockFile('myapp', pkg: ['barback']); |
67 ]).create(); | 59 var server = pubServe(); |
68 | 60 requestShouldSucceed("foo.json", JSON.encode(configuration)); |
69 createLockFile('myapp', pkg: ['barback']); | 61 requestShould404("foo.out"); |
70 | 62 endPubServe(); |
71 var server = pubServe(); | 63 }); |
72 requestShouldSucceed("foo.json", JSON.encode(configuration)); | |
73 requestShould404("foo.out"); | |
74 endPubServe(); | |
75 }); | |
76 }); | 64 }); |
77 } | 65 } |
OLD | NEW |