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