| OLD | NEW |
| 1 // Copyright (c) 2014, 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 library pub_tests; | 1 library pub_tests; |
| 6 | |
| 7 import 'package:path/path.dart' as p; | 2 import 'package:path/path.dart' as p; |
| 8 import 'package:scheduled_test/scheduled_test.dart'; | 3 import 'package:scheduled_test/scheduled_test.dart'; |
| 9 | |
| 10 import '../descriptor.dart' as d; | 4 import '../descriptor.dart' as d; |
| 11 import '../test_pub.dart'; | 5 import '../test_pub.dart'; |
| 12 | |
| 13 const REPLACE_TRANSFORMER = """ | 6 const REPLACE_TRANSFORMER = """ |
| 14 import 'dart:async'; | 7 import 'dart:async'; |
| 15 | 8 |
| 16 import 'package:barback/barback.dart'; | 9 import 'package:barback/barback.dart'; |
| 17 | 10 |
| 18 class ReplaceTransformer extends Transformer { | 11 class ReplaceTransformer extends Transformer { |
| 19 ReplaceTransformer.asPlugin(); | 12 ReplaceTransformer.asPlugin(); |
| 20 | 13 |
| 21 String get allowedExtensions => '.dart'; | 14 String get allowedExtensions => '.dart'; |
| 22 | 15 |
| 23 Future apply(Transform transform) { | 16 Future apply(Transform transform) { |
| 24 return transform.primaryInput.readAsString().then((contents) { | 17 return transform.primaryInput.readAsString().then((contents) { |
| 25 transform.addOutput(new Asset.fromString(transform.primaryInput.id, | 18 transform.addOutput(new Asset.fromString(transform.primaryInput.id, |
| 26 contents.replaceAll("REPLACE ME", "hello!"))); | 19 contents.replaceAll("REPLACE ME", "hello!"))); |
| 27 }); | 20 }); |
| 28 } | 21 } |
| 29 } | 22 } |
| 30 """; | 23 """; |
| 31 | |
| 32 main() { | 24 main() { |
| 33 initConfig(); | 25 initConfig(); |
| 34 integration("snapshots the transformed version of an executable", () { | 26 integration("snapshots the transformed version of an executable", () { |
| 35 servePackages((builder) { | 27 servePackages((builder) { |
| 36 builder.serveRepoPackage('barback'); | 28 builder.serveRepoPackage('barback'); |
| 37 | 29 builder.serve("foo", "1.2.3", deps: { |
| 38 builder.serve("foo", "1.2.3", | 30 "barback": "any" |
| 39 deps: {"barback": "any"}, | 31 }, pubspec: { |
| 40 pubspec: {'transformers': ['foo']}, | 32 'transformers': ['foo'] |
| 33 }, |
| 41 contents: [ | 34 contents: [ |
| 42 d.dir("lib", [d.file("foo.dart", REPLACE_TRANSFORMER)]), | 35 d.dir("lib", [d.file("foo.dart", REPLACE_TRANSFORMER)]), |
| 43 d.dir("bin", [ | 36 d.dir("bin", [d.file("hello.dart", """ |
| 44 d.file("hello.dart", """ | |
| 45 final message = 'REPLACE ME'; | 37 final message = 'REPLACE ME'; |
| 46 | 38 |
| 47 void main() => print(message); | 39 void main() => print(message); |
| 48 """), | 40 """)])]); |
| 49 ]) | |
| 50 ]); | |
| 51 }); | 41 }); |
| 52 | 42 d.appDir({ |
| 53 d.appDir({"foo": "1.2.3"}).create(); | 43 "foo": "1.2.3" |
| 54 | 44 }).create(); |
| 55 pubGet(output: contains("Precompiled foo:hello.")); | 45 pubGet(output: contains("Precompiled foo:hello.")); |
| 56 | 46 d.dir( |
| 57 d.dir(p.join(appPath, '.pub', 'bin'), [ | 47 p.join(appPath, '.pub', 'bin'), |
| 58 d.dir('foo', [d.matcherFile('hello.dart.snapshot', contains('hello!'))]) | 48 [ |
| 59 ]).validate(); | 49 d.dir( |
| 60 | 50 'foo', |
| 51 [d.matcherFile('hello.dart.snapshot', contains('hello!'))])]).va
lidate(); |
| 61 var process = pubRun(args: ['foo:hello']); | 52 var process = pubRun(args: ['foo:hello']); |
| 62 process.stdout.expect("hello!"); | 53 process.stdout.expect("hello!"); |
| 63 process.shouldExit(); | 54 process.shouldExit(); |
| 64 }); | 55 }); |
| 65 } | 56 } |
| OLD | NEW |