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

Unified Diff: sdk/lib/_internal/pub/test/transformer/can_use_read_input_as_string_test.dart

Issue 29343004: Support all Transform methods on ForeignTransform. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes Created 7 years, 2 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
Index: sdk/lib/_internal/pub/test/transformer/can_use_read_input_as_string_test.dart
diff --git a/sdk/lib/_internal/pub/test/transformer/prints_a_transform_interface_error_test.dart b/sdk/lib/_internal/pub/test/transformer/can_use_read_input_as_string_test.dart
similarity index 64%
copy from sdk/lib/_internal/pub/test/transformer/prints_a_transform_interface_error_test.dart
copy to sdk/lib/_internal/pub/test/transformer/can_use_read_input_as_string_test.dart
index d84ff22f1f91532bd9c0f35483897c67a3a2d502..0084d5c8105331a836391d2652ce764ef03551f3 100644
--- a/sdk/lib/_internal/pub/test/transformer/prints_a_transform_interface_error_test.dart
+++ b/sdk/lib/_internal/pub/test/transformer/can_use_read_input_as_string_test.dart
@@ -8,9 +8,7 @@ import '../descriptor.dart' as d;
import '../test_pub.dart';
import '../serve/utils.dart';
-import 'package:scheduled_test/scheduled_test.dart';
-
-final transformer = """
+const TRANSFORMER = """
import 'dart:async';
import 'package:barback/barback.dart';
@@ -19,19 +17,27 @@ class RewriteTransformer extends Transformer {
RewriteTransformer.asPlugin();
String get allowedExtensions => '.txt';
+
+ Future apply(Transform transform) {
+ return transform.readInputAsString(transform.primaryInput.id)
+ .then((contents) {
+ var id = transform.primaryInput.id.changeExtension(".out");
+ transform.addOutput(new Asset.fromString(id, "\$contents.out"));
+ });
+ }
}
""";
main() {
initConfig();
- integration("prints a transform interface error", () {
+ integration("a transform can use readInputAsString", () {
d.dir(appPath, [
d.pubspec({
"name": "myapp",
"transformers": ["myapp/src/transformer"]
}),
d.dir("lib", [d.dir("src", [
- d.file("transformer.dart", transformer)
+ d.file("transformer.dart", TRANSFORMER)
])]),
d.dir("web", [
d.file("foo.txt", "foo")
@@ -40,11 +46,8 @@ main() {
createLockFile('myapp', pkg: ['barback']);
- var server = startPubServe();
- expect(server.nextErrLine(), completion(equals('Build error:')));
- expect(server.nextErrLine(), completion(equals("Transform Rewrite on "
- "myapp|web/foo.txt threw error: Class 'RewriteTransformer' has no "
- "instance method 'apply'.")));
+ startPubServe();
+ requestShouldSucceed("foo.out", "foo.out");
endPubServe();
});
}

Powered by Google App Engine
This is Rietveld 408576698