| 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 import '../../descriptor.dart' as d; | |
| 6 import '../../test_pub.dart'; | |
| 7 | |
| 8 const TRANSFORMER = """ | |
| 9 import 'dart:async'; | |
| 10 | |
| 11 import 'package:barback/barback.dart'; | |
| 12 | |
| 13 class DartTransformer extends Transformer { | |
| 14 final BarbackSettings _settings; | |
| 15 | |
| 16 DartTransformer.asPlugin(this._settings); | |
| 17 | |
| 18 String get allowedExtensions => '.in'; | |
| 19 | |
| 20 void apply(Transform transform) { | |
| 21 transform.addOutput(new Asset.fromString( | |
| 22 new AssetId(transform.primaryInput.id.package, "bin/script.dart"), | |
| 23 "void main() => print('\${_settings.mode.name}');")); | |
| 24 } | |
| 25 } | |
| 26 """; | |
| 27 | |
| 28 main() { | |
| 29 initConfig(); | |
| 30 integration( | |
| 31 'runs a script in an activated package with customizable modes', | |
| 32 () { | |
| 33 servePackages((builder) { | |
| 34 builder.serveRepoPackage("barback"); | |
| 35 | |
| 36 builder.serve("foo", "1.0.0", deps: { | |
| 37 "barback": "any" | |
| 38 }, pubspec: { | |
| 39 "transformers": ["foo/src/transformer"] | |
| 40 }, | |
| 41 contents: [ | |
| 42 d.dir( | |
| 43 "lib", | |
| 44 [ | |
| 45 d.dir( | |
| 46 "src", | |
| 47 [d.file("transformer.dart", TRANSFORMER), d.file("prim
ary.in", "")])])]); | |
| 48 }); | |
| 49 | |
| 50 schedulePub(args: ["global", "activate", "foo"]); | |
| 51 | |
| 52 // By default it should run in release mode. | |
| 53 var pub = pubRun(global: true, args: ["foo:script"]); | |
| 54 pub.stdout.expect("release"); | |
| 55 pub.shouldExit(); | |
| 56 | |
| 57 // A custom mode should be specifiable. | |
| 58 pub = pubRun(global: true, args: ["--mode", "custom-mode", "foo:script"]); | |
| 59 pub.stdout.expect("custom-mode"); | |
| 60 pub.shouldExit(); | |
| 61 }); | |
| 62 } | |
| OLD | NEW |