Chromium Code Reviews| 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 771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 782 * executed: a compilation step and an execution step, both with the | 782 * executed: a compilation step and an execution step, both with the |
| 783 * appropriate executable and arguments. The [expectations] object can be | 783 * appropriate executable and arguments. The [expectations] object can be |
| 784 * either a Set<String> if the test is a regular test, or a Map<String | 784 * either a Set<String> if the test is a regular test, or a Map<String |
| 785 * subTestName, Set<String>> if we are running a browser multi-test (one | 785 * subTestName, Set<String>> if we are running a browser multi-test (one |
| 786 * compilation and many browser runs). | 786 * compilation and many browser runs). |
| 787 */ | 787 */ |
| 788 void enqueueBrowserTest(TestInformation info, | 788 void enqueueBrowserTest(TestInformation info, |
| 789 String testName, | 789 String testName, |
| 790 Object expectations, | 790 Object expectations, |
| 791 bool isWrappingRequired) { | 791 bool isWrappingRequired) { |
| 792 Map optionsFromFile = info.optionsFromFile; | 792 Map optionsFromFile = info.optionsFromFile; |
|
ricow1
2012/12/17 13:45:57
Add todo here to tell us to refactor this method (
kustermann
2012/12/17 14:00:47
Done.
| |
| 793 Path filePath = info.filePath; | 793 Path filePath = info.filePath; |
| 794 String filename = filePath.toString(); | 794 String filename = filePath.toString(); |
| 795 bool isWebTest = optionsFromFile['containsDomImport']; | 795 bool isWebTest = optionsFromFile['containsDomImport']; |
| 796 bool isLibraryDefinition = optionsFromFile['isLibraryDefinition']; | 796 bool isLibraryDefinition = optionsFromFile['isLibraryDefinition']; |
| 797 if (isWrappingRequired | 797 if (isWrappingRequired |
| 798 && !isLibraryDefinition && optionsFromFile['containsSourceOrImport']) { | 798 && !isLibraryDefinition && optionsFromFile['containsSourceOrImport']) { |
| 799 print('Warning for $filename: Browser tests require #library ' | 799 print('Warning for $filename: Browser tests require #library ' |
| 800 'in any file that uses #import, #source, or #resource'); | 800 'in any file that uses #import, #source, or #resource'); |
| 801 } | 801 } |
| 802 | 802 |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 907 compiler, tempDir, vmOptions, optionsFromFile)); | 907 compiler, tempDir, vmOptions, optionsFromFile)); |
| 908 } | 908 } |
| 909 } | 909 } |
| 910 | 910 |
| 911 // Variables for browser multi-tests. | 911 // Variables for browser multi-tests. |
| 912 List<String> subtestNames = info.optionsFromFile['subtestNames']; | 912 List<String> subtestNames = info.optionsFromFile['subtestNames']; |
| 913 TestCase multitestParentTest; | 913 TestCase multitestParentTest; |
| 914 int subtestIndex = 0; | 914 int subtestIndex = 0; |
| 915 // Construct the command that executes the browser test | 915 // Construct the command that executes the browser test |
| 916 do { | 916 do { |
| 917 List<Command> commandSet = new List<Command>.from(commands); | |
|
ricow1
2012/12/17 13:45:57
add comment describing what we use this for
kustermann
2012/12/17 14:00:47
Done.
| |
| 918 if (subtestIndex != 0) { | |
| 919 commandSet = []; | |
| 920 } | |
| 921 | |
| 917 List<String> args = <String>[]; | 922 List<String> args = <String>[]; |
| 918 String fullHtmlPath = htmlPath.startsWith('http:') ? htmlPath : | 923 String fullHtmlPath = htmlPath.startsWith('http:') ? htmlPath : |
| 919 (htmlPath.startsWith('/') ? | 924 (htmlPath.startsWith('/') ? |
| 920 'file://$htmlPath' : | 925 'file://$htmlPath' : |
| 921 'file:///$htmlPath'); | 926 'file:///$htmlPath'); |
| 922 if (info.optionsFromFile['isMultiHtmlTest'] | 927 if (info.optionsFromFile['isMultiHtmlTest'] |
| 923 && subtestNames.length > 0) { | 928 && subtestNames.length > 0) { |
| 924 fullHtmlPath = '${fullHtmlPath}#${subtestNames[subtestIndex]}'; | 929 fullHtmlPath = '${fullHtmlPath}#${subtestNames[subtestIndex]}'; |
| 925 } | 930 } |
| 931 | |
| 926 if (TestUtils.usesWebDriver(runtime)) { | 932 if (TestUtils.usesWebDriver(runtime)) { |
| 927 args = [ | 933 args = [ |
| 928 dartDir.append('tools/testing/run_selenium.py').toNativePath(), | 934 dartDir.append('tools/testing/run_selenium.py').toNativePath(), |
| 929 '--browser=$runtime', | 935 '--browser=$runtime', |
| 930 '--timeout=${configuration["timeout"] - 2}', | 936 '--timeout=${configuration["timeout"] - 2}', |
| 931 '--out="$fullHtmlPath"']; | 937 '--out="$fullHtmlPath"']; |
| 932 if (runtime == 'dartium') { | 938 if (runtime == 'dartium') { |
| 933 args.add('--executable=$dartiumFilename'); | 939 args.add('--executable=$dartiumFilename'); |
| 934 } | 940 } |
| 941 if (subtestIndex != 0) { | |
| 942 args.add('--force-refresh'); | |
| 943 } | |
| 944 commandSet.add(new Command('python', args)); | |
| 935 } else { | 945 } else { |
| 936 args = [ | 946 Expect.isTrue(runtime == "drt"); |
| 937 dartDir.append('tools/testing/drt-trampoline.py').toNativePath(), | 947 |
| 938 dumpRenderTreeFilename, | 948 var dartFlags = []; |
| 939 '--no-timeout' | 949 var dumpRenderTreeOptions = []; |
| 940 ]; | 950 var packageRootUri; |
| 941 if (compiler == 'none') { | 951 |
| 942 String packageRoot = | 952 dumpRenderTreeOptions.add('--no-timeout'); |
| 943 packageRootArgument(optionsFromFile['packageRoot']); | 953 |
| 944 if (packageRoot != null) { | 954 if (compiler == 'none' || compiler == 'dart2dart') { |
| 945 args.add(packageRoot); | 955 dartFlags.add('--ignore-unrecognized-flags'); |
| 946 } | |
| 947 } | |
| 948 if (runtime == 'drt' && | |
| 949 (compiler == 'none' || compiler == 'dart2dart')) { | |
| 950 var dartFlags = ['--ignore-unrecognized-flags']; | |
| 951 if (configuration["checked"]) { | 956 if (configuration["checked"]) { |
| 952 dartFlags.add('--enable_asserts'); | 957 dartFlags.add('--enable_asserts'); |
| 953 dartFlags.add("--enable_type_checks"); | 958 dartFlags.add("--enable_type_checks"); |
| 954 } | 959 } |
| 955 dartFlags.addAll(vmOptions); | 960 dartFlags.addAll(vmOptions); |
| 956 args.add('--dart-flags=${Strings.join(dartFlags, " ")}'); | |
| 957 } | 961 } |
| 958 args.add(fullHtmlPath); | 962 if (compiler == 'none') { |
| 963 var packageRoot = packageRootArgument( | |
| 964 optionsFromFile['packageRoot']); | |
| 965 if (packageRoot != null) { | |
| 966 var absolutePath = TestUtils.absolutePath(new Path(packageRoot)); | |
| 967 packageRootUri = new Uri.fromComponents( | |
| 968 scheme: 'file', | |
| 969 path: absolutePath.toString()); | |
| 970 } | |
| 971 } | |
| 972 | |
| 959 if (expectedOutput != null) { | 973 if (expectedOutput != null) { |
| 960 args.add('--out-expectation=${expectedOutput.toNativePath()}'); | 974 if (expectedOutput.toNativePath().endsWith('.png')) { |
| 975 // pixel tests are specified by running DRT "foo.html'-p" | |
| 976 dumpRenderTreeOptions.add('--notree'); | |
| 977 fullHtmlPath = "${fullHtmlPath}'-p"; | |
| 978 } | |
| 961 } | 979 } |
| 980 commandSet.add(new DumpRenderTreeCommand(dumpRenderTreeFilename, | |
| 981 fullHtmlPath, | |
| 982 dumpRenderTreeOptions, | |
| 983 dartFlags, | |
| 984 packageRootUri, | |
| 985 expectedOutput)); | |
| 962 } | 986 } |
| 963 List<Command> commandSet = new List<Command>.from(commands); | |
| 964 if (subtestIndex != 0) { | |
| 965 commandSet = []; | |
| 966 if(TestUtils.usesWebDriver(runtime)) args.add('--force-refresh'); | |
| 967 } | |
| 968 commandSet.add(new Command('python', args)); | |
| 969 | 987 |
| 970 // Create BrowserTestCase and queue it. | 988 // Create BrowserTestCase and queue it. |
| 971 String testDisplayName = '$suiteName/$testName'; | 989 String testDisplayName = '$suiteName/$testName'; |
| 972 var testCase; | 990 var testCase; |
| 973 if (info.optionsFromFile['isMultiHtmlTest']) { | 991 if (info.optionsFromFile['isMultiHtmlTest']) { |
| 974 testDisplayName = '$testDisplayName/${subtestNames[subtestIndex]}'; | 992 testDisplayName = '$testDisplayName/${subtestNames[subtestIndex]}'; |
| 975 testCase = new BrowserTestCase(testDisplayName, | 993 testCase = new BrowserTestCase(testDisplayName, |
| 976 commandSet, configuration, completeHandler, | 994 commandSet, configuration, completeHandler, |
| 977 expectations['$testName/${subtestNames[subtestIndex]}'], | 995 expectations['$testName/${subtestNames[subtestIndex]}'], |
| 978 info, info.hasCompileError || info.hasRuntimeError, | 996 info, info.hasCompileError || info.hasRuntimeError, |
| (...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1756 * $pass tests are expected to pass | 1774 * $pass tests are expected to pass |
| 1757 * $failOk tests are expected to fail that we won't fix | 1775 * $failOk tests are expected to fail that we won't fix |
| 1758 * $fail tests are expected to fail that we should fix | 1776 * $fail tests are expected to fail that we should fix |
| 1759 * $crash tests are expected to crash that we should fix | 1777 * $crash tests are expected to crash that we should fix |
| 1760 * $timeout tests are allowed to timeout | 1778 * $timeout tests are allowed to timeout |
| 1761 * $compileErrorSkip tests are skipped on browsers due to compile-time error | 1779 * $compileErrorSkip tests are skipped on browsers due to compile-time error |
| 1762 """; | 1780 """; |
| 1763 print(report); | 1781 print(report); |
| 1764 } | 1782 } |
| 1765 } | 1783 } |
| OLD | NEW |