Skip to content

Commit

Permalink
update transformer-test dep
Browse files Browse the repository at this point in the history
  • Loading branch information
jakemac53 committed Jan 28, 2016
1 parent 6f59037 commit 57d2b01
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 20 deletions.
12 changes: 11 additions & 1 deletion lib/src/transformer/transformer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ import '../builder/build_step_impl.dart';
/// A [Transformer] which runs multiple [Builder]s.
/// Extend this class and define the [builders] getter to create a [Transformer]
/// out of your custom [Builder]s.
abstract class BuilderTransformer implements Transformer {
///
/// By default all [BuilderTransformer]s are [DeclaringTransformer]s. If you
/// wish to run as a [LazyTransformer], simply mix that into your class as well.
abstract class BuilderTransformer implements Transformer, DeclaringTransformer {
/// The only thing you need to implement when extending this class. This
/// declares which builders should be ran.
///
Expand Down Expand Up @@ -71,6 +74,13 @@ abstract class BuilderTransformer implements Transformer {
await buildStep.outputsCompleted;
}));
}

@override
void declareOutputs(DeclaringTransform transform) {
for (var outputId in _expectedOutputs(transform.primaryId, builders)) {
transform.declareOutput(_toBarbackAssetId(outputId));
}
}
}

/// Very simple [AssetReader] which uses a [Transform].
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ dependencies:

dev_dependencies:
test: ^0.12.0
transformer_test: ^0.1.0
transformer_test: ^0.2.0
31 changes: 13 additions & 18 deletions test/transformer/transformer_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ main() {
],
], {
'a|web/a.txt': 'hello',
}, {}, [
}, {}, messages: [
_fileExistsError('CopyBuilder', ['a|web/a.txt.copy']),
]);

Expand Down Expand Up @@ -80,23 +80,18 @@ main() {
], {
'a|web/a.txt': 'hello',
'a|web/a.txt.copy': 'hello',
}, {}, [
}, {}, messages: [
_fileExistsError("CopyBuilder", ["a|web/a.txt.copy"]),
]);
], expectBarbackErrors: true);

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

testPhases('builders in separate phases can\'t output the same file', [
[singleCopyTransformer],
Expand All @@ -105,9 +100,9 @@ main() {
'a|web/a.txt': 'hello',
}, {
'a|web/a.txt.copy': 'hello',
}, [
}, messages: [
_fileExistsError("CopyBuilder", ["a|web/a.txt.copy"]),
]);
], expectBarbackErrors: true);
}

String _fileExistsError(String builder, List<String> files) {
Expand Down

0 comments on commit 57d2b01

Please sign in to comment.