| OLD | NEW |
| 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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 } | 158 } |
| 159 JSModuleFile module = null; | 159 JSModuleFile module = null; |
| 160 var exception, stackTrace; | 160 var exception, stackTrace; |
| 161 try { | 161 try { |
| 162 module = compiler.compile(unit, options); | 162 module = compiler.compile(unit, options); |
| 163 } catch (e, st) { | 163 } catch (e, st) { |
| 164 exception = e; | 164 exception = e; |
| 165 stackTrace = st; | 165 stackTrace = st; |
| 166 } | 166 } |
| 167 | 167 |
| 168 bool expectedCompileTimeError = | 168 bool expectedCompileTimeError = contents.contains(': compile-time error'); |
| 169 contents.contains(': compile-time error\n'); | |
| 170 bool notStrong = notYetStrongTests.contains(name); | 169 bool notStrong = notYetStrongTests.contains(name); |
| 171 bool crashing = _crashingTests.contains(name); | 170 bool crashing = _crashingTests.contains(name); |
| 171 bool inconsistent = _inconsistentTests.contains(name); |
| 172 | 172 |
| 173 if (module == null) { | 173 if (module == null) { |
| 174 expect(crashing, isTrue, | 174 expect(crashing, isTrue, |
| 175 reason: "test $name crashes during compilation.\n" | 175 reason: "test $name crashes during compilation.\n" |
| 176 "$exception\n$stackTrace"); | 176 "$exception\n$stackTrace"); |
| 177 } else if (inconsistent) { |
| 178 // An inconsistent test will only compile on some platforms (see |
| 179 // comment below). It should not crash however. |
| 180 expect(crashing, isFalse, reason: "test $name no longer crashes."); |
| 177 } else if (module.isValid) { | 181 } else if (module.isValid) { |
| 178 _writeModule( | 182 _writeModule( |
| 179 path.join(codegenOutputDir, name), | 183 path.join(codegenOutputDir, name), |
| 180 isTopLevelTest ? path.join(codegenExpectDir, name) : null, | 184 isTopLevelTest ? path.join(codegenExpectDir, name) : null, |
| 181 moduleFormat, | 185 moduleFormat, |
| 182 module); | 186 module); |
| 183 | 187 |
| 184 expect(crashing, isFalse, reason: "test $name no longer crashes."); | 188 expect(crashing, isFalse, reason: "test $name no longer crashes."); |
| 185 // TODO(vsm): We don't seem to trip on non-strong errors? | 189 // TODO(vsm): We don't seem to trip on non-strong errors? |
| 186 // expect(expectedCompileTimeError, isFalse, | 190 // expect(expectedCompileTimeError, isFalse, |
| 187 // reason: "test $name expected compilation errors, but compiled."); | 191 // reason: "test $name expected compilation errors, but compiled."); |
| 188 expect(notStrong, isFalse, | 192 expect(notStrong, isFalse, |
| 189 reason: "test $name expected strong mode errors, but compiled."); | 193 reason: "test $name expected strong mode errors, but compiled."); |
| 190 } else { | 194 } else { |
| 191 expect(crashing, isFalse, reason: "test $name no longer crashes."); | 195 expect(crashing, isFalse, reason: "test $name no longer crashes."); |
| 192 var reason = | 196 var reason = expectedCompileTimeError |
| 193 expectedCompileTimeError ? "expected" : "untriaged strong mode"; | 197 ? "expected" |
| 194 expect(expectedCompileTimeError || notStrong, isTrue, | 198 : inconsistent ? "platform consistency" : "untriaged strong mode"; |
| 199 expect(expectedCompileTimeError || inconsistent || notStrong, isTrue, |
| 195 reason: "test $name failed to compile due to $reason errors:" | 200 reason: "test $name failed to compile due to $reason errors:" |
| 196 "\n\n${module.errors.join('\n')}."); | 201 "\n\n${module.errors.join('\n')}."); |
| 197 } | 202 } |
| 198 }); | 203 }); |
| 199 } | 204 } |
| 200 | 205 |
| 201 if (filePattern.hasMatch('sunflower')) { | 206 if (filePattern.hasMatch('sunflower')) { |
| 202 test('sunflower', () { | 207 test('sunflower', () { |
| 203 _buildSunflower(sharedCompiler, codegenOutputDir, codegenExpectDir); | 208 _buildSunflower(sharedCompiler, codegenOutputDir, codegenExpectDir); |
| 204 }); | 209 }); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 | 269 |
| 265 List<String> _setUpTests(List<String> testDirs) { | 270 List<String> _setUpTests(List<String> testDirs) { |
| 266 var testFiles = <String>[]; | 271 var testFiles = <String>[]; |
| 267 | 272 |
| 268 for (var testDir in testDirs) { | 273 for (var testDir in testDirs) { |
| 269 // Look for the tests in the "_strong" directories in the SDK's main | 274 // Look for the tests in the "_strong" directories in the SDK's main |
| 270 // "tests" directory. | 275 // "tests" directory. |
| 271 var dirParts = path.split(testDir); | 276 var dirParts = path.split(testDir); |
| 272 var sdkTestDir = | 277 var sdkTestDir = |
| 273 path.join(dirParts[0] + "_strong", path.joinAll(dirParts.skip(1))); | 278 path.join(dirParts[0] + "_strong", path.joinAll(dirParts.skip(1))); |
| 274 var inputPath = path.join(testDirectory, '../../../tests/', sdkTestDir); | 279 var inputPath = |
| 280 path.join(testDirectory, '..', '..', '..', 'tests', sdkTestDir); |
| 275 | 281 |
| 276 for (var file in _listFiles(inputPath, recursive: true)) { | 282 for (var file in _listFiles(inputPath, recursive: true)) { |
| 277 var relativePath = path.relative(file, from: inputPath); | 283 var relativePath = path.relative(file, from: inputPath); |
| 278 var outputPath = path.join(codegenTestDir, testDir, relativePath); | 284 var outputPath = path.join(codegenTestDir, testDir, relativePath); |
| 279 | 285 |
| 280 _ensureDirectory(path.dirname(outputPath)); | 286 _ensureDirectory(path.dirname(outputPath)); |
| 281 | 287 |
| 282 // Copy it over. We do this even for multitests because import_self_test | 288 // Copy it over. We do this even for multitests because import_self_test |
| 283 // is a multitest, yet imports its own unexpanded form (!). | 289 // is a multitest, yet imports its own unexpanded form (!). |
| 284 new File(file).copySync(outputPath); | 290 new File(file).copySync(outputPath); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 String uriContent = uriLiteral.stringValue; | 385 String uriContent = uriLiteral.stringValue; |
| 380 if (uriContent != null) { | 386 if (uriContent != null) { |
| 381 uriContent = uriContent.trim(); | 387 uriContent = uriContent.trim(); |
| 382 directive.uriContent = uriContent; | 388 directive.uriContent = uriContent; |
| 383 } | 389 } |
| 384 return (directive as UriBasedDirectiveImpl).validate() == null | 390 return (directive as UriBasedDirectiveImpl).validate() == null |
| 385 ? uriContent | 391 ? uriContent |
| 386 : null; | 392 : null; |
| 387 } | 393 } |
| 388 | 394 |
| 395 /// Tests that, due to bugs, are strong-mode clean only on some platforms. |
| 396 final _inconsistentTests = new Set<String>.from([ |
| 397 // This test is clean on windows, but not linux/mac due to newline encoding. |
| 398 // See: https://github.com/dart-lang/sdk/issues/27224 |
| 399 'language/multiline_newline_test_02_multi', |
| 400 ].map((p) => p.replaceAll('/', path.separator))); |
| 401 |
| 389 final _crashingTests = new Set<String>.from([ | 402 final _crashingTests = new Set<String>.from([ |
| 390 'language/generic_methods_generic_class_tearoff_test', | 403 'language/generic_methods_generic_class_tearoff_test', |
| 391 'language/generic_methods_named_parameters_test', | 404 'language/generic_methods_named_parameters_test', |
| 392 'language/generic_methods_optional_parameters_test', | 405 'language/generic_methods_optional_parameters_test', |
| 393 'language/generic_methods_tearoff_specialization_test', | 406 'language/generic_methods_tearoff_specialization_test', |
| 394 'language/generic_methods_unused_parameter_test', | 407 'language/generic_methods_unused_parameter_test', |
| 395 | 408 |
| 396 // TODO(vsm): Fix these - they import files from a different directory | 409 // TODO(vsm): Fix these - they import files from a different directory |
| 397 // - this triggers an invalid library root build error. | 410 // - this triggers an invalid library root build error. |
| 398 'lib/html/custom/attribute_changed_callback_test', | 411 'lib/html/custom/attribute_changed_callback_test', |
| 399 'lib/html/custom/constructor_calls_created_synchronously_test', | 412 'lib/html/custom/constructor_calls_created_synchronously_test', |
| 400 'lib/html/custom/entered_left_view_test', | 413 'lib/html/custom/entered_left_view_test', |
| 401 'lib/html/custom/js_custom_test', | 414 'lib/html/custom/js_custom_test', |
| 402 'lib/html/custom/mirrors_test', | 415 'lib/html/custom/mirrors_test', |
| 403 'lib/html/custom/regress_194523002_test', | 416 'lib/html/custom/regress_194523002_test', |
| 404 ]); | 417 ].map((p) => p.replaceAll('/', path.separator))); |
| OLD | NEW |