OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 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 | 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 import '../descriptor.dart' as d; | 5 import '../descriptor.dart' as d; |
6 import '../test_pub.dart'; | 6 import '../test_pub.dart'; |
7 | 7 |
8 const TRANSFORMER = """ | 8 const TRANSFORMER = """ |
9 import 'dart:async'; | 9 import 'dart:async'; |
10 | 10 |
(...skipping 11 matching lines...) Expand all Loading... |
22 new AssetId(transform.primaryInput.id.package, "bin/script.dart"), | 22 new AssetId(transform.primaryInput.id.package, "bin/script.dart"), |
23 "void main() => print('\${_settings.mode.name}');")); | 23 "void main() => print('\${_settings.mode.name}');")); |
24 } | 24 } |
25 } | 25 } |
26 """; | 26 """; |
27 | 27 |
28 main() { | 28 main() { |
29 initConfig(); | 29 initConfig(); |
30 withBarbackVersions("any", () { | 30 withBarbackVersions("any", () { |
31 integration('runs a local script with customizable modes', () { | 31 integration('runs a local script with customizable modes', () { |
32 d.dir(appPath, [ | 32 d.dir(appPath, [d.pubspec({ |
33 d.pubspec({ | |
34 "name": "myapp", | 33 "name": "myapp", |
35 "transformers": ["myapp/src/transformer"] | 34 "transformers": ["myapp/src/transformer"] |
36 }), | 35 }), |
37 d.dir("lib", [d.dir("src", [ | 36 d.dir( |
38 d.file("transformer.dart", TRANSFORMER), | 37 "lib", |
39 d.file("primary.in", "") | 38 [ |
40 ])]) | 39 d.dir( |
41 ]).create(); | 40 "src", |
| 41 [ |
| 42 d.file("transformer.dart", TRANSFORMER), |
| 43 d.file("primary.in", "")])])]).create(); |
42 | 44 |
43 createLockFile('myapp', pkg: ['barback']); | 45 createLockFile('myapp', pkg: ['barback']); |
44 | 46 |
45 // By default it should run in debug mode. | 47 // By default it should run in debug mode. |
46 var pub = pubRun(args: ["script"]); | 48 var pub = pubRun(args: ["script"]); |
47 pub.stdout.expect("debug"); | 49 pub.stdout.expect("debug"); |
48 pub.shouldExit(); | 50 pub.shouldExit(); |
49 | 51 |
50 // A custom mode should be specifiable. | 52 // A custom mode should be specifiable. |
51 pub = pubRun(args: ["--mode", "custom-mode", "script"]); | 53 pub = pubRun(args: ["--mode", "custom-mode", "script"]); |
52 pub.stdout.expect("custom-mode"); | 54 pub.stdout.expect("custom-mode"); |
53 pub.shouldExit(); | 55 pub.shouldExit(); |
54 }); | 56 }); |
55 | 57 |
56 integration('runs a dependency script with customizable modes', () { | 58 integration('runs a dependency script with customizable modes', () { |
57 d.dir("foo", [ | 59 d.dir("foo", [d.pubspec({ |
58 d.pubspec({ | |
59 "name": "foo", | 60 "name": "foo", |
60 "version": "1.2.3", | 61 "version": "1.2.3", |
61 "transformers": ["foo/src/transformer"] | 62 "transformers": ["foo/src/transformer"] |
62 }), | 63 }), |
63 d.dir("lib", [d.dir("src", [ | 64 d.dir( |
64 d.file("transformer.dart", TRANSFORMER), | 65 "lib", |
65 d.file("primary.in", "") | 66 [ |
66 ])]) | 67 d.dir( |
67 ]).create(); | 68 "src", |
| 69 [ |
| 70 d.file("transformer.dart", TRANSFORMER), |
| 71 d.file("primary.in", "")])])]).create(); |
68 | 72 |
69 d.appDir({"foo": {"path": "../foo"}}).create(); | 73 d.appDir({ |
| 74 "foo": { |
| 75 "path": "../foo" |
| 76 } |
| 77 }).create(); |
70 | 78 |
71 createLockFile('myapp', sandbox: ['foo'], pkg: ['barback']); | 79 createLockFile('myapp', sandbox: ['foo'], pkg: ['barback']); |
72 | 80 |
73 // By default it should run in release mode. | 81 // By default it should run in release mode. |
74 var pub = pubRun(args: ["foo:script"]); | 82 var pub = pubRun(args: ["foo:script"]); |
75 pub.stdout.expect("release"); | 83 pub.stdout.expect("release"); |
76 pub.shouldExit(); | 84 pub.shouldExit(); |
77 | 85 |
78 // A custom mode should be specifiable. | 86 // A custom mode should be specifiable. |
79 pub = pubRun(args: ["--mode", "custom-mode", "foo:script"]); | 87 pub = pubRun(args: ["--mode", "custom-mode", "foo:script"]); |
80 pub.stdout.expect("custom-mode"); | 88 pub.stdout.expect("custom-mode"); |
81 pub.shouldExit(); | 89 pub.shouldExit(); |
82 }); | 90 }); |
83 }); | 91 }); |
84 } | 92 } |
OLD | NEW |