| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS d.file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS d.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 library pub_tests; | 5 library pub_tests; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:http/http.dart' as http; | 9 import 'package:http/http.dart' as http; |
| 10 import 'package:scheduled_test/scheduled_process.dart'; | 10 import 'package:scheduled_test/scheduled_process.dart'; |
| 11 import 'package:scheduled_test/scheduled_test.dart'; | 11 import 'package:scheduled_test/scheduled_test.dart'; |
| 12 | 12 |
| 13 import '../test_pub.dart'; | 13 import '../test_pub.dart'; |
| 14 | 14 |
| 15 /// The pub process running "pub serve". | 15 /// The pub process running "pub serve". |
| 16 ScheduledProcess _pubServer; | 16 ScheduledProcess _pubServer; |
| 17 | 17 |
| 18 /// The ephemeral port assigned to the running server. | 18 /// The ephemeral port assigned to the running server. |
| 19 int _port; | 19 int _port; |
| 20 | 20 |
| 21 /// The code for a transformer that renames ".txt" files to ".out" and adds a | 21 /// The code for a transformer that renames ".txt" files to ".out" and adds a |
| 22 /// ".out" suffix. | 22 /// ".out" suffix. |
| 23 const REWRITE_TRANSFORMER = """ | 23 const REWRITE_TRANSFORMER = """ |
| 24 import 'dart:async'; | 24 import 'dart:async'; |
| 25 | 25 |
| 26 import 'package:barback/barback.dart'; | 26 import 'package:barback/barback.dart'; |
| 27 | 27 |
| 28 class RewriteTransformer extends Transformer { | 28 class RewriteTransformer extends Transformer { |
| 29 RewriteTransformer(); | 29 RewriteTransformer.asPlugin(); |
| 30 | 30 |
| 31 String get allowedExtensions => '.txt'; | 31 String get allowedExtensions => '.txt'; |
| 32 | 32 |
| 33 Future apply(Transform transform) { | 33 Future apply(Transform transform) { |
| 34 return transform.primaryInput.readAsString().then((contents) { | 34 return transform.primaryInput.readAsString().then((contents) { |
| 35 var id = transform.primaryInput.id.changeExtension(".out"); | 35 var id = transform.primaryInput.id.changeExtension(".out"); |
| 36 transform.addOutput(new Asset.fromString(id, "\$contents.out")); | 36 transform.addOutput(new Asset.fromString(id, "\$contents.out")); |
| 37 }); | 37 }); |
| 38 } | 38 } |
| 39 } | 39 } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 62 import 'dart:async'; | 62 import 'dart:async'; |
| 63 | 63 |
| 64 import 'package:barback/barback.dart'; | 64 import 'package:barback/barback.dart'; |
| 65 $import | 65 $import |
| 66 | 66 |
| 67 const TOKEN = "$id"; | 67 const TOKEN = "$id"; |
| 68 | 68 |
| 69 final _tokenRegExp = new RegExp(r'^const TOKEN = "(.*?)";\$', multiLine: true); | 69 final _tokenRegExp = new RegExp(r'^const TOKEN = "(.*?)";\$', multiLine: true); |
| 70 | 70 |
| 71 class DartTransformer extends Transformer { | 71 class DartTransformer extends Transformer { |
| 72 DartTransformer(); | 72 DartTransformer.asPlugin(); |
| 73 | 73 |
| 74 String get allowedExtensions => '.dart'; | 74 String get allowedExtensions => '.dart'; |
| 75 | 75 |
| 76 Future apply(Transform transform) { | 76 Future apply(Transform transform) { |
| 77 return transform.primaryInput.readAsString().then((contents) { | 77 return transform.primaryInput.readAsString().then((contents) { |
| 78 transform.addOutput(new Asset.fromString(transform.primaryInput.id, | 78 transform.addOutput(new Asset.fromString(transform.primaryInput.id, |
| 79 contents.replaceAllMapped(_tokenRegExp, (match) { | 79 contents.replaceAllMapped(_tokenRegExp, (match) { |
| 80 return 'const TOKEN = "(\${match[1]}, \$TOKEN)";'; | 80 return 'const TOKEN = "(\${match[1]}, \$TOKEN)";'; |
| 81 }))); | 81 }))); |
| 82 }); | 82 }); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 return _pubServer.nextLine().then((line) { | 159 return _pubServer.nextLine().then((line) { |
| 160 if (line.contains("successfully")) return; | 160 if (line.contains("successfully")) return; |
| 161 | 161 |
| 162 // This line wasn't it, so ignore it and keep trying. | 162 // This line wasn't it, so ignore it and keep trying. |
| 163 return nextLine(); | 163 return nextLine(); |
| 164 }); | 164 }); |
| 165 } | 165 } |
| 166 | 166 |
| 167 schedule(nextLine); | 167 schedule(nextLine); |
| 168 } | 168 } |
| OLD | NEW |