Chromium Code Reviews| Index: sdk/lib/_internal/pub/test/serve/utils.dart |
| diff --git a/sdk/lib/_internal/pub/test/serve/utils.dart b/sdk/lib/_internal/pub/test/serve/utils.dart |
| index 128917a1a0c1fdcca6b87559f22e640ee6bf2b24..e983fe56ce38b840c1dd122ad4618365ee1195ab 100644 |
| --- a/sdk/lib/_internal/pub/test/serve/utils.dart |
| +++ b/sdk/lib/_internal/pub/test/serve/utils.dart |
| @@ -18,10 +18,34 @@ ScheduledProcess _pubServer; |
| /// The ephemeral port assigned to the running server. |
| int _port; |
| +/// The code for a transformer that renames ".txt" files to ".out" and adds a |
| +/// ".out" suffix. |
| +const REWRITE_TRANSFORMER = """ |
| +import 'dart:async'; |
| + |
| +import 'package:barback/barback.dart'; |
| + |
| +class RewriteTransformer extends Transformer { |
| + RewriteTransformer(); |
| + |
| + String get allowedExtensions => '.txt'; |
| + |
| + Future apply(Transform transform) { |
| + return transform.primaryInput |
| + .then((input) => input.readAsString()) |
| + .then((contents) { |
| + var id = transform.primaryId.changeExtension(".out"); |
| + transform.addOutput(new Asset.fromString(id, "\$contents.out")); |
| + }); |
| + } |
| +} |
| +"""; |
| + |
| /// Schedules starting the "pub serve" process. |
| /// |
| /// If [shouldInstallFirst] is `true`, validates that pub install is run first. |
| -void startPubServe({bool shouldInstallFirst: false}) { |
| +/// Returns the `pub serve` process. |
|
Bob Nystrom
2013/08/27 22:12:30
Newline above this.
nweiz
2013/08/28 20:45:23
Done.
|
| +ScheduledProcess startPubServe({bool shouldInstallFirst: false}) { |
| // Use port 0 to get an ephemeral port. |
| _pubServer = startPub(args: ["serve", "--port=0"]); |
| @@ -35,6 +59,7 @@ void startPubServe({bool shouldInstallFirst: false}) { |
| } |
| expect(_pubServer.nextLine().then(_parsePort), completes); |
| + return _pubServer; |
| } |
| /// Parses the port number from the "Serving blah on localhost:1234" line |