| Index: lib/pub_serve.dart
|
| diff --git a/lib/pub_serve.dart b/lib/pub_serve.dart
|
| index aae6a24ce5c9894428759a50541d108d7f47adc4..f500af0a68c9b1f8c783e9e957e12167ced1447a 100644
|
| --- a/lib/pub_serve.dart
|
| +++ b/lib/pub_serve.dart
|
| @@ -21,10 +21,10 @@ class PubServeTransformer extends Transformer implements DeclaringTransformer {
|
| var id = transform.primaryId;
|
| transform.declareOutput(id.addExtension('.vm_test.dart'));
|
| transform.declareOutput(id.addExtension('.browser_test.dart'));
|
| - transform.declareOutput(id.addExtension('.browser_test.html'));
|
| + transform.declareOutput(id.changeExtension('.html'));
|
| }
|
|
|
| - void apply(Transform transform) {
|
| + Future apply(Transform transform) {
|
| var id = transform.primaryInput.id;
|
|
|
| transform.addOutput(
|
| @@ -41,27 +41,33 @@ void main(_, Map message) {
|
| }
|
| '''));
|
|
|
| - var browserId = id.addExtension('.browser_test.dart');
|
| - transform.addOutput(new Asset.fromString(browserId, '''
|
| + transform.addOutput(
|
| + new Asset.fromString(id.addExtension('.browser_test.dart'), '''
|
| import "package:test/src/runner/browser/iframe_listener.dart";
|
|
|
| import "${p.url.basename(id.path)}" as test;
|
|
|
| -void main(_) {
|
| +void main() {
|
| IframeListener.start(() => test.main);
|
| }
|
| '''));
|
|
|
| - transform.addOutput(
|
| - new Asset.fromString(id.addExtension('.browser_test.html'), '''
|
| + // If the user has their own HTML file for the test, let that take
|
| + // precedence. Otherwise, create our own basic file.
|
| + var htmlId = id.changeExtension('.html');
|
| + return transform.hasInput(htmlId).then((hasInput) {
|
| + if (hasInput) return;
|
| + transform.addOutput(
|
| + new Asset.fromString(htmlId, '''
|
| <!DOCTYPE html>
|
| <html>
|
| <head>
|
| <title>${HTML_ESCAPE.convert(id.path)} Test</title>
|
| - <script src="${HTML_ESCAPE.convert(p.url.basename(browserId.path))}.js">
|
| - </script>
|
| + <link rel="x-dart-test" href="${HTML_ESCAPE.convert(p.url.basename(id.path))}">
|
| + <script src="packages/test/dart.js"></script>
|
| </head>
|
| </html>
|
| '''));
|
| + });
|
| }
|
| }
|
|
|