Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(805)

Unified Diff: sdk/lib/_internal/pub/test/serve/supports_user_defined_lazy_transformers_test.dart

Issue 239853002: Support declaring and lazy transformers in pub. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: code review Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/_internal/pub/test/serve/supports_user_defined_declaring_transformers.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
});
}
« no previous file with comments | « sdk/lib/_internal/pub/test/serve/supports_user_defined_declaring_transformers.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698