Index: sdk/lib/_internal/pub/test/serve/supports_user_defined_lazy_transformers_test.dart |
diff --git a/sdk/lib/_internal/pub/test/transformer/can_use_consume_primary_test.dart b/sdk/lib/_internal/pub/test/serve/supports_user_defined_lazy_transformers_test.dart |
similarity index 57% |
copy from sdk/lib/_internal/pub/test/transformer/can_use_consume_primary_test.dart |
copy to sdk/lib/_internal/pub/test/serve/supports_user_defined_lazy_transformers_test.dart |
index 9b41b2bbc5905412e31e2c3d02224973d5b1ff64..fd88315bda6f89e7040bed937432f84bfa8565db 100644 |
--- a/sdk/lib/_internal/pub/test/transformer/can_use_consume_primary_test.dart |
+++ b/sdk/lib/_internal/pub/test/serve/supports_user_defined_lazy_transformers_test.dart |
@@ -6,32 +6,36 @@ library pub_tests; |
import '../descriptor.dart' as d; |
import '../test_pub.dart'; |
-import '../serve/utils.dart'; |
+import 'utils.dart'; |
const TRANSFORMER = """ |
import 'dart:async'; |
import 'package:barback/barback.dart'; |
-class RewriteTransformer extends Transformer { |
- RewriteTransformer.asPlugin(); |
+class LazyRewriteTransformer extends Transformer implements LazyTransformer { |
+ LazyRewriteTransformer.asPlugin(); |
String get allowedExtensions => '.txt'; |
Future apply(Transform transform) { |
- transform.consumePrimary(); |
+ transform.logger.info('Rewriting \${transform.primaryInput.id}.'); |
return transform.primaryInput.readAsString().then((contents) { |
var id = transform.primaryInput.id.changeExtension(".out"); |
- var asset = new Asset.fromString(id, "\$contents.out"); |
- transform.addOutput(asset); |
+ transform.addOutput(new Asset.fromString(id, "\$contents.out")); |
}); |
} |
+ |
+ Future declareOutputs(DeclaringTransform transform) { |
+ transform.declareOutput(transform.primaryId.changeExtension(".out")); |
+ return new Future.value(); |
+ } |
} |
"""; |
main() { |
initConfig(); |
- integration("a transform can use consumePrimary", () { |
+ integration("supports a user-defined lazy transformer", () { |
d.dir(appPath, [ |
d.pubspec({ |
"name": "myapp", |
@@ -47,9 +51,14 @@ main() { |
createLockFile('myapp', pkg: ['barback']); |
- pubServe(); |
+ var server = pubServe(); |
+ // The build should complete without the transformer logging anything. |
+ server.stdout.expect('Build completed successfully'); |
+ |
requestShouldSucceed("foo.out", "foo.out"); |
- requestShould404("foo.txt"); |
+ server.stdout.expect(emitsLines( |
+ '[Info from LazyRewrite]:\n' |
+ 'Rewriting myapp|web/foo.txt.')); |
endPubServe(); |
}); |
} |