| 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, [ | |
| 36 d.pubspec({ | |
| 37 "name": "myapp", | |
| 38 "transformers": ["myapp"] | |
| 39 }), | |
| 40 d.dir("lib", [ | |
| 41 d.file("transformer.dart", TRANSFORMER) | |
| 42 ]), | |
| 43 d.dir("web", [ | |
| 44 d.file("foo.txt", "foo") | |
| 45 ]) | |
| 46 ]).create(); | |
| 47 | |
| 48 createLockFile('myapp', pkg: ['barback']); | |
| 49 | |
| 50 schedulePub(args: ["build", "--format", "json"], | |
| 51 outputJson: { | |
| 52 "buildResult": "failure", | |
| 53 "errors": [ | |
| 54 { | |
| 55 "error": startsWith("Transform Rewrite on myapp|web/foo.txt " | |
| 56 "threw error: oh no!") | |
| 57 } | |
| 58 ], | |
| 59 "log": [] | |
| 60 }, | |
| 61 exitCode: exit_codes.DATA); | |
| 62 }); | |
| 63 }); | |
| 64 } | |
| OLD | NEW |