OLD | NEW |
| (Empty) |
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 | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 | |
5 library pub_tests; | |
6 | |
7 import '../descriptor.dart' as d; | |
8 import '../test_pub.dart'; | |
9 import '../serve/utils.dart'; | |
10 | |
11 const TRANSFORMER = """ | |
12 import 'dart:async'; | |
13 | |
14 import 'package:barback/barback.dart'; | |
15 | |
16 class RewriteTransformer extends Transformer { | |
17 RewriteTransformer.asPlugin(); | |
18 | |
19 String get allowedExtensions => '.txt'; | |
20 | |
21 Future apply(Transform transform) { | |
22 return Future.wait([ | |
23 transform.hasInput(transform.primaryInput.id), | |
24 transform.hasInput(new AssetId('hooble', 'whatsit')) | |
25 ]).then((results) { | |
26 var id = transform.primaryInput.id.changeExtension(".out"); | |
27 var asset = new Asset.fromString(id, | |
28 "primary: \${results[0]}, secondary: \${results[1]}"); | |
29 transform.addOutput(asset); | |
30 }); | |
31 } | |
32 } | |
33 """; | |
34 | |
35 main() { | |
36 initConfig(); | |
37 withBarbackVersions("any", () { | |
38 integration("a transform can use hasInput", () { | |
39 d.dir(appPath, [d.pubspec({ | |
40 "name": "myapp", | |
41 "transformers": ["myapp/src/transformer"] | |
42 }), | |
43 d.dir("lib", [d.dir("src", [d.file("transformer.dart", TRANSFORMER)]
)]), | |
44 d.dir("web", [d.file("foo.txt", "foo")])]).create(); | |
45 | |
46 createLockFile('myapp', pkg: ['barback']); | |
47 | |
48 pubServe(); | |
49 requestShouldSucceed("foo.out", "primary: true, secondary: false"); | |
50 endPubServe(); | |
51 }); | |
52 }); | |
53 } | |
OLD | NEW |