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

Side by Side Diff: test/codegen_test.dart

Issue 1013223002: coverage: increase coverage of js_codegen (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/map_keys.dart ('k') | no next file » | 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, bool sourceMaps: false}) {
61 // TODO(jmesserly): add a way to specify flags in the test file, so
62 // they're more self-contained.
61 var options = new CompilerOptions( 63 var options = new CompilerOptions(
62 outputDir: serverMode ? path.join(actualDir, 'server_mode') : actualDir, 64 outputDir: serverMode ? path.join(actualDir, 'server_mode') : actualDir,
63 useColors: false, 65 useColors: false,
64 outputDart: dartGen, 66 outputDart: dartGen,
65 formatOutput: dartGen, 67 formatOutput: dartGen,
66 emitSourceMaps: false, 68 emitSourceMaps: sourceMaps,
67 forceCompile: checkSdk, 69 forceCompile: checkSdk,
68 cheapTestFormat: checkSdk, 70 cheapTestFormat: checkSdk,
69 checkSdk: checkSdk, 71 checkSdk: checkSdk,
70 entryPointFile: entryPoint, 72 entryPointFile: entryPoint,
71 dartSdkPath: sdkPath, 73 dartSdkPath: sdkPath,
72 serverMode: serverMode); 74 serverMode: serverMode);
73 return new Compiler(options).run(); 75 return new Compiler(options).run();
74 } 76 }
75 var realSdk = getSdkDir(arguments).path; 77 var realSdk = getSdkDir(arguments).path;
76 78
77 // Validate that old output is gone before running. 79 // Validate that old output is gone before running.
78 // TODO(jmesserly): it'd be nice to do all cleanup here, including removing 80 // TODO(jmesserly): it'd be nice to do all cleanup here, including removing
79 // pub's 'packages' symlinks which mess up the diff. That way this test 81 // pub's 'packages' symlinks which mess up the diff. That way this test
80 // can be self contained instead of depending on a shell script. 82 // can be self contained instead of depending on a shell script.
81 if (new Directory(actualDir).existsSync()) { 83 if (new Directory(actualDir).existsSync()) {
82 throw 'Old compiler output should be cleaned up first. Use ./test/test.sh'; 84 throw 'Old compiler output should be cleaned up first. Use ./test/test.sh';
83 } 85 }
84 86
85 for (var filePath in paths) { 87 for (var filePath in paths) {
86 var filename = path.basenameWithoutExtension(filePath); 88 var filename = path.basenameWithoutExtension(filePath);
87 89
88 test('devc $filename.dart', () { 90 test('devc $filename.dart', () {
89 compilerMessages.writeln('// Messages from compiling $filename.dart'); 91 compilerMessages.writeln('// Messages from compiling $filename.dart');
90 92
91 var result = compile(filePath, realSdk); 93 // TODO(jmesserly): this was added to get some coverage of source maps
94 // We need a more comprehensive strategy to test them.
Siggi Cherem (dart-lang) 2015/03/18 16:16:13 how about detecting if there is one .map file in t
Jennifer Messerly 2015/03/18 16:17:53 that's a really good idea. I also thought about ha
95 var sourceMaps = filename == 'map_keys';
96 var result = compile(filePath, realSdk, sourceMaps: sourceMaps);
92 var success = !result.failure; 97 var success = !result.failure;
93 98
94 // Write compiler messages to disk. 99 // Write compiler messages to disk.
95 new File(path.join(actualDir, '$filename.txt')) 100 new File(path.join(actualDir, '$filename.txt'))
96 .writeAsStringSync(compilerMessages.toString()); 101 .writeAsStringSync(compilerMessages.toString());
97 102
98 var outFile = dartGen 103 var outFile = dartGen
99 ? new File(path.join(actualDir, '$filename/$filename.dart')) 104 ? new File(path.join(actualDir, '$filename/$filename.dart'))
100 : new File(path.join(actualDir, '$filename.js')); 105 : new File(path.join(actualDir, '$filename.js'));
101 expect(outFile.existsSync(), success, 106 expect(outFile.existsSync(), success,
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 print('[AnalysisEngine] error $message $exception'); 223 print('[AnalysisEngine] error $message $exception');
219 } 224 }
220 225
221 @override void logError2(String message, Object exception) { 226 @override void logError2(String message, Object exception) {
222 print('[AnalysisEngine] error $message $exception'); 227 print('[AnalysisEngine] error $message $exception');
223 } 228 }
224 229
225 void logInformation(String message, [CaughtException exception]) {} 230 void logInformation(String message, [CaughtException exception]) {}
226 void logInformation2(String message, Object exception) {} 231 void logInformation2(String message, Object exception) {}
227 } 232 }
OLDNEW
« no previous file with comments | « test/codegen/map_keys.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698