OLD | NEW |
| (Empty) |
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; | |
6 | |
7 import '../descriptor.dart' as d; | |
8 import '../test_pub.dart'; | |
9 import '../serve/utils.dart'; | |
10 | |
11 const WRONG_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 transform.primaryInput.readAsString().then((contents) { | |
23 var id = transform.primaryInput.id.changeExtension(".wrong"); | |
24 transform.addOutput(new Asset.fromString(id, "\$contents.wrong")); | |
25 }); | |
26 } | |
27 } | |
28 """; | |
29 | |
30 main() { | |
31 initConfig(); | |
32 withBarbackVersions("any", () { | |
33 integration("prefers transformer.dart to <package name>.dart", () { | |
34 d.dir(appPath, [d.pubspec({ | |
35 "name": "myapp", | |
36 "transformers": ["myapp"] | |
37 }), | |
38 d.dir( | |
39 "lib", | |
40 [ | |
41 d.file("transformer.dart", REWRITE_TRANSFORMER), | |
42 d.file("myapp.dart", WRONG_TRANSFORMER)]), | |
43 d.dir("web", [d.file("foo.txt", "foo")])]).create(); | |
44 | |
45 createLockFile('myapp', pkg: ['barback']); | |
46 | |
47 pubServe(); | |
48 requestShouldSucceed("foo.out", "foo.out"); | |
49 requestShould404("foo.wrong"); | |
50 endPubServe(); | |
51 }); | |
52 }); | |
53 } | |
OLD | NEW |