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

Side by Side Diff: pkg/polymer/test/build/script_compactor_test.dart

Issue 427623002: Polymer transformer logs now show on the frontend for pub serve. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: added tests for the log widget Created 6 years, 4 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
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 library polymer.test.build.script_compactor_test; 5 library polymer.test.build.script_compactor_test;
6 6
7 import 'dart:convert';
8
7 import 'package:code_transformers/tests.dart' show testingDartSdkDirectory; 9 import 'package:code_transformers/tests.dart' show testingDartSdkDirectory;
8 import 'package:polymer/src/build/common.dart'; 10 import 'package:polymer/src/build/common.dart';
9 import 'package:polymer/src/build/script_compactor.dart'; 11 import 'package:polymer/src/build/script_compactor.dart';
10 import 'package:smoke/codegen/generator.dart' show DEFAULT_IMPORTS; 12 import 'package:smoke/codegen/generator.dart' show DEFAULT_IMPORTS;
11 import 'package:unittest/compact_vm_config.dart'; 13 import 'package:unittest/compact_vm_config.dart';
12 import 'package:unittest/unittest.dart'; 14 import 'package:unittest/unittest.dart';
13 15
14 import 'common.dart'; 16 import 'common.dart';
15 17
16 void main() { 18 void main() {
17 useCompactVMConfiguration(); 19 useCompactVMConfiguration();
18 var phases = [[new ScriptCompactor(new TransformOptions(), 20 var phases = [[new ScriptCompactor(new TransformOptions(),
19 sdkDir: testingDartSdkDirectory)]]; 21 sdkDir: testingDartSdkDirectory)]];
20 group('initializers', () => initializerTests(phases)); 22 group('initializers', () => initializerTests(phases));
21 group('experimental', () => initializerTestsExperimental(phases)); 23 group('experimental', () => initializerTestsExperimental(phases));
22 group('codegen', () => codegenTests(phases)); 24 group('codegen', () => codegenTests(phases));
25 group('output logs', logOutputTests);
23 } 26 }
24 27
25 initializerTests(phases) { 28 initializerTests(phases) {
26 testPhases('no changes', phases, { 29 testPhases('no changes', phases, {
27 'a|web/test.html': '<!DOCTYPE html><html></html>', 30 'a|web/test.html': '<!DOCTYPE html><html></html>',
28 'a|web/test.html._data': EMPTY_DATA, 31 'a|web/test.html._data': EMPTY_DATA,
29 }, { 32 }, {
30 'a|web/test.html': '<!DOCTYPE html><html></html>', 33 'a|web/test.html': '<!DOCTYPE html><html></html>',
31 }); 34 });
32 35
(...skipping 1053 matching lines...) Expand 10 before | Expand all | Expand 10 after
1086 })); 1089 }));
1087 configureForDeployment([ 1090 configureForDeployment([
1088 () => Polymer.register(\'x-foo\', i0.XFoo), 1091 () => Polymer.register(\'x-foo\', i0.XFoo),
1089 ]); 1092 ]);
1090 i0.main(); 1093 i0.main();
1091 } 1094 }
1092 '''.replaceAll('\n ', '\n'), 1095 '''.replaceAll('\n ', '\n'),
1093 }); 1096 });
1094 } 1097 }
1095 1098
1099 void logOutputTests() {
1100 final outputLogsPhases = [[new ScriptCompactor(
1101 new TransformOptions(injectBuildLogsInOutput: true),
1102 sdkDir: testingDartSdkDirectory)]];
1103
1104 testPhases("logs are output and converted to warnings", outputLogsPhases, {
1105 'a|web/test.html': '<!DOCTYPE html><html><head>',
1106 'a|web/test.html._data': expectedData(['web/a.dart'], experimental: true),
1107 'a|web/a.dart':
1108 'library a;\n'
1109 'import "package:polymer/polymer.broken.import.dart";\n'
1110 '@CustomTag("x-foo")\n'
1111 'class XFoo extends PolymerElement {\n}\n'
1112 'main(){}',
1113 }, {
1114 'a|web/test.html._buildLogs.1':
1115 '[{'
1116 '"level":"Warning",'
1117 '"message":"$NO_INITIALIZERS_ERROR"'
1118 '}]',
1119 }, [
1120 'warning: $NO_INITIALIZERS_ERROR',
1121 ]);
1122
1123 testPhases('Injects logging element and styles', outputLogsPhases, {
1124 'a|web/test.html': '<!DOCTYPE html><html><head>',
1125 'a|web/test.html._data': expectedData(['web/a.dart']),
1126 'a|web/a.dart':
1127 'library a;\n'
1128 'import "package:polymer/polymer.dart";\n'
1129 'main(){}',
1130 }, {
1131 'a|web/test.html':
1132 '<!DOCTYPE html><html><head>'
1133 '<link rel="stylesheet" type="text/css" '
1134 'href="packages/polymer/src/build/log_injector.css">'
1135 '</head><body>'
1136 '<script type="application/dart" '
1137 'src="test.html_bootstrap.dart"></script>'
1138 '</body></html>',
1139 'a|web/test.html_bootstrap.dart':
1140 '''$MAIN_HEADER
1141 import 'a.dart' as i0;
1142 import 'package:polymer/src/build/log_injector.dart';
1143 ${DEFAULT_IMPORTS.join('\n')}
1144
1145 void main() {
1146 useGeneratedCode(new StaticConfiguration(
1147 checkedMode: false));
1148 new LogInjector().injectLogs();
1149 configureForDeployment([]);
1150 i0.main();
1151 }
1152 '''.replaceAll('\n ', '\n'),
1153 'a|web/a.dart':
1154 'library a;\n'
1155 'import "package:polymer/polymer.dart";\n'
1156 'main(){}',
1157 });
1158 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698