| 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('runs a script in an activated package with customizable modes', | |
| 31 () { | |
| 32 servePackages((builder) { | |
| 33 builder.serveRepoPackage("barback"); | |
| 34 | |
| 35 builder.serve("foo", "1.0.0", | |
| 36 deps: {"barback": "any"}, | |
| 37 pubspec: {"transformers": ["foo/src/transformer"]}, | |
| 38 contents: [ | |
| 39 d.dir("lib", [d.dir("src", [ | |
| 40 d.file("transformer.dart", TRANSFORMER), | |
| 41 d.file("primary.in", "") | |
| 42 ])]) | |
| 43 ]); | |
| 44 }); | |
| 45 | |
| 46 schedulePub(args: ["global", "activate", "foo"]); | |
| 47 | |
| 48 // By default it should run in release mode. | |
| 49 var pub = pubRun(global: true, args: ["foo:script"]); | |
| 50 pub.stdout.expect("release"); | |
| 51 pub.shouldExit(); | |
| 52 | |
| 53 // A custom mode should be specifiable. | |
| 54 pub = pubRun(global: true, args: ["--mode", "custom-mode", "foo:script"]); | |
| 55 pub.stdout.expect("custom-mode"); | |
| 56 pub.shouldExit(); | |
| 57 }); | |
| 58 } | |
| OLD | NEW |