OLD | NEW |
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; | 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 AGGREGATE_TRANSFORMER = """ | 5 const AGGREGATE_TRANSFORMER = """ |
12 import 'dart:async'; | 6 import 'dart:async'; |
13 | 7 |
14 import 'package:barback/barback.dart'; | 8 import 'package:barback/barback.dart'; |
15 import 'package:path/path.dart' as p; | 9 import 'package:path/path.dart' as p; |
16 | 10 |
17 class ManyToOneTransformer extends AggregateTransformer | 11 class ManyToOneTransformer extends AggregateTransformer |
18 implements LazyAggregateTransformer { | 12 implements LazyAggregateTransformer { |
19 ManyToOneTransformer.asPlugin(); | 13 ManyToOneTransformer.asPlugin(); |
20 | 14 |
(...skipping 12 matching lines...) Expand all Loading... |
33 transform.addOutput(new Asset.fromString(id, contents.join('\\n'))); | 27 transform.addOutput(new Asset.fromString(id, contents.join('\\n'))); |
34 }); | 28 }); |
35 } | 29 } |
36 | 30 |
37 void declareOutputs(DeclaringAggregateTransform transform) { | 31 void declareOutputs(DeclaringAggregateTransform transform) { |
38 transform.declareOutput(new AssetId(transform.package, | 32 transform.declareOutput(new AssetId(transform.package, |
39 p.url.join(transform.key, 'out.txt'))); | 33 p.url.join(transform.key, 'out.txt'))); |
40 } | 34 } |
41 } | 35 } |
42 """; | 36 """; |
43 | |
44 main() { | 37 main() { |
45 initConfig(); | 38 initConfig(); |
46 withBarbackVersions(">=0.14.1", () { | 39 withBarbackVersions(">=0.14.1", () { |
47 integration("loads a lazy aggregate transformer", () { | 40 integration("loads a lazy aggregate transformer", () { |
48 d.dir(appPath, [ | 41 d.dir(appPath, [d.pubspec({ |
49 d.pubspec({ | |
50 "name": "myapp", | 42 "name": "myapp", |
51 "transformers": ["myapp"] | 43 "transformers": ["myapp"] |
52 }), | 44 }), |
53 d.dir("lib", [ | 45 d.dir("lib", [d.file("transformer.dart", AGGREGATE_TRANSFORMER)]), |
54 d.file("transformer.dart", AGGREGATE_TRANSFORMER), | 46 d.dir("web", [d.file("foo.txt", "foo"), d.file("bar.txt", "bar")])])
.create(); |
55 ]), | |
56 d.dir("web", [ | |
57 d.file("foo.txt", "foo"), | |
58 d.file("bar.txt", "bar") | |
59 ]) | |
60 ]).create(); | |
61 | |
62 createLockFile('myapp', pkg: ['barback']); | 47 createLockFile('myapp', pkg: ['barback']); |
63 | |
64 var server = pubServe(); | 48 var server = pubServe(); |
65 // The transformer should preserve laziness. | |
66 server.stdout.expect("Build completed successfully"); | 49 server.stdout.expect("Build completed successfully"); |
67 | |
68 requestShouldSucceed("out.txt", "bar\nfoo"); | 50 requestShouldSucceed("out.txt", "bar\nfoo"); |
69 endPubServe(); | 51 endPubServe(); |
70 }); | 52 }); |
71 }); | 53 }); |
72 } | 54 } |
OLD | NEW |