Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update transformer-test dep #14

Merged
merged 1 commit into from
Jan 28, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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