| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 /** | 5 /** |
| 6 * Classes and methods for enumerating and preparing tests. | 6 * Classes and methods for enumerating and preparing tests. |
| 7 * | 7 * |
| 8 * This library includes: | 8 * This library includes: |
| 9 * | 9 * |
| 10 * - Creating tests by listing all the Dart files in certain directories, | 10 * - Creating tests by listing all the Dart files in certain directories, |
| (...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 619 Path pngPath = dir.append('$nameNoExt.png'); | 619 Path pngPath = dir.append('$nameNoExt.png'); |
| 620 Path txtPath = dir.append('$nameNoExt.txt'); | 620 Path txtPath = dir.append('$nameNoExt.txt'); |
| 621 Path expectedOutput = null; | 621 Path expectedOutput = null; |
| 622 if (new File.fromPath(pngPath).existsSync()) { | 622 if (new File.fromPath(pngPath).existsSync()) { |
| 623 expectedOutput = pngPath; | 623 expectedOutput = pngPath; |
| 624 content = getHtmlLayoutContents(scriptType, '$filePrefix$scriptPath'); | 624 content = getHtmlLayoutContents(scriptType, '$filePrefix$scriptPath'); |
| 625 } else if (new File.fromPath(txtPath).existsSync()) { | 625 } else if (new File.fromPath(txtPath).existsSync()) { |
| 626 expectedOutput = txtPath; | 626 expectedOutput = txtPath; |
| 627 content = getHtmlLayoutContents(scriptType, '$filePrefix$scriptPath'); | 627 content = getHtmlLayoutContents(scriptType, '$filePrefix$scriptPath'); |
| 628 } else { | 628 } else { |
| 629 final htmlLocation = new Path(htmlPath); | |
| 630 content = getHtmlContents( | 629 content = getHtmlContents( |
| 631 filename, | 630 filename, |
| 632 _relativize(htmlLocation, dartDir.append( | 631 '$filePrefix${dartDir.append("pkg/unittest/test_controller.js")}', |
| 633 'pkg/unittest/test_controller.js')), | 632 '$filePrefix${dartDir.append("client/dart.js")}', |
| 634 _relativize(htmlLocation, dartDir.append('client/dart.js')), | |
| 635 scriptType, | 633 scriptType, |
| 636 _relativize(htmlLocation, new Path(scriptPath))); | 634 '$filePrefix$scriptPath'); |
| 637 } | 635 } |
| 638 htmlTest.writeStringSync(content); | 636 htmlTest.writeStringSync(content); |
| 639 htmlTest.closeSync(); | 637 htmlTest.closeSync(); |
| 640 | 638 |
| 641 // Construct the command(s) that compile all the inputs needed by the | 639 // Construct the command(s) that compile all the inputs needed by the |
| 642 // browser test. For running Dart in DRT, this will be noop commands. | 640 // browser test. For running Dart in DRT, this will be noop commands. |
| 643 List<Command> commands = []; | 641 List<Command> commands = []; |
| 644 if (compiler != 'none') { | 642 if (compiler != 'none') { |
| 645 commands.add(_compileCommand( | 643 commands.add(_compileCommand( |
| 646 dartWrapperFilename, compiledDartWrapperFilename, | 644 dartWrapperFilename, compiledDartWrapperFilename, |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1020 "isolateStubs": isolateStubs, | 1018 "isolateStubs": isolateStubs, |
| 1021 "containsDomImport": containsDomImport, | 1019 "containsDomImport": containsDomImport, |
| 1022 "isLibraryDefinition": isLibraryDefinition, | 1020 "isLibraryDefinition": isLibraryDefinition, |
| 1023 "containsSourceOrImport": containsSourceOrImport, | 1021 "containsSourceOrImport": containsSourceOrImport, |
| 1024 "numStaticTypeAnnotations": numStaticTypeAnnotations, | 1022 "numStaticTypeAnnotations": numStaticTypeAnnotations, |
| 1025 "numCompileTimeAnnotations": numCompileTimeAnnotations}; | 1023 "numCompileTimeAnnotations": numCompileTimeAnnotations}; |
| 1026 } | 1024 } |
| 1027 | 1025 |
| 1028 List<List<String>> getVmOptions(Map optionsFromFile) { | 1026 List<List<String>> getVmOptions(Map optionsFromFile) { |
| 1029 bool needsVmOptions = | 1027 bool needsVmOptions = |
| 1030 Contains(configuration['compiler'], | 1028 Contains(configuration['compiler'], const ['none', 'dart2dart', 'dartc']
) && |
| 1031 const ['none', 'dart2dart', 'dartc']) && | 1029 Contains(configuration['runtime'], const ['none', 'vm', 'drt', 'dartium'
]); |
| 1032 Contains(configuration['runtime'], | |
| 1033 const ['none', 'vm', 'drt', 'dartium']); | |
| 1034 if (!needsVmOptions) return [[]]; | 1030 if (!needsVmOptions) return [[]]; |
| 1035 return optionsFromFile['vmOptions']; | 1031 return optionsFromFile['vmOptions']; |
| 1036 } | 1032 } |
| 1037 | |
| 1038 String _relativize(Path base, Path path) { | |
| 1039 base = base.canonicalize(); | |
| 1040 path = path.canonicalize(); | |
| 1041 | |
| 1042 if (!base.isAbsolute || !path.isAbsolute) { | |
| 1043 throw "Only absolute paths are supported."; | |
| 1044 } | |
| 1045 List<String> pathSegments = path.segments(); | |
| 1046 List<String> baseSegments = base.segments(); | |
| 1047 int common = 0; | |
| 1048 int length = Math.min(pathSegments.length, baseSegments.length); | |
| 1049 while (common < length && pathSegments[common] == baseSegments[common]) { | |
| 1050 common++; | |
| 1051 } | |
| 1052 final sb = new StringBuffer(); | |
| 1053 for (int i = common + 1; i < baseSegments.length; i++) { | |
| 1054 sb.add('..${Platform.pathSeparator}'); | |
| 1055 } | |
| 1056 for (int i = common; i < pathSegments.length - 1; i++) { | |
| 1057 sb.add('${pathSegments[i]}${Platform.pathSeparator}'); | |
| 1058 } | |
| 1059 sb.add('${pathSegments.last()}'); | |
| 1060 return sb.toString(); | |
| 1061 } | |
| 1062 } | 1033 } |
| 1063 | 1034 |
| 1064 | 1035 |
| 1065 class DartcCompilationTestSuite extends StandardTestSuite { | 1036 class DartcCompilationTestSuite extends StandardTestSuite { |
| 1066 List<String> _testDirs; | 1037 List<String> _testDirs; |
| 1067 int activityCount = 0; | 1038 int activityCount = 0; |
| 1068 | 1039 |
| 1069 DartcCompilationTestSuite(Map configuration, | 1040 DartcCompilationTestSuite(Map configuration, |
| 1070 String suiteName, | 1041 String suiteName, |
| 1071 String directoryPath, | 1042 String directoryPath, |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1442 * $noCrash tests are expected to be flaky but not crash | 1413 * $noCrash tests are expected to be flaky but not crash |
| 1443 * $pass tests are expected to pass | 1414 * $pass tests are expected to pass |
| 1444 * $failOk tests are expected to fail that we won't fix | 1415 * $failOk tests are expected to fail that we won't fix |
| 1445 * $fail tests are expected to fail that we should fix | 1416 * $fail tests are expected to fail that we should fix |
| 1446 * $crash tests are expected to crash that we should fix | 1417 * $crash tests are expected to crash that we should fix |
| 1447 * $timeout tests are allowed to timeout | 1418 * $timeout tests are allowed to timeout |
| 1448 """; | 1419 """; |
| 1449 print(report); | 1420 print(report); |
| 1450 } | 1421 } |
| 1451 } | 1422 } |
| OLD | NEW |