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 '../descriptor.dart' as d; | 2 import '../descriptor.dart' as d; |
8 import '../test_pub.dart'; | 3 import '../test_pub.dart'; |
9 import '../serve/utils.dart'; | 4 import '../serve/utils.dart'; |
10 | |
11 const WRONG_TRANSFORMER = """ | 5 const WRONG_TRANSFORMER = """ |
12 import 'dart:async'; | 6 import 'dart:async'; |
13 | 7 |
14 import 'package:barback/barback.dart'; | 8 import 'package:barback/barback.dart'; |
15 | 9 |
16 class RewriteTransformer extends Transformer { | 10 class RewriteTransformer extends Transformer { |
17 RewriteTransformer.asPlugin(); | 11 RewriteTransformer.asPlugin(); |
18 | 12 |
19 String get allowedExtensions => '.txt'; | 13 String get allowedExtensions => '.txt'; |
20 | 14 |
21 Future apply(Transform transform) { | 15 Future apply(Transform transform) { |
22 return transform.primaryInput.readAsString().then((contents) { | 16 return transform.primaryInput.readAsString().then((contents) { |
23 var id = transform.primaryInput.id.changeExtension(".wrong"); | 17 var id = transform.primaryInput.id.changeExtension(".wrong"); |
24 transform.addOutput(new Asset.fromString(id, "\$contents.wrong")); | 18 transform.addOutput(new Asset.fromString(id, "\$contents.wrong")); |
25 }); | 19 }); |
26 } | 20 } |
27 } | 21 } |
28 """; | 22 """; |
29 | |
30 main() { | 23 main() { |
31 initConfig(); | 24 initConfig(); |
32 withBarbackVersions("any", () { | 25 withBarbackVersions("any", () { |
33 integration("prefers transformer.dart to <package name>.dart", () { | 26 integration("prefers transformer.dart to <package name>.dart", () { |
34 d.dir(appPath, [ | 27 d.dir(appPath, [d.pubspec({ |
35 d.pubspec({ | |
36 "name": "myapp", | 28 "name": "myapp", |
37 "transformers": ["myapp"] | 29 "transformers": ["myapp"] |
38 }), | 30 }), |
39 d.dir("lib", [ | 31 d.dir( |
40 d.file("transformer.dart", REWRITE_TRANSFORMER), | 32 "lib", |
41 d.file("myapp.dart", WRONG_TRANSFORMER) | 33 [ |
42 ]), | 34 d.file("transformer.dart", REWRITE_TRANSFORMER), |
43 d.dir("web", [ | 35 d.file("myapp.dart", WRONG_TRANSFORMER)]), |
44 d.file("foo.txt", "foo") | 36 d.dir("web", [d.file("foo.txt", "foo")])]).create(); |
45 ]) | |
46 ]).create(); | |
47 | |
48 createLockFile('myapp', pkg: ['barback']); | 37 createLockFile('myapp', pkg: ['barback']); |
49 | |
50 pubServe(); | 38 pubServe(); |
51 requestShouldSucceed("foo.out", "foo.out"); | 39 requestShouldSucceed("foo.out", "foo.out"); |
52 requestShould404("foo.wrong"); | 40 requestShould404("foo.wrong"); |
53 endPubServe(); | 41 endPubServe(); |
54 }); | 42 }); |
55 }); | 43 }); |
56 } | 44 } |
OLD | NEW |