OLD | NEW |
| (Empty) |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS d.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:scheduled_test/scheduled_test.dart'; | |
8 | |
9 import '../../lib/src/exit_codes.dart' as exit_codes; | |
10 import '../descriptor.dart' as d; | |
11 import '../test_pub.dart'; | |
12 | |
13 const TRANSFORMER = """ | |
14 import 'dart:async'; | |
15 | |
16 import 'package:barback/barback.dart'; | |
17 | |
18 class RewriteTransformer extends Transformer { | |
19 RewriteTransformer.asPlugin(); | |
20 | |
21 String get allowedExtensions => '.txt'; | |
22 | |
23 Future apply(Transform transform) => throw new Exception('oh no!'); | |
24 } | |
25 """; | |
26 | |
27 main() { | |
28 initConfig(); | |
29 withBarbackVersions("any", () { | |
30 integration("outputs error to JSON in a failed build", () { | |
31 // Loading transformers takes several seconds, so make sure we don't | |
32 // timeout. | |
33 currentSchedule.timeout *= 2; | |
34 | |
35 d.dir(appPath, [d.pubspec({ | |
36 "name": "myapp", | |
37 "transformers": ["myapp"] | |
38 }), | |
39 d.dir("lib", [d.file("transformer.dart", TRANSFORMER)]), | |
40 d.dir("web", [d.file("foo.txt", "foo")])]).create(); | |
41 | |
42 createLockFile('myapp', pkg: ['barback']); | |
43 | |
44 schedulePub(args: ["build", "--format", "json"], outputJson: { | |
45 "buildResult": "failure", | |
46 "errors": [{ | |
47 "error": startsWith( | |
48 "Transform Rewrite on myapp|web/foo.txt " "threw error: oh no!") | |
49 }], | |
50 "log": [] | |
51 }, exitCode: exit_codes.DATA); | |
52 }); | |
53 }); | |
54 } | |
OLD | NEW |