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 import '../descriptor.dart' as d; | 1 import '../descriptor.dart' as d; |
6 import '../test_pub.dart'; | 2 import '../test_pub.dart'; |
7 | |
8 const SCRIPT = """ | 3 const SCRIPT = """ |
9 main() { | 4 main() { |
10 print("should not get here!"); | 5 print("should not get here!"); |
11 } | 6 } |
12 """; | 7 """; |
13 | |
14 const TRANSFORMER = """ | 8 const TRANSFORMER = """ |
15 import 'dart:async'; | 9 import 'dart:async'; |
16 | 10 |
17 import 'package:barback/barback.dart'; | 11 import 'package:barback/barback.dart'; |
18 | 12 |
19 class FailingTransformer extends Transformer { | 13 class FailingTransformer extends Transformer { |
20 FailingTransformer.asPlugin(); | 14 FailingTransformer.asPlugin(); |
21 | 15 |
22 String get allowedExtensions => '.dart'; | 16 String get allowedExtensions => '.dart'; |
23 | 17 |
24 void apply(Transform transform) { | 18 void apply(Transform transform) { |
25 // Don't run on the transformer itself. | 19 // Don't run on the transformer itself. |
26 if (transform.primaryInput.id.path.startsWith("lib")) return; | 20 if (transform.primaryInput.id.path.startsWith("lib")) return; |
27 transform.logger.error('\${transform.primaryInput.id}.'); | 21 transform.logger.error('\${transform.primaryInput.id}.'); |
28 } | 22 } |
29 } | 23 } |
30 """; | 24 """; |
31 | |
32 main() { | 25 main() { |
33 initConfig(); | 26 initConfig(); |
34 withBarbackVersions("any", () { | 27 withBarbackVersions("any", () { |
35 integration('does not run if a transformer has an error', () { | 28 integration('does not run if a transformer has an error', () { |
36 d.dir(appPath, [ | 29 d.dir(appPath, [d.pubspec({ |
37 d.pubspec({ | |
38 "name": "myapp", | 30 "name": "myapp", |
39 "transformers": ["myapp/src/transformer"] | 31 "transformers": ["myapp/src/transformer"] |
40 }), | 32 }), |
41 d.dir("lib", [ | 33 d.dir("lib", [d.dir("src", [d.file("transformer.dart", TRANSFORMER)]
)]), |
42 d.dir("src", [ | 34 d.dir("bin", [d.file("script.dart", SCRIPT)])]).create(); |
43 d.file("transformer.dart", TRANSFORMER) | |
44 ]) | |
45 ]), | |
46 d.dir("bin", [ | |
47 d.file("script.dart", SCRIPT) | |
48 ]) | |
49 ]).create(); | |
50 | |
51 createLockFile('myapp', pkg: ['barback']); | 35 createLockFile('myapp', pkg: ['barback']); |
52 | |
53 var pub = pubRun(args: ["script"]); | 36 var pub = pubRun(args: ["script"]); |
54 | |
55 pub.stderr.expect("[Error from Failing]:"); | 37 pub.stderr.expect("[Error from Failing]:"); |
56 pub.stderr.expect("myapp|bin/script.dart."); | 38 pub.stderr.expect("myapp|bin/script.dart."); |
57 | |
58 // Note: no output from the script. | |
59 pub.shouldExit(); | 39 pub.shouldExit(); |
60 }); | 40 }); |
61 }); | 41 }); |
62 } | 42 } |
OLD | NEW |