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

Side by Side Diff: mojo/public/dart/third_party/test/lib/pub_serve.dart

Issue 1346773002: Stop running pub get at gclient sync time and fix build bugs (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 3 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 import 'dart:async';
6 import 'dart:convert';
7
8 import 'package:barback/barback.dart';
9 import 'package:path/path.dart' as p;
10
11 /// A transformer that injects bootstrapping code used by the test runner to run
12 /// tests against a "pub serve" instance.
13 ///
14 /// This doesn't modify existing code at all, it just adds wrapper files that
15 /// can be used to load isolates or iframes.
16 class PubServeTransformer extends Transformer implements DeclaringTransformer {
17 final allowedExtensions = ".dart";
18
19 PubServeTransformer.asPlugin();
20
21 void declareOutputs(DeclaringTransform transform) {
22 var id = transform.primaryId;
23 transform.declareOutput(id.addExtension('.vm_test.dart'));
24 transform.declareOutput(id.addExtension('.browser_test.dart'));
25 }
26
27 Future apply(Transform transform) async {
28 var id = transform.primaryInput.id;
29
30 transform.addOutput(
31 new Asset.fromString(id.addExtension('.vm_test.dart'), '''
32 import "package:test/src/backend/metadata.dart";
33 import "package:test/src/runner/vm/isolate_listener.dart";
34
35 import "${p.url.basename(id.path)}" as test;
36
37 void main(_, Map message) {
38 var sendPort = message['reply'];
39 var metadata = new Metadata.deserialize(message['metadata']);
40 IsolateListener.start(sendPort, metadata, () => test.main);
41 }
42 '''));
43
44 transform.addOutput(
45 new Asset.fromString(id.addExtension('.browser_test.dart'), '''
46 import "package:test/src/runner/browser/iframe_listener.dart";
47
48 import "${p.url.basename(id.path)}" as test;
49
50 void main() {
51 IframeListener.start(() => test.main);
52 }
53 '''));
54
55 // If the user has their own HTML file for the test, let that take
56 // precedence. Otherwise, create our own basic file.
57 var htmlId = id.changeExtension('.html');
58 if (await transform.hasInput(htmlId)) return;
59
60 transform.addOutput(
61 new Asset.fromString(htmlId, '''
62 <!DOCTYPE html>
63 <html>
64 <head>
65 <title>${HTML_ESCAPE.convert(id.path)} Test</title>
66 <link rel="x-dart-test" href="${HTML_ESCAPE.convert(p.url.basename(id.path))}" >
67 <script src="packages/test/dart.js"></script>
68 </head>
69 </html>
70 '''));
71 }
72 }
OLDNEW
« no previous file with comments | « mojo/public/dart/third_party/test/lib/dart.js ('k') | mojo/public/dart/third_party/test/lib/src/backend/closed_exception.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698