| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS d.file | 1 // Copyright (c) 2013, 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 library pub_tests; | 5 library pub_tests; |
| 6 | 6 |
| 7 import 'package:scheduled_test/scheduled_test.dart'; | 7 import 'package:scheduled_test/scheduled_test.dart'; |
| 8 import 'package:scheduled_test/scheduled_stream.dart'; | 8 import 'package:scheduled_test/scheduled_stream.dart'; |
| 9 | 9 |
| 10 import '../../lib/src/exit_codes.dart' as exit_codes; | 10 import '../../lib/src/exit_codes.dart' as exit_codes; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 main() { | 67 main() { |
| 68 initConfig(); | 68 initConfig(); |
| 69 // This intentionally tests barback 0.14.2 with both transformers, since it | 69 // This intentionally tests barback 0.14.2 with both transformers, since it |
| 70 // supports both types of span. | 70 // supports both types of span. |
| 71 withBarbackVersions("<0.15.0", () => runTest(SOURCE_MAPS_TRANSFORMER)); | 71 withBarbackVersions("<0.15.0", () => runTest(SOURCE_MAPS_TRANSFORMER)); |
| 72 withBarbackVersions(">=0.14.2", () => runTest(SOURCE_SPAN_TRANSFORMER)); | 72 withBarbackVersions(">=0.14.2", () => runTest(SOURCE_SPAN_TRANSFORMER)); |
| 73 } | 73 } |
| 74 | 74 |
| 75 void runTest(String transformerText) { | 75 void runTest(String transformerText) { |
| 76 integration("can log messages", () { | 76 integration("can log messages", () { |
| 77 d.dir(appPath, [ | 77 d.dir(appPath, [d.pubspec({ |
| 78 d.pubspec({ | |
| 79 "name": "myapp", | 78 "name": "myapp", |
| 80 "transformers": ["myapp/src/transformer"] | 79 "transformers": ["myapp/src/transformer"] |
| 81 }), | 80 }), |
| 82 d.dir("lib", [d.dir("src", [ | 81 d.dir("lib", [d.dir("src", [d.file("transformer.dart", transformerText
)])]), |
| 83 d.file("transformer.dart", transformerText) | 82 d.dir("web", [d.file("foo.txt", "foo")])]).create(); |
| 84 ])]), | |
| 85 d.dir("web", [ | |
| 86 d.file("foo.txt", "foo") | |
| 87 ]) | |
| 88 ]).create(); | |
| 89 | 83 |
| 90 createLockFile('myapp', pkg: ['barback']); | 84 createLockFile('myapp', pkg: ['barback']); |
| 91 | 85 |
| 92 var pub = startPub(args: ["build"]); | 86 var pub = startPub(args: ["build"]); |
| 93 pub.stdout.expect(startsWith("Loading source assets...")); | 87 pub.stdout.expect(startsWith("Loading source assets...")); |
| 94 pub.stdout.expect(consumeWhile(matches("Loading .* transformers..."))); | 88 pub.stdout.expect(consumeWhile(matches("Loading .* transformers..."))); |
| 95 pub.stdout.expect(startsWith("Building myapp...")); | 89 pub.stdout.expect(startsWith("Building myapp...")); |
| 96 | 90 |
| 97 pub.stdout.expect(emitsLines(""" | 91 pub.stdout.expect(emitsLines(""" |
| 98 [Rewrite on myapp|web/foo.txt]: | 92 [Rewrite on myapp|web/foo.txt]: |
| 99 info!""")); | 93 info!""")); |
| 100 | 94 |
| 101 pub.stderr.expect(emitsLines(""" | 95 pub.stderr.expect(emitsLines(""" |
| 102 [Rewrite on myapp|web/foo.txt with input myapp|web/foo.foo]: | 96 [Rewrite on myapp|web/foo.txt with input myapp|web/foo.foo]: |
| 103 Warning! | 97 Warning! |
| 104 [Rewrite on myapp|web/foo.txt]:""")); | 98 [Rewrite on myapp|web/foo.txt]:""")); |
| 105 | 99 |
| 106 // The details of the analyzer's error message change pretty frequently, | 100 // The details of the analyzer's error message change pretty frequently, |
| 107 // so instead of validating the entire line, just look for a couple of | 101 // so instead of validating the entire line, just look for a couple of |
| 108 // salient bits of information. | 102 // salient bits of information. |
| 109 pub.stderr.expect(allOf([ | 103 pub.stderr.expect(allOf([contains("2"), // The line number. |
| 110 contains("2"), // The line number. | 104 contains("1"), // The column number. |
| 111 contains("1"), // The column number. | 105 contains("http://fake.com/not_real.dart"), // The library. |
| 112 contains("http://fake.com/not_real.dart"), // The library. | 106 contains("ERROR"), // That it's an error. |
| 113 contains("ERROR"), // That it's an error. | |
| 114 ])); | 107 ])); |
| 115 | 108 |
| 116 // In barback >=0.15.0, the span will point to the location where the error | 109 // In barback >=0.15.0, the span will point to the location where the error |
| 117 // occurred. | 110 // occurred. |
| 118 pub.stderr.expect(allow(inOrder(["d", "^"]))); | 111 pub.stderr.expect(allow(inOrder(["d", "^"]))); |
| 119 | 112 |
| 120 pub.stderr.expect("Build failed."); | 113 pub.stderr.expect("Build failed."); |
| 121 | 114 |
| 122 pub.shouldExit(exit_codes.DATA); | 115 pub.shouldExit(exit_codes.DATA); |
| 123 }); | 116 }); |
| 124 } | 117 } |
| OLD | NEW |