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

Side by Side Diff: test/codegen_test.dart

Issue 1007313003: Move sunflower to a new directory, make final tweaks to make it all work. (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « test/codegen/sunflower/sunflower.html ('k') | test/sunflower/README.md » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 code generation. 5 /// Tests code generation.
6 /// Runs Dart Dev Compiler on all input in the `codegen` directory and checks 6 /// Runs Dart Dev Compiler on all input in the `codegen` directory and checks
7 /// that the output is what we expected. 7 /// that the output is what we expected.
8 library dev_compiler.test.codegen_test; 8 library dev_compiler.test.codegen_test;
9 9
10 import 'dart:io'; 10 import 'dart:io';
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 ? path.join(testDir, 'dart_codegen') 50 ? path.join(testDir, 'dart_codegen')
51 : path.join(testDir, 'codegen'); 51 : path.join(testDir, 'codegen');
52 var actualDir = path.join(inputDir, 'actual'); 52 var actualDir = path.join(inputDir, 'actual');
53 var paths = new Directory(inputDir) 53 var paths = new Directory(inputDir)
54 .listSync() 54 .listSync()
55 .where((f) => f is File) 55 .where((f) => f is File)
56 .map((f) => f.path) 56 .map((f) => f.path)
57 .where((p) => p.endsWith('.dart') && filePattern.hasMatch(p)); 57 .where((p) => p.endsWith('.dart') && filePattern.hasMatch(p));
58 58
59 compile(String entryPoint, String sdkPath, 59 compile(String entryPoint, String sdkPath,
60 {bool checkSdk: false, bool serverMode: false}) { 60 {bool checkSdk: false, bool serverMode: false, String subDir}) {
61 var runtimeDir = path.join( 61 var runtimeDir = path.join(
62 path.dirname(path.dirname(Platform.script.path)), 'lib', 'runtime'); 62 path.dirname(path.dirname(Platform.script.path)), 'lib', 'runtime');
63 var options = new CompilerOptions( 63 var options = new CompilerOptions(
64 outputDir: serverMode ? path.join(actualDir, 'server_mode') : actualDir, 64 outputDir: subDir == null ? actualDir : path.join(actualDir, subDir),
65 useColors: false, 65 useColors: false,
66 outputDart: dartGen, 66 outputDart: dartGen,
67 formatOutput: dartGen, 67 formatOutput: dartGen,
68 emitSourceMaps: false, 68 emitSourceMaps: false,
69 forceCompile: checkSdk, 69 forceCompile: checkSdk,
70 cheapTestFormat: checkSdk, 70 cheapTestFormat: checkSdk,
71 checkSdk: checkSdk, 71 checkSdk: checkSdk,
72 entryPointFile: entryPoint, 72 entryPointFile: entryPoint,
73 dartSdkPath: sdkPath, 73 dartSdkPath: sdkPath,
74 runtimeDir: runtimeDir, 74 runtimeDir: runtimeDir,
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 var outputDir = new Directory(path.join(actualDir, 'core')); 136 var outputDir = new Directory(path.join(actualDir, 'core'));
137 var outFile = dartGen 137 var outFile = dartGen
138 ? new File(path.join(actualDir, 'core/core')) 138 ? new File(path.join(actualDir, 'core/core'))
139 : new File(path.join(actualDir, 'dart/core.js')); 139 : new File(path.join(actualDir, 'dart/core.js'));
140 expect(outFile.existsSync(), true, 140 expect(outFile.existsSync(), true,
141 reason: '${outFile.path} was created for dart:core'); 141 reason: '${outFile.path} was created for dart:core');
142 }); 142 });
143 }); 143 });
144 144
145 if (!dartGen) { 145 if (!dartGen) {
146 test('devc jscodegen sunflower.html', () {
147 var filePath = path.join(inputDir, 'sunflower', 'sunflower.html');
148 compilerMessages.writeln('// Messages from compiling sunflower.html');
149
150 var result = compile(filePath, realSdk, subDir: 'sunflower');
151 var success = !result.failure;
152
153 // Write compiler messages to disk.
154 new File(path.join(actualDir, 'sunflower', 'sunflower.txt'))
155 .writeAsStringSync(compilerMessages.toString());
156
157 var expectedFiles = [
158 'sunflower.html',
159 'sunflower.js',
160 'sunflower.css',
161 'math.png',
162 'dev_compiler/runtime/dart_core.js',
163 'dev_compiler/runtime/dart_runtime.js',
164 'dev_compiler/runtime/harmony_feature_check.js',
165 ];
166 for (var filepath in expectedFiles) {
167 var outFile = new File(path.join(actualDir, 'sunflower', filepath));
168 expect(outFile.existsSync(), success,
169 reason: '${outFile.path} was created iff compilation succeeds');
170 }
171 });
172
146 test('devc jscodegen html_input.html', () { 173 test('devc jscodegen html_input.html', () {
147 var filePath = path.join(inputDir, 'html_input.html'); 174 var filePath = path.join(inputDir, 'html_input.html');
148 compilerMessages.writeln('// Messages from compiling html_input.html'); 175 compilerMessages.writeln('// Messages from compiling html_input.html');
149 176
150 var result = compile(filePath, realSdk); 177 var result = compile(filePath, realSdk);
151 var success = !result.failure; 178 var success = !result.failure;
152 179
153 // Write compiler messages to disk. 180 // Write compiler messages to disk.
154 new File(path.join(actualDir, 'html_input.txt')) 181 new File(path.join(actualDir, 'html_input.txt'))
155 .writeAsStringSync(compilerMessages.toString()); 182 .writeAsStringSync(compilerMessages.toString());
(...skipping 23 matching lines...) Expand all
179 var outFile = new File(path.join(actualDir, filepath)); 206 var outFile = new File(path.join(actualDir, filepath));
180 expect(outFile.existsSync(), isFalse, 207 expect(outFile.existsSync(), isFalse,
181 reason: '${outFile.path} should only be generated in server mode'); 208 reason: '${outFile.path} should only be generated in server mode');
182 } 209 }
183 }); 210 });
184 211
185 test('devc jscodegen html_input.html server mode', () { 212 test('devc jscodegen html_input.html server mode', () {
186 var filePath = path.join(inputDir, 'html_input.html'); 213 var filePath = path.join(inputDir, 'html_input.html');
187 compilerMessages.writeln('// Messages from compiling html_input.html'); 214 compilerMessages.writeln('// Messages from compiling html_input.html');
188 215
189 var result = compile(filePath, realSdk, serverMode: true); 216 var result =
217 compile(filePath, realSdk, serverMode: true, subDir: 'server_mode');
190 var success = !result.failure; 218 var success = !result.failure;
191 219
192 // Write compiler messages to disk. 220 // Write compiler messages to disk.
193 new File(path.join(actualDir, 'server_mode', 'html_input.txt')) 221 new File(path.join(actualDir, 'server_mode', 'html_input.txt'))
194 .writeAsStringSync(compilerMessages.toString()); 222 .writeAsStringSync(compilerMessages.toString());
195 223
196 var expectedFiles = [ 224 var expectedFiles = [
197 'html_input.html', 225 'html_input.html',
198 'dir/html_input_a.js', 226 'dir/html_input_a.js',
199 'dir/html_input_b.js', 227 'dir/html_input_b.js',
(...skipping 21 matching lines...) Expand all
221 print('[AnalysisEngine] error $message $exception'); 249 print('[AnalysisEngine] error $message $exception');
222 } 250 }
223 251
224 @override void logError2(String message, Object exception) { 252 @override void logError2(String message, Object exception) {
225 print('[AnalysisEngine] error $message $exception'); 253 print('[AnalysisEngine] error $message $exception');
226 } 254 }
227 255
228 void logInformation(String message, [CaughtException exception]) {} 256 void logInformation(String message, [CaughtException exception]) {}
229 void logInformation2(String message, Object exception) {} 257 void logInformation2(String message, Object exception) {}
230 } 258 }
OLDNEW
« no previous file with comments | « test/codegen/sunflower/sunflower.html ('k') | test/sunflower/README.md » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698