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