Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(272)

Side by Side Diff: sdk/lib/_internal/pub_generated/test/transformer/can_log_messages_test.dart

Issue 896623005: Use native async/await support in pub. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
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 import 'package:scheduled_test/scheduled_stream.dart';
9
10 import '../../lib/src/exit_codes.dart' as exit_codes;
11 import '../descriptor.dart' as d;
12 import '../test_pub.dart';
13
14 const SOURCE_MAPS_TRANSFORMER = """
15 import 'dart:async';
16
17 import 'package:barback/barback.dart';
18 import 'package:source_maps/source_maps.dart';
19
20 class RewriteTransformer extends Transformer {
21 RewriteTransformer.asPlugin();
22
23 String get allowedExtensions => '.txt';
24
25 Future apply(Transform transform) {
26 transform.logger.info('info!');
27 transform.logger.warning('Warning!',
28 asset: transform.primaryInput.id.changeExtension('.foo'));
29 var sourceFile = new SourceFile.text(
30 'http://fake.com/not_real.dart',
31 'not a real\\ndart file');
32 transform.logger.error('ERROR!', span: new FileSpan(sourceFile, 11));
33 return transform.primaryInput.readAsString().then((contents) {
34 var id = transform.primaryInput.id.changeExtension(".out");
35 transform.addOutput(new Asset.fromString(id, "\$contents.out"));
36 });
37 }
38 }
39 """;
40
41 const SOURCE_SPAN_TRANSFORMER = """
42 import 'dart:async';
43
44 import 'package:barback/barback.dart';
45 import 'package:source_span/source_span.dart';
46
47 class RewriteTransformer extends Transformer {
48 RewriteTransformer.asPlugin();
49
50 String get allowedExtensions => '.txt';
51
52 Future apply(Transform transform) {
53 transform.logger.info('info!');
54 transform.logger.warning('Warning!',
55 asset: transform.primaryInput.id.changeExtension('.foo'));
56 var sourceFile = new SourceFile('not a real\\ndart file',
57 url: 'http://fake.com/not_real.dart');
58 transform.logger.error('ERROR!', span: sourceFile.span(11, 12));
59 return transform.primaryInput.readAsString().then((contents) {
60 var id = transform.primaryInput.id.changeExtension(".out");
61 transform.addOutput(new Asset.fromString(id, "\$contents.out"));
62 });
63 }
64 }
65 """;
66
67 main() {
68 initConfig();
69 // This intentionally tests barback 0.14.2 with both transformers, since it
70 // supports both types of span.
71 withBarbackVersions("<0.15.0", () => runTest(SOURCE_MAPS_TRANSFORMER));
72 withBarbackVersions(">=0.14.2", () => runTest(SOURCE_SPAN_TRANSFORMER));
73 }
74
75 void runTest(String transformerText) {
76 integration("can log messages", () {
77 d.dir(appPath, [d.pubspec({
78 "name": "myapp",
79 "transformers": ["myapp/src/transformer"]
80 }),
81 d.dir("lib", [d.dir("src", [d.file("transformer.dart", transformerText )])]),
82 d.dir("web", [d.file("foo.txt", "foo")])]).create();
83
84 createLockFile('myapp', pkg: ['barback']);
85
86 var pub = startPub(args: ["build"]);
87 pub.stdout.expect(startsWith("Loading source assets..."));
88 pub.stdout.expect(consumeWhile(matches("Loading .* transformers...")));
89 pub.stdout.expect(startsWith("Building myapp..."));
90
91 pub.stdout.expect(emitsLines("""
92 [Rewrite on myapp|web/foo.txt]:
93 info!"""));
94
95 pub.stderr.expect(emitsLines("""
96 [Rewrite on myapp|web/foo.txt with input myapp|web/foo.foo]:
97 Warning!
98 [Rewrite on myapp|web/foo.txt]:"""));
99
100 // The details of the analyzer's error message change pretty frequently,
101 // so instead of validating the entire line, just look for a couple of
102 // salient bits of information.
103 pub.stderr.expect(allOf([contains("2"), // The line number.
104 contains("1"), // The column number.
105 contains("http://fake.com/not_real.dart"), // The library.
106 contains("ERROR"), // That it's an error.
107 ]));
108
109 // In barback >=0.15.0, the span will point to the location where the error
110 // occurred.
111 pub.stderr.expect(allow(inOrder(["d", "^"])));
112
113 pub.stderr.expect("Build failed.");
114
115 pub.shouldExit(exit_codes.DATA);
116 });
117 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698