| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 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 | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 import 'dart:async'; | 5 import 'dart:async'; |
| 6 import 'dart:convert'; | 6 import 'dart:convert'; |
| 7 | 7 |
| 8 import 'package:barback/barback.dart'; | 8 import 'package:barback/barback.dart'; |
| 9 import 'package:path/path.dart' as p; | 9 import 'package:path/path.dart' as p; |
| 10 | 10 |
| 11 /// A transformer that injects bootstrapping code used by the test runner to run | 11 /// A transformer that injects bootstrapping code used by the test runner to run |
| 12 /// tests against a "pub serve" instance. | 12 /// tests against a "pub serve" instance. |
| 13 /// | 13 /// |
| 14 /// This doesn't modify existing code at all, it just adds wrapper files that | 14 /// This doesn't modify existing code at all, it just adds wrapper files that |
| 15 /// can be used to load isolates or iframes. | 15 /// can be used to load isolates or iframes. |
| 16 class PubServeTransformer extends Transformer implements DeclaringTransformer { | 16 class PubServeTransformer extends Transformer implements DeclaringTransformer { |
| 17 final allowedExtensions = ".dart"; | 17 final allowedExtensions = ".dart"; |
| 18 | 18 |
| 19 PubServeTransformer.asPlugin(); | 19 PubServeTransformer.asPlugin(); |
| 20 | 20 |
| 21 void declareOutputs(DeclaringTransform transform) { | 21 void declareOutputs(DeclaringTransform transform) { |
| 22 var id = transform.primaryId; | 22 var id = transform.primaryId; |
| 23 transform.declareOutput(id.addExtension('.vm_test.dart')); | 23 transform.declareOutput(id.addExtension('.vm_test.dart')); |
| 24 transform.declareOutput(id.addExtension('.browser_test.dart')); | 24 transform.declareOutput(id.addExtension('.browser_test.dart')); |
| 25 transform.declareOutput(id.changeExtension('.html')); | |
| 26 } | 25 } |
| 27 | 26 |
| 28 Future apply(Transform transform) { | 27 Future apply(Transform transform) { |
| 29 var id = transform.primaryInput.id; | 28 var id = transform.primaryInput.id; |
| 30 | 29 |
| 31 transform.addOutput( | 30 transform.addOutput( |
| 32 new Asset.fromString(id.addExtension('.vm_test.dart'), ''' | 31 new Asset.fromString(id.addExtension('.vm_test.dart'), ''' |
| 33 import "package:test/src/backend/metadata.dart"; | 32 import "package:test/src/backend/metadata.dart"; |
| 34 import "package:test/src/runner/vm/isolate_listener.dart"; | 33 import "package:test/src/runner/vm/isolate_listener.dart"; |
| 35 | 34 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 65 <head> | 64 <head> |
| 66 <title>${HTML_ESCAPE.convert(id.path)} Test</title> | 65 <title>${HTML_ESCAPE.convert(id.path)} Test</title> |
| 67 <link rel="x-dart-test" href="${HTML_ESCAPE.convert(p.url.basename(id.path))}"
> | 66 <link rel="x-dart-test" href="${HTML_ESCAPE.convert(p.url.basename(id.path))}"
> |
| 68 <script src="packages/test/dart.js"></script> | 67 <script src="packages/test/dart.js"></script> |
| 69 </head> | 68 </head> |
| 70 </html> | 69 </html> |
| 71 ''')); | 70 ''')); |
| 72 }); | 71 }); |
| 73 } | 72 } |
| 74 } | 73 } |
| OLD | NEW |