From 57d2b01da4d786e8fdb8a762496f42854ca5494c Mon Sep 17 00:00:00 2001 From: Jacob MacDonald Date: Thu, 28 Jan 2016 12:39:49 -0800 Subject: [PATCH] update transformer-test dep --- lib/src/transformer/transformer.dart | 12 +++++++++- pubspec.yaml | 2 +- test/transformer/transformer_test.dart | 31 +++++++++++--------------- 3 files changed, 25 insertions(+), 20 deletions(-) diff --git a/lib/src/transformer/transformer.dart b/lib/src/transformer/transformer.dart index a164ce8c9..fe17855ff 100644 --- a/lib/src/transformer/transformer.dart +++ b/lib/src/transformer/transformer.dart @@ -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. /// @@ -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]. diff --git a/pubspec.yaml b/pubspec.yaml index ab1db3efd..02da3b3bc 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -16,4 +16,4 @@ dependencies: dev_dependencies: test: ^0.12.0 - transformer_test: ^0.1.0 + transformer_test: ^0.2.0 diff --git a/test/transformer/transformer_test.dart b/test/transformer/transformer_test.dart index 079ae1e0a..1fde8cbdc 100644 --- a/test/transformer/transformer_test.dart +++ b/test/transformer/transformer_test.dart @@ -48,7 +48,7 @@ main() { ], ], { 'a|web/a.txt': 'hello', - }, {}, [ + }, {}, messages: [ _fileExistsError('CopyBuilder', ['a|web/a.txt.copy']), ]); @@ -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], @@ -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 files) {