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

Side by Side Diff: pkg/dev_compiler/test/codegen_test.dart

Issue 2991073002: remove unittest as a test status, instead record this at test build time (Closed)
Patch Set: cleanup import Created 3 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
« no previous file with comments | « pkg/dev_compiler/test/browser/language_tests.js ('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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 /// 6 ///
7 /// Runs Dart Dev Compiler on all input in the `codegen` directory and checks 7 /// Runs Dart Dev Compiler on all input in the `codegen` directory and checks
8 /// that the output is what we expected. 8 /// that the output is what we expected.
9 library dev_compiler.test.codegen_test; 9 library dev_compiler.test.codegen_test;
10 10
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 var exception, stackTrace; 159 var exception, stackTrace;
160 try { 160 try {
161 module = compiler.compile(unit, options); 161 module = compiler.compile(unit, options);
162 } catch (e, st) { 162 } catch (e, st) {
163 exception = e; 163 exception = e;
164 stackTrace = st; 164 stackTrace = st;
165 } 165 }
166 166
167 // This covers tests where the intent of the test is to validate that 167 // This covers tests where the intent of the test is to validate that
168 // some static error is produced. 168 // some static error is produced.
169 var intentionalCompileError = 169 var intentionalCompileError = contents.contains(': compile-time error') ||
170 contents.contains(': compile-time error') || 170 contents.contains('/*@compile-error=');
171 contents.contains('/*@compile-error=');
172 171
173 // This covers tests that should not produce a static error but that 172 // This covers tests that should not produce a static error but that
174 // currently do due to issues in our implementation. 173 // currently do due to issues in our implementation.
175 var knownCompileError = compileErrorTests.contains(name); 174 var knownCompileError = compileErrorTests.contains(name);
176 175
177 var crashing = _crashingTests.contains(name); 176 var crashing = _crashingTests.contains(name);
178 var inconsistent = _inconsistentTests.contains(name); 177 var inconsistent = _inconsistentTests.contains(name);
179 178
180 if (module == null) { 179 if (module == null) {
181 expect(crashing, isTrue, 180 expect(crashing, isTrue,
(...skipping 14 matching lines...) Expand all
196 if (inconsistent) { 195 if (inconsistent) {
197 // An inconsistent test will only compile on some platforms (see 196 // An inconsistent test will only compile on some platforms (see
198 // comment below). It should not crash however. 197 // comment below). It should not crash however.
199 } else if (module.isValid) { 198 } else if (module.isValid) {
200 // TODO(vsm): We don't seem to trip on non-strong errors? 199 // TODO(vsm): We don't seem to trip on non-strong errors?
201 // expect(expectedCompileTimeError, isFalse, 200 // expect(expectedCompileTimeError, isFalse,
202 // reason: "test $name expected compilation errors, but compiled."); 201 // reason: "test $name expected compilation errors, but compiled.");
203 expect(knownCompileError, isFalse, 202 expect(knownCompileError, isFalse,
204 reason: "test $name expected static errors, but compiled."); 203 reason: "test $name expected static errors, but compiled.");
205 } else { 204 } else {
206 var reason = intentionalCompileError 205 var reason = intentionalCompileError ? "intended" : "unexpected";
207 ? "intended"
208 : "unexpected";
209 expect(intentionalCompileError || knownCompileError, isTrue, 206 expect(intentionalCompileError || knownCompileError, isTrue,
210 reason: "test $name failed to compile due to $reason errors:" 207 reason: "test $name failed to compile due to $reason errors:"
211 "\n\n${module.errors.join('\n')}."); 208 "\n\n${module.errors.join('\n')}.");
212 } 209 }
213 }); 210 });
214 } 211 }
215 212
216 if (filePattern.hasMatch('sunflower')) { 213 if (filePattern.hasMatch('sunflower')) {
217 test('sunflower', () { 214 test('sunflower', () {
218 _buildSunflower(sharedCompiler, codegenOutputDir, codegenExpectDir); 215 _buildSunflower(sharedCompiler, codegenOutputDir, codegenExpectDir);
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 path.join(testDirectory, '..', '..', '..', 'tests', sdkTestDir); 293 path.join(testDirectory, '..', '..', '..', 'tests', sdkTestDir);
297 294
298 if (!new Directory(inputPath).existsSync()) continue; 295 if (!new Directory(inputPath).existsSync()) continue;
299 296
300 for (var file in _listFiles(inputPath, recursive: true)) { 297 for (var file in _listFiles(inputPath, recursive: true)) {
301 var relativePath = path.relative(file, from: inputPath); 298 var relativePath = path.relative(file, from: inputPath);
302 var outputPath = path.join(codegenTestDir, testDir, relativePath); 299 var outputPath = path.join(codegenTestDir, testDir, relativePath);
303 300
304 _ensureDirectory(path.dirname(outputPath)); 301 _ensureDirectory(path.dirname(outputPath));
305 302
306 // Copy it over. We do this even for multitests because import_self_test 303 if (file.endsWith("_test.dart")) {
307 // is a multitest, yet imports its own unexpanded form (!).
308 new File(file).copySync(outputPath);
309 304
310 if (file.endsWith("_test.dart")) { 305 void _writeTest(String outputPath, String contents) {
306 if (contents.contains('package:unittest/')) {
307 // TODO(jmesserly): we could use directive parsing, but that
308 // feels like overkill.
309 // Alternatively, we could detect "unittest" use at runtime.
310 // We really need a better solution for Karma+mocha+unittest
311 // integration.
312 contents += '\nfinal _usesUnittestPackage = true;\n';
313 }
314 new File(outputPath).writeAsStringSync(contents);
315 }
316
311 var contents = new File(file).readAsStringSync(); 317 var contents = new File(file).readAsStringSync();
312
313 if (isMultiTest(contents)) { 318 if (isMultiTest(contents)) {
314 // It's a multitest, so expand it and add all of the variants. 319 // It's a multitest, so expand it and add all of the variants.
315 var tests = <String, String>{}; 320 var tests = <String, String>{};
316 var outcomes = <String, Set<String>>{}; 321 var outcomes = <String, Set<String>>{};
317 extractTestsFromMultitest(file, contents, tests, outcomes); 322 extractTestsFromMultitest(file, contents, tests, outcomes);
318 323
319 var fileName = path.basenameWithoutExtension(file); 324 var fileName = path.basenameWithoutExtension(file);
320 var outputDir = path.dirname(outputPath); 325 var outputDir = path.dirname(outputPath);
321 tests.forEach((name, contents) { 326 tests.forEach((name, contents) {
322 var multiFile = 327 var multiFile =
323 path.join(outputDir, '${fileName}_${name}_multi.dart'); 328 path.join(outputDir, '${fileName}_${name}_multi.dart');
324 testFiles.add(multiFile); 329 testFiles.add(multiFile);
325 330
326 new File(multiFile).writeAsStringSync(contents); 331 _writeTest(multiFile, contents);
327 }); 332 });
328 } else { 333 } else {
329 // It's a single test suite. 334 // It's a single test suite.
330 testFiles.add(outputPath); 335 testFiles.add(outputPath);
331 } 336 }
337
338 // Write the test file.
339 //
340 // We do this even for multitests because import_self_test
341 // is a multitest, yet imports its own unexpanded form (!).
342 _writeTest(outputPath, contents);
343
344 } else {
345 // Copy the non-test file over, in case it is used as an import.
346 new File(file).copySync(outputPath);
332 } 347 }
333 } 348 }
334 } 349 }
335 } 350 }
336 351
337 // Also include the other special files that live at the top level directory. 352 // Also include the other special files that live at the top level directory.
338 for (var file in _listFiles(codegenDir)) { 353 for (var file in _listFiles(codegenDir)) {
339 var relativePath = path.relative(file, from: codegenDir); 354 var relativePath = path.relative(file, from: codegenDir);
340 var outputPath = path.join(codegenTestDir, relativePath); 355 var outputPath = path.join(codegenTestDir, relativePath);
341 356
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 final _crashingTests = new Set<String>.from([ 436 final _crashingTests = new Set<String>.from([
422 // TODO(vsm): Fix these - they import files from a different directory 437 // TODO(vsm): Fix these - they import files from a different directory
423 // - this triggers an invalid library root build error. 438 // - this triggers an invalid library root build error.
424 'lib/html/custom/attribute_changed_callback_test', 439 'lib/html/custom/attribute_changed_callback_test',
425 'lib/html/custom/constructor_calls_created_synchronously_test', 440 'lib/html/custom/constructor_calls_created_synchronously_test',
426 'lib/html/custom/entered_left_view_test', 441 'lib/html/custom/entered_left_view_test',
427 'lib/html/custom/js_custom_test', 442 'lib/html/custom/js_custom_test',
428 'lib/html/custom/mirrors_test', 443 'lib/html/custom/mirrors_test',
429 'lib/html/custom/regress_194523002_test', 444 'lib/html/custom/regress_194523002_test',
430 ].map((p) => p.replaceAll('/', path.separator))); 445 ].map((p) => p.replaceAll('/', path.separator)));
OLDNEW
« no previous file with comments | « pkg/dev_compiler/test/browser/language_tests.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698