| 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 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 | 353 |
| 354 if (configuration["report"]) { | 354 if (configuration["report"]) { |
| 355 SummaryReport.add(expectations); | 355 SummaryReport.add(expectations); |
| 356 } | 356 } |
| 357 | 357 |
| 358 if (expectations.contains(SKIP)) return; | 358 if (expectations.contains(SKIP)) return; |
| 359 | 359 |
| 360 var args = TestUtils.standardOptions(configuration); | 360 var args = TestUtils.standardOptions(configuration); |
| 361 args.add(testName); | 361 args.add(testName); |
| 362 | 362 |
| 363 doTest(new TestCase(constructedName, | 363 doTest( |
| 364 [new Command(targetRunnerPath, args)], | 364 new TestCase(constructedName, |
| 365 configuration, | 365 [new Command('run_vm_unittest', targetRunnerPath, args)], |
| 366 completeHandler, | 366 configuration, |
| 367 expectations)); | 367 completeHandler, |
| 368 expectations)); |
| 368 } | 369 } |
| 369 } | 370 } |
| 370 | 371 |
| 371 void forEachTest(TestCaseEvent onTest, Map testCache, [VoidFunction onDone]) { | 372 void forEachTest(TestCaseEvent onTest, Map testCache, [VoidFunction onDone]) { |
| 372 doTest = onTest; | 373 doTest = onTest; |
| 373 doDone = onDone; | 374 doDone = onDone; |
| 374 | 375 |
| 375 var filesRead = 0; | 376 var filesRead = 0; |
| 376 void statusFileRead() { | 377 void statusFileRead() { |
| 377 filesRead++; | 378 filesRead++; |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 739 makeCommands(info, vmOptions, commonArguments), | 740 makeCommands(info, vmOptions, commonArguments), |
| 740 configuration, | 741 configuration, |
| 741 completeHandler, | 742 completeHandler, |
| 742 expectations, | 743 expectations, |
| 743 isNegative: isNegative, | 744 isNegative: isNegative, |
| 744 info: info)); | 745 info: info)); |
| 745 } | 746 } |
| 746 } | 747 } |
| 747 | 748 |
| 748 List<Command> makeCommands(TestInformation info, var vmOptions, var args) { | 749 List<Command> makeCommands(TestInformation info, var vmOptions, var args) { |
| 749 switch (configuration['compiler']) { | 750 var compiler = configuration['compiler']; |
| 751 switch (compiler) { |
| 750 case 'dart2js': | 752 case 'dart2js': |
| 751 args = new List.from(args); | 753 args = new List.from(args); |
| 752 String tempDir = createOutputDirectory(info.filePath, ''); | 754 String tempDir = createOutputDirectory(info.filePath, ''); |
| 753 args.add('--out=$tempDir/out.js'); | 755 args.add('--out=$tempDir/out.js'); |
| 754 | 756 |
| 755 List<Command> commands = | 757 List<Command> commands = |
| 756 <Command>[new CompilationCommand("$tempDir/out.js", | 758 <Command>[new CompilationCommand(compiler, |
| 759 "$tempDir/out.js", |
| 757 !useSdk, | 760 !useSdk, |
| 758 dart2JsBootstrapDependencies, | 761 dart2JsBootstrapDependencies, |
| 759 compilerPath, | 762 compilerPath, |
| 760 args)]; | 763 args)]; |
| 761 if (info.hasCompileError) { | 764 if (info.hasCompileError) { |
| 762 // Do not attempt to run the compiled result. A compilation | 765 // Do not attempt to run the compiled result. A compilation |
| 763 // error should be reported by the compilation command. | 766 // error should be reported by the compilation command. |
| 764 } else if (configuration['runtime'] == 'd8') { | 767 } else if (configuration['runtime'] == 'd8') { |
| 765 commands.add(new Command(d8FileName, ['$tempDir/out.js'])); | 768 commands.add(new Command("d8", d8FileName, ['$tempDir/out.js'])); |
| 766 } else if (configuration['runtime'] == 'jsshell') { | 769 } else if (configuration['runtime'] == 'jsshell') { |
| 767 commands.add(new Command(jsShellFileName, ['$tempDir/out.js'])); | 770 commands.add( |
| 771 new Command("jsshell", jsShellFileName, ['$tempDir/out.js'])); |
| 768 } | 772 } |
| 769 return commands; | 773 return commands; |
| 770 | 774 |
| 771 case 'dart2dart': | 775 case 'dart2dart': |
| 772 args = new List.from(args); | 776 args = new List.from(args); |
| 773 args.add('--output-type=dart'); | 777 args.add('--output-type=dart'); |
| 774 String tempDir = createOutputDirectory(info.filePath, ''); | 778 String tempDir = createOutputDirectory(info.filePath, ''); |
| 775 args.add('--out=$tempDir/out.dart'); | 779 args.add('--out=$tempDir/out.dart'); |
| 776 | 780 |
| 777 List<Command> commands = | 781 List<Command> commands = |
| 778 <Command>[new CompilationCommand("$tempDir/out.dart", | 782 <Command>[new CompilationCommand(compiler, |
| 783 "$tempDir/out.dart", |
| 779 !useSdk, | 784 !useSdk, |
| 780 dart2JsBootstrapDependencies, | 785 dart2JsBootstrapDependencies, |
| 781 compilerPath, | 786 compilerPath, |
| 782 args)]; | 787 args)]; |
| 783 if (info.hasCompileError) { | 788 if (info.hasCompileError) { |
| 784 // Do not attempt to run the compiled result. A compilation | 789 // Do not attempt to run the compiled result. A compilation |
| 785 // error should be reported by the compilation command. | 790 // error should be reported by the compilation command. |
| 786 } else if (configuration['runtime'] == 'vm') { | 791 } else if (configuration['runtime'] == 'vm') { |
| 787 // TODO(antonm): support checked. | 792 // TODO(antonm): support checked. |
| 788 var vmArguments = new List.from(vmOptions); | 793 var vmArguments = new List.from(vmOptions); |
| 789 vmArguments.addAll([ | 794 vmArguments.addAll([ |
| 790 '--ignore-unrecognized-flags', '$tempDir/out.dart']); | 795 '--ignore-unrecognized-flags', '$tempDir/out.dart']); |
| 791 commands.add(new Command(vmFileName, vmArguments)); | 796 commands.add(new Command("vm", vmFileName, vmArguments)); |
| 792 } else { | 797 } else { |
| 793 throw 'Unsupported runtime ${configuration["runtime"]} for dart2dart'; | 798 throw 'Unsupported runtime ${configuration["runtime"]} for dart2dart'; |
| 794 } | 799 } |
| 795 return commands; | 800 return commands; |
| 796 | 801 |
| 797 case 'none': | 802 case 'none': |
| 798 case 'dartc': | 803 case 'dartc': |
| 799 case 'dartanalyzer': | 804 case 'dartanalyzer': |
| 800 case 'dart2analyzer': | 805 case 'dart2analyzer': |
| 806 var displayName = (configuration['compiler'] == 'none' |
| 807 ? 'vm' : configuration['compiler']); |
| 801 var arguments = new List.from(vmOptions); | 808 var arguments = new List.from(vmOptions); |
| 802 arguments.addAll(args); | 809 arguments.addAll(args); |
| 803 return <Command>[new Command(dartShellFileName, arguments)]; | 810 return <Command>[ |
| 811 new Command(displayName, dartShellFileName, arguments)]; |
| 804 | 812 |
| 805 default: | 813 default: |
| 806 throw 'Unknown compiler ${configuration["compiler"]}'; | 814 throw 'Unknown compiler ${configuration["compiler"]}'; |
| 807 } | 815 } |
| 808 } | 816 } |
| 809 | 817 |
| 810 CreateTest makeTestCaseCreator(RegExp pattern, Map optionsFromFile) { | 818 CreateTest makeTestCaseCreator(RegExp pattern, Map optionsFromFile) { |
| 811 return (Path filePath, | 819 return (Path filePath, |
| 812 bool hasCompileError, | 820 bool hasCompileError, |
| 813 bool hasRuntimeError, | 821 bool hasRuntimeError, |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1017 subtestNames, subtestIndex); | 1025 subtestNames, subtestIndex); |
| 1018 | 1026 |
| 1019 List<String> args = <String>[]; | 1027 List<String> args = <String>[]; |
| 1020 | 1028 |
| 1021 if (configuration['use_browser_controller']) { | 1029 if (configuration['use_browser_controller']) { |
| 1022 // This command is not actually run, it is used for reproducing | 1030 // This command is not actually run, it is used for reproducing |
| 1023 // the failure. | 1031 // the failure. |
| 1024 args = ['tools/testing/dart/launch_browser.dart', | 1032 args = ['tools/testing/dart/launch_browser.dart', |
| 1025 runtime, | 1033 runtime, |
| 1026 fullHtmlPath]; | 1034 fullHtmlPath]; |
| 1027 commandSet.add(new Command(TestUtils.dartTestExecutable.toString(), | 1035 commandSet.add(new Command(runtime, |
| 1036 TestUtils.dartTestExecutable.toString(), |
| 1028 args)); | 1037 args)); |
| 1029 } else if (TestUtils.usesWebDriver(runtime)) { | 1038 } else if (TestUtils.usesWebDriver(runtime)) { |
| 1030 args = [ | 1039 args = [ |
| 1031 dartDir.append('tools/testing/run_selenium.py').toNativePath(), | 1040 dartDir.append('tools/testing/run_selenium.py').toNativePath(), |
| 1032 '--browser=$runtime', | 1041 '--browser=$runtime', |
| 1033 // NOTE: This value will be overridden by the test runner | 1042 // NOTE: This value will be overridden by the test runner |
| 1034 '--timeout=${configuration['timeout']}', | 1043 '--timeout=${configuration['timeout']}', |
| 1035 '--out=$fullHtmlPath']; | 1044 '--out=$fullHtmlPath']; |
| 1036 if (runtime == 'dartium') { | 1045 if (runtime == 'dartium') { |
| 1037 args.add('--executable=$dartiumFilename'); | 1046 args.add('--executable=$dartiumFilename'); |
| 1038 } | 1047 } |
| 1039 if (subtestIndex != 0) { | 1048 if (subtestIndex != 0) { |
| 1040 args.add('--force-refresh'); | 1049 args.add('--force-refresh'); |
| 1041 } | 1050 } |
| 1042 commandSet.add(new Command('python', args)); | 1051 commandSet.add(new Command(runtime, 'python', args)); |
| 1043 } else { | 1052 } else { |
| 1044 if (runtime != "drt") { | 1053 if (runtime != "drt") { |
| 1045 print("Unknown runtime $runtime"); | 1054 print("Unknown runtime $runtime"); |
| 1046 exit(1); | 1055 exit(1); |
| 1047 } | 1056 } |
| 1048 | 1057 |
| 1049 var dartFlags = []; | 1058 var dartFlags = []; |
| 1050 var contentShellOptions = []; | 1059 var contentShellOptions = []; |
| 1051 | 1060 |
| 1052 contentShellOptions.add('--no-timeout'); | 1061 contentShellOptions.add('--no-timeout'); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1099 | 1108 |
| 1100 doTest(testCase); | 1109 doTest(testCase); |
| 1101 subtestIndex++; | 1110 subtestIndex++; |
| 1102 } while(subtestIndex < subtestNames.length); | 1111 } while(subtestIndex < subtestNames.length); |
| 1103 } | 1112 } |
| 1104 } | 1113 } |
| 1105 | 1114 |
| 1106 /** Helper to create a compilation command for a single input file. */ | 1115 /** Helper to create a compilation command for a single input file. */ |
| 1107 Command _compileCommand(String inputFile, String outputFile, | 1116 Command _compileCommand(String inputFile, String outputFile, |
| 1108 String compiler, String dir, vmOptions, optionsFromFile) { | 1117 String compiler, String dir, vmOptions, optionsFromFile) { |
| 1118 assert (['dart2js', 'dart2dart'].contains(compiler)); |
| 1109 String executable = compilerPath; | 1119 String executable = compilerPath; |
| 1110 List<String> args = TestUtils.standardOptions(configuration); | 1120 List<String> args = TestUtils.standardOptions(configuration); |
| 1111 switch (compiler) { | 1121 String packageRoot = |
| 1112 case 'dart2js': | 1122 packageRootArgument(optionsFromFile['packageRoot']); |
| 1113 case 'dart2dart': | 1123 if (packageRoot != null) { |
| 1114 String packageRoot = | 1124 args.add(packageRoot); |
| 1115 packageRootArgument(optionsFromFile['packageRoot']); | |
| 1116 if (packageRoot != null) { | |
| 1117 args.add(packageRoot); | |
| 1118 } | |
| 1119 args.add('--out=$outputFile'); | |
| 1120 args.add(inputFile); | |
| 1121 break; | |
| 1122 default: | |
| 1123 print('unimplemented compiler $compiler'); | |
| 1124 exit(1); | |
| 1125 } | 1125 } |
| 1126 args.add('--out=$outputFile'); |
| 1127 args.add(inputFile); |
| 1126 if (executable.endsWith('.dart')) { | 1128 if (executable.endsWith('.dart')) { |
| 1127 // Run the compiler script via the Dart VM. | 1129 // Run the compiler script via the Dart VM. |
| 1128 args.insert(0, executable); | 1130 args.insert(0, executable); |
| 1129 executable = dartShellFileName; | 1131 executable = dartShellFileName; |
| 1130 } | 1132 } |
| 1131 if (['dart2js', 'dart2dart'].contains(configuration['compiler'])) { | 1133 return new CompilationCommand(compiler, |
| 1132 return new CompilationCommand(outputFile, | 1134 outputFile, |
| 1133 !useSdk, | 1135 !useSdk, |
| 1134 dart2JsBootstrapDependencies, | 1136 dart2JsBootstrapDependencies, |
| 1135 compilerPath, | 1137 compilerPath, |
| 1136 args); | 1138 args); |
| 1137 } | |
| 1138 return new Command(executable, args); | |
| 1139 } | 1139 } |
| 1140 | 1140 |
| 1141 /** | 1141 /** |
| 1142 * Create a directory for the generated test. If a Dart language test | 1142 * Create a directory for the generated test. If a Dart language test |
| 1143 * needs to be run in a browser, the Dart test needs to be embedded in | 1143 * needs to be run in a browser, the Dart test needs to be embedded in |
| 1144 * an HTML page, with a testing framework based on scripting and DOM events. | 1144 * an HTML page, with a testing framework based on scripting and DOM events. |
| 1145 * These scripts and pages are written to a generated_test directory | 1145 * These scripts and pages are written to a generated_test directory |
| 1146 * inside the build directory of the checkout. | 1146 * inside the build directory of the checkout. |
| 1147 * | 1147 * |
| 1148 * Those tests which are already HTML web applications (web tests), with | 1148 * Those tests which are already HTML web applications (web tests), with |
| (...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1661 args.addAll(testClasses); | 1661 args.addAll(testClasses); |
| 1662 | 1662 |
| 1663 // Lengthen the timeout for JUnit tests. It is normal for them | 1663 // Lengthen the timeout for JUnit tests. It is normal for them |
| 1664 // to run for a few minutes. | 1664 // to run for a few minutes. |
| 1665 Map updatedConfiguration = new Map(); | 1665 Map updatedConfiguration = new Map(); |
| 1666 configuration.forEach((key, value) { | 1666 configuration.forEach((key, value) { |
| 1667 updatedConfiguration[key] = value; | 1667 updatedConfiguration[key] = value; |
| 1668 }); | 1668 }); |
| 1669 updatedConfiguration['timeout'] *= 3; | 1669 updatedConfiguration['timeout'] *= 3; |
| 1670 doTest(new TestCase(suiteName, | 1670 doTest(new TestCase(suiteName, |
| 1671 [new Command('java', args)], | 1671 [new Command('junit_test', 'java', args)], |
| 1672 updatedConfiguration, | 1672 updatedConfiguration, |
| 1673 completeHandler, | 1673 completeHandler, |
| 1674 new Set<String>.from([PASS]))); | 1674 new Set<String>.from([PASS]))); |
| 1675 doDone(); | 1675 doDone(); |
| 1676 } | 1676 } |
| 1677 | 1677 |
| 1678 void completeHandler(TestCase testCase) { | 1678 void completeHandler(TestCase testCase) { |
| 1679 } | 1679 } |
| 1680 | 1680 |
| 1681 void computeClassPath() { | 1681 void computeClassPath() { |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1966 * $pass tests are expected to pass | 1966 * $pass tests are expected to pass |
| 1967 * $failOk tests are expected to fail that we won't fix | 1967 * $failOk tests are expected to fail that we won't fix |
| 1968 * $fail tests are expected to fail that we should fix | 1968 * $fail tests are expected to fail that we should fix |
| 1969 * $crash tests are expected to crash that we should fix | 1969 * $crash tests are expected to crash that we should fix |
| 1970 * $timeout tests are allowed to timeout | 1970 * $timeout tests are allowed to timeout |
| 1971 * $compileErrorSkip tests are skipped on browsers due to compile-time error | 1971 * $compileErrorSkip tests are skipped on browsers due to compile-time error |
| 1972 """; | 1972 """; |
| 1973 print(report); | 1973 print(report); |
| 1974 } | 1974 } |
| 1975 } | 1975 } |
| OLD | NEW |