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

Side by Side Diff: test/report_test.dart

Issue 1235503010: fixes #219, able to compile multiple entry points (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 5 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
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS 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 /// Tests for summary reporting. 5 /// Tests for summary reporting.
6 library dev_compiler.test.report_test; 6 library dev_compiler.test.report_test;
7 7
8 import 'package:test/test.dart'; 8 import 'package:test/test.dart';
9 9
10 import 'package:dev_compiler/devc.dart'; 10 import 'package:dev_compiler/devc.dart';
11 import 'package:dev_compiler/strong_mode.dart' show StrongModeOptions; 11 import 'package:dev_compiler/strong_mode.dart' show StrongModeOptions;
12 12
13 import 'package:dev_compiler/src/analysis_context.dart'; 13 import 'package:dev_compiler/src/analysis_context.dart';
14 import 'package:dev_compiler/src/options.dart'; 14 import 'package:dev_compiler/src/options.dart';
15 import 'package:dev_compiler/src/report.dart'; 15 import 'package:dev_compiler/src/report.dart';
16 import 'package:dev_compiler/src/summary.dart'; 16 import 'package:dev_compiler/src/summary.dart';
17 import 'package:dev_compiler/src/testing.dart'; 17
18 import 'testing.dart';
18 19
19 void main() { 20 void main() {
20 test('toJson/parse', () { 21 test('toJson/parse', () {
21 var files = { 22 var files = {
22 '/main.dart': ''' 23 '/main.dart': '''
23 import 'package:foo/bar.dart'; 24 import 'package:foo/bar.dart';
24 25
25 test1() { 26 test1() {
26 x = /*severe:StaticTypeError*/"hi"; 27 x = /*severe:StaticTypeError*/"hi";
27 } 28 }
28 '''.replaceAll('\n ', '\n'), 29 '''.replaceAll('\n ', '\n'),
29 'package:foo/bar.dart': ''' 30 'package:foo/bar.dart': '''
30 num x; 31 num x;
31 test2() { 32 test2() {
32 int y = /*info:AssignmentCast*/x; 33 int y = /*info:AssignmentCast*/x;
33 } 34 }
34 '''.replaceAll('\n ', '\n'), 35 '''.replaceAll('\n ', '\n'),
35 }; 36 };
36 37
37 var provider = createTestResourceProvider(files); 38 var provider = createTestResourceProvider(files);
38 var uriResolver = new TestUriResolver(provider); 39 var uriResolver = new TestUriResolver(provider);
39 var srcOpts = new SourceResolverOptions( 40 var srcOpts = new SourceResolverOptions(useMockSdk: true);
40 entryPointFile: '/main.dart', useMockSdk: true);
41 var context = createAnalysisContextWithSources( 41 var context = createAnalysisContextWithSources(
42 new StrongModeOptions(), srcOpts, fileResolvers: [uriResolver]); 42 new StrongModeOptions(), srcOpts, fileResolvers: [uriResolver]);
43 var reporter = new SummaryReporter(context); 43 var reporter = new SummaryReporter(context);
44 new Compiler(new CompilerOptions(sourceOptions: srcOpts), 44 new BatchCompiler(context, new CompilerOptions(sourceOptions: srcOpts),
45 context: context, reporter: reporter).run(); 45 reporter: reporter).compileFromUriString('/main.dart');
46 46
47 _verifySummary(GlobalSummary summary) { 47 _verifySummary(GlobalSummary summary) {
48 var mainLib = summary.loose['file:///main.dart']; 48 var mainLib = summary.loose['file:///main.dart'];
49 expect(mainLib.messages.length, 2); 49 expect(mainLib.messages.length, 2);
50 var analyzerMsg = mainLib.messages[0]; 50 var analyzerMsg = mainLib.messages[0];
51 expect(analyzerMsg.kind, "AnalyzerMessage"); 51 expect(analyzerMsg.kind, "AnalyzerMessage");
52 52
53 var mainMessage = mainLib.messages[1]; 53 var mainMessage = mainLib.messages[1];
54 expect(mainMessage.kind, "StaticTypeError"); 54 expect(mainMessage.kind, "StaticTypeError");
55 expect(mainMessage.level, "error"); 55 expect(mainMessage.level, "error");
56 expect(mainMessage.span.text, '"hi"'); 56 expect(mainMessage.span.text, '"hi"');
57 expect( 57 expect(
58 mainMessage.span.context, ' x = /*severe:StaticTypeError*/"hi";\n'); 58 mainMessage.span.context, ' x = /*severe:StaticTypeError*/"hi";\n');
59 59
60 var barLib = summary.packages['foo'].libraries['package:foo/bar.dart']; 60 var barLib = summary.packages['foo'].libraries['package:foo/bar.dart'];
61 expect(barLib.messages.length, 1); 61 expect(barLib.messages.length, 1);
62 var barMessage = barLib.messages[0]; 62 var barMessage = barLib.messages[0];
63 expect(barMessage.kind, "AssignmentCast"); 63 expect(barMessage.kind, "AssignmentCast");
64 expect(barMessage.level, "info"); 64 expect(barMessage.level, "info");
65 expect(barMessage.span.text, 'x'); 65 expect(barMessage.span.text, 'x');
66 expect(barMessage.span.context, ' int y = /*info:AssignmentCast*/x;\n'); 66 expect(barMessage.span.context, ' int y = /*info:AssignmentCast*/x;\n');
67 } 67 }
68 68
69 var original = reporter.result; 69 var original = reporter.result;
70 _verifySummary(original); 70 _verifySummary(original);
71 _verifySummary(GlobalSummary.parse(original.toJsonMap())); 71 _verifySummary(GlobalSummary.parse(original.toJsonMap()));
72 }); 72 });
73 } 73 }
OLDNEW
« lib/src/summary.dart ('K') | « test/end_to_end_test.dart ('k') | test/test_util.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698