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

Unified Diff: lib/pub_serve.dart

Issue 1087303004: Add support for user-defined HTML files. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Code review changes Created 5 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 | « lib/dart.js ('k') | lib/src/runner/browser/server.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/pub_serve.dart
diff --git a/lib/pub_serve.dart b/lib/pub_serve.dart
index aae6a24ce5c9894428759a50541d108d7f47adc4..92112e87e718971db5a8c8a268810a7e23c9b4a5 100644
--- a/lib/pub_serve.dart
+++ b/lib/pub_serve.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import 'dart:async';
import 'dart:convert';
import 'package:barback/barback.dart';
@@ -21,10 +22,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 +42,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>
'''));
+ });
}
}
« no previous file with comments | « lib/dart.js ('k') | lib/src/runner/browser/server.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698