OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library barback.test.transformer.bad_log; | 5 library barback.test.transformer.bad_log; |
6 | 6 |
| 7 import 'dart:async'; |
| 8 |
7 import 'package:barback/barback.dart'; | 9 import 'package:barback/barback.dart'; |
| 10 import 'package:barback/src/utils.dart'; |
8 | 11 |
9 import 'mock.dart'; | 12 import 'mock.dart'; |
10 | 13 |
11 /// A transformer that logs an error when run, Before generating the given | 14 /// A transformer that logs an error when run, Before generating the given |
12 /// outputs. | 15 /// outputs. |
13 class BadLogTransformer extends MockTransformer { | 16 class BadLogTransformer extends MockTransformer { |
14 /// The list of asset names that it should output. | 17 /// The list of asset names that it should output. |
15 final List<String> outputs; | 18 final List<String> outputs; |
16 | 19 |
17 BadLogTransformer(this.outputs); | 20 BadLogTransformer(this.outputs); |
18 | 21 |
19 bool doIsPrimary(AssetId id) => true; | 22 Future<bool> doIsPrimary(AssetId id) => new Future.value(true); |
20 | 23 |
21 void doApply(Transform transform) { | 24 Future doApply(Transform transform) { |
22 transform.logger.error("first error"); | 25 return newFuture(() { |
23 transform.logger.error("second error"); | 26 transform.logger.error("first error"); |
| 27 transform.logger.error("second error"); |
24 | 28 |
25 for (var output in outputs) { | 29 for (var output in outputs) { |
26 var id = new AssetId.parse(output); | 30 var id = new AssetId.parse(output); |
27 transform.addOutput(new Asset.fromString(id, output)); | 31 transform.addOutput(new Asset.fromString(id, output)); |
28 } | 32 } |
| 33 }); |
29 } | 34 } |
30 } | 35 } |
OLD | NEW |