Skip to content

Commit 57d2b01

Browse files
committed
update transformer-test dep
1 parent 6f59037 commit 57d2b01

File tree

3 files changed

+25
-20
lines changed

3 files changed

+25
-20
lines changed

lib/src/transformer/transformer.dart

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ import '../builder/build_step_impl.dart';
1717
/// A [Transformer] which runs multiple [Builder]s.
1818
/// Extend this class and define the [builders] getter to create a [Transformer]
1919
/// out of your custom [Builder]s.
20-
abstract class BuilderTransformer implements Transformer {
20+
///
21+
/// By default all [BuilderTransformer]s are [DeclaringTransformer]s. If you
22+
/// wish to run as a [LazyTransformer], simply mix that into your class as well.
23+
abstract class BuilderTransformer implements Transformer, DeclaringTransformer {
2124
/// The only thing you need to implement when extending this class. This
2225
/// declares which builders should be ran.
2326
///
@@ -71,6 +74,13 @@ abstract class BuilderTransformer implements Transformer {
7174
await buildStep.outputsCompleted;
7275
}));
7376
}
77+
78+
@override
79+
void declareOutputs(DeclaringTransform transform) {
80+
for (var outputId in _expectedOutputs(transform.primaryId, builders)) {
81+
transform.declareOutput(_toBarbackAssetId(outputId));
82+
}
83+
}
7484
}
7585

7686
/// Very simple [AssetReader] which uses a [Transform].

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ dependencies:
1616

1717
dev_dependencies:
1818
test: ^0.12.0
19-
transformer_test: ^0.1.0
19+
transformer_test: ^0.2.0

test/transformer/transformer_test.dart

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ main() {
4848
],
4949
], {
5050
'a|web/a.txt': 'hello',
51-
}, {}, [
51+
}, {}, messages: [
5252
_fileExistsError('CopyBuilder', ['a|web/a.txt.copy']),
5353
]);
5454

@@ -80,23 +80,18 @@ main() {
8080
], {
8181
'a|web/a.txt': 'hello',
8282
'a|web/a.txt.copy': 'hello',
83-
}, {}, [
83+
}, {}, messages: [
8484
_fileExistsError("CopyBuilder", ["a|web/a.txt.copy"]),
85-
]);
85+
], expectBarbackErrors: true);
8686

87-
// TODO(jakemac): Skipped because we can't detect this situation today.
88-
// Instead you get a barback error, see
89-
// https://github.com/dart-lang/transformer_test/issues/2
90-
//
91-
// testPhases('builders in the same phase can\'t output the same file', [
92-
// [singleCopyTransformer, new GenericBuilderTransformer([new CopyBuilder()])]
93-
// ], {
94-
// 'a|web/a.txt': 'hello',
95-
// }, {
96-
// 'a|web/a.txt.copy': 'hello',
97-
// }, [
98-
// _fileExistsError("CopyBuilder", ["a|web/a.txt.copy"]),
99-
// ]);
87+
// Gives a barback error only, we can't detect this situation.
88+
testPhases('builders in the same phase can\'t output the same file', [
89+
[singleCopyTransformer, new GenericBuilderTransformer([new CopyBuilder()])]
90+
], {
91+
'a|web/a.txt': 'hello',
92+
}, {
93+
'a|web/a.txt.copy': 'hello',
94+
}, expectBarbackErrors: true);
10095

10196
testPhases('builders in separate phases can\'t output the same file', [
10297
[singleCopyTransformer],
@@ -105,9 +100,9 @@ main() {
105100
'a|web/a.txt': 'hello',
106101
}, {
107102
'a|web/a.txt.copy': 'hello',
108-
}, [
103+
}, messages: [
109104
_fileExistsError("CopyBuilder", ["a|web/a.txt.copy"]),
110-
]);
105+
], expectBarbackErrors: true);
111106
}
112107

113108
String _fileExistsError(String builder, List<String> files) {

0 commit comments

Comments
 (0)