| 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 776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 787 * executed: a compilation step and an execution step, both with the | 787 * executed: a compilation step and an execution step, both with the |
| 788 * appropriate executable and arguments. The [expectations] object can be | 788 * appropriate executable and arguments. The [expectations] object can be |
| 789 * either a Set<String> if the test is a regular test, or a Map<String | 789 * either a Set<String> if the test is a regular test, or a Map<String |
| 790 * subTestName, Set<String>> if we are running a browser multi-test (one | 790 * subTestName, Set<String>> if we are running a browser multi-test (one |
| 791 * compilation and many browser runs). | 791 * compilation and many browser runs). |
| 792 */ | 792 */ |
| 793 void enqueueBrowserTest(TestInformation info, | 793 void enqueueBrowserTest(TestInformation info, |
| 794 String testName, | 794 String testName, |
| 795 Object expectations, | 795 Object expectations, |
| 796 bool isWrappingRequired) { | 796 bool isWrappingRequired) { |
| 797 // TODO(kustermann/ricow): This method should be refactored. | |
| 798 Map optionsFromFile = info.optionsFromFile; | 797 Map optionsFromFile = info.optionsFromFile; |
| 799 Path filePath = info.filePath; | 798 Path filePath = info.filePath; |
| 800 String filename = filePath.toString(); | 799 String filename = filePath.toString(); |
| 801 bool isWebTest = optionsFromFile['containsDomImport']; | 800 bool isWebTest = optionsFromFile['containsDomImport']; |
| 802 bool isLibraryDefinition = optionsFromFile['isLibraryDefinition']; | 801 bool isLibraryDefinition = optionsFromFile['isLibraryDefinition']; |
| 803 if (isWrappingRequired | 802 if (isWrappingRequired |
| 804 && !isLibraryDefinition && optionsFromFile['containsSourceOrImport']) { | 803 && !isLibraryDefinition && optionsFromFile['containsSourceOrImport']) { |
| 805 print('Warning for $filename: Browser tests require #library ' | 804 print('Warning for $filename: Browser tests require #library ' |
| 806 'in any file that uses #import, #source, or #resource'); | 805 'in any file that uses #import, #source, or #resource'); |
| 807 } | 806 } |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 913 compiler, tempDir, vmOptions, optionsFromFile)); | 912 compiler, tempDir, vmOptions, optionsFromFile)); |
| 914 } | 913 } |
| 915 } | 914 } |
| 916 | 915 |
| 917 // Variables for browser multi-tests. | 916 // Variables for browser multi-tests. |
| 918 List<String> subtestNames = info.optionsFromFile['subtestNames']; | 917 List<String> subtestNames = info.optionsFromFile['subtestNames']; |
| 919 TestCase multitestParentTest; | 918 TestCase multitestParentTest; |
| 920 int subtestIndex = 0; | 919 int subtestIndex = 0; |
| 921 // Construct the command that executes the browser test | 920 // Construct the command that executes the browser test |
| 922 do { | 921 do { |
| 923 List<Command> commandSet = new List<Command>.from(commands); | |
| 924 if (subtestIndex != 0) { | |
| 925 // NOTE: The first time we enter this loop, all the compilation | |
| 926 // commands will be executed. On subsequent loop iterations, we | |
| 927 // don't need to do any compilations. Thus we set "commandSet = []". | |
| 928 commandSet = []; | |
| 929 } | |
| 930 | |
| 931 List<String> args = <String>[]; | 922 List<String> args = <String>[]; |
| 932 String fullHtmlPath = htmlPath.startsWith('http:') ? htmlPath : | 923 String fullHtmlPath = htmlPath.startsWith('http:') ? htmlPath : |
| 933 (htmlPath.startsWith('/') ? | 924 (htmlPath.startsWith('/') ? |
| 934 'file://$htmlPath' : | 925 'file://$htmlPath' : |
| 935 'file:///$htmlPath'); | 926 'file:///$htmlPath'); |
| 936 if (info.optionsFromFile['isMultiHtmlTest'] | 927 if (info.optionsFromFile['isMultiHtmlTest'] |
| 937 && subtestNames.length > 0) { | 928 && subtestNames.length > 0) { |
| 938 fullHtmlPath = '${fullHtmlPath}#${subtestNames[subtestIndex]}'; | 929 fullHtmlPath = '${fullHtmlPath}#${subtestNames[subtestIndex]}'; |
| 939 } | 930 } |
| 940 | |
| 941 if (TestUtils.usesWebDriver(runtime)) { | 931 if (TestUtils.usesWebDriver(runtime)) { |
| 942 args = [ | 932 args = [ |
| 943 dartDir.append('tools/testing/run_selenium.py').toNativePath(), | 933 dartDir.append('tools/testing/run_selenium.py').toNativePath(), |
| 944 '--browser=$runtime', | 934 '--browser=$runtime', |
| 945 '--timeout=${configuration["timeout"] - 2}', | 935 '--timeout=${configuration["timeout"] - 2}', |
| 946 '--out="$fullHtmlPath"']; | 936 '--out="$fullHtmlPath"']; |
| 947 if (runtime == 'dartium') { | 937 if (runtime == 'dartium') { |
| 948 args.add('--executable=$dartiumFilename'); | 938 args.add('--executable=$dartiumFilename'); |
| 949 } | 939 } |
| 950 if (subtestIndex != 0) { | 940 } else { |
| 951 args.add('--force-refresh'); | 941 args = [ |
| 942 dartDir.append('tools/testing/drt-trampoline.py').toNativePath(), |
| 943 dumpRenderTreeFilename, |
| 944 '--no-timeout' |
| 945 ]; |
| 946 if (compiler == 'none') { |
| 947 String packageRoot = |
| 948 packageRootArgument(optionsFromFile['packageRoot']); |
| 949 if (packageRoot != null) { |
| 950 args.add(packageRoot); |
| 951 } |
| 952 } | 952 } |
| 953 commandSet.add(new Command('python', args)); | 953 if (runtime == 'drt' && |
| 954 } else { | 954 (compiler == 'none' || compiler == 'dart2dart')) { |
| 955 Expect.isTrue(runtime == "drt"); | 955 var dartFlags = ['--ignore-unrecognized-flags']; |
| 956 | |
| 957 var dartFlags = []; | |
| 958 var dumpRenderTreeOptions = []; | |
| 959 var packageRootUri; | |
| 960 | |
| 961 dumpRenderTreeOptions.add('--no-timeout'); | |
| 962 | |
| 963 if (compiler == 'none' || compiler == 'dart2dart') { | |
| 964 dartFlags.add('--ignore-unrecognized-flags'); | |
| 965 if (configuration["checked"]) { | 956 if (configuration["checked"]) { |
| 966 dartFlags.add('--enable_asserts'); | 957 dartFlags.add('--enable_asserts'); |
| 967 dartFlags.add("--enable_type_checks"); | 958 dartFlags.add("--enable_type_checks"); |
| 968 } | 959 } |
| 969 dartFlags.addAll(vmOptions); | 960 dartFlags.addAll(vmOptions); |
| 961 args.add('--dart-flags=${Strings.join(dartFlags, " ")}'); |
| 970 } | 962 } |
| 971 if (compiler == 'none') { | 963 args.add(fullHtmlPath); |
| 972 var packageRoot = packageRootArgument( | 964 if (expectedOutput != null) { |
| 973 optionsFromFile['packageRoot']); | 965 args.add('--out-expectation=${expectedOutput.toNativePath()}'); |
| 974 if (packageRoot != null) { | |
| 975 var absolutePath = TestUtils.absolutePath(new Path(packageRoot)); | |
| 976 packageRootUri = new Uri.fromComponents( | |
| 977 scheme: 'file', | |
| 978 path: absolutePath.toString()); | |
| 979 } | |
| 980 } | 966 } |
| 981 | |
| 982 if (expectedOutput != null) { | |
| 983 if (expectedOutput.toNativePath().endsWith('.png')) { | |
| 984 // pixel tests are specified by running DRT "foo.html'-p" | |
| 985 dumpRenderTreeOptions.add('--notree'); | |
| 986 fullHtmlPath = "${fullHtmlPath}'-p"; | |
| 987 } | |
| 988 } | |
| 989 commandSet.add(new DumpRenderTreeCommand(dumpRenderTreeFilename, | |
| 990 fullHtmlPath, | |
| 991 dumpRenderTreeOptions, | |
| 992 dartFlags, | |
| 993 packageRootUri, | |
| 994 expectedOutput)); | |
| 995 } | 967 } |
| 968 List<Command> commandSet = new List<Command>.from(commands); |
| 969 if (subtestIndex != 0) { |
| 970 commandSet = []; |
| 971 if(TestUtils.usesWebDriver(runtime)) args.add('--force-refresh'); |
| 972 } |
| 973 commandSet.add(new Command('python', args)); |
| 996 | 974 |
| 997 // Create BrowserTestCase and queue it. | 975 // Create BrowserTestCase and queue it. |
| 998 String testDisplayName = '$suiteName/$testName'; | 976 String testDisplayName = '$suiteName/$testName'; |
| 999 var testCase; | 977 var testCase; |
| 1000 if (info.optionsFromFile['isMultiHtmlTest']) { | 978 if (info.optionsFromFile['isMultiHtmlTest']) { |
| 1001 testDisplayName = '$testDisplayName/${subtestNames[subtestIndex]}'; | 979 testDisplayName = '$testDisplayName/${subtestNames[subtestIndex]}'; |
| 1002 testCase = new BrowserTestCase(testDisplayName, | 980 testCase = new BrowserTestCase(testDisplayName, |
| 1003 commandSet, configuration, completeHandler, | 981 commandSet, configuration, completeHandler, |
| 1004 expectations['$testName/${subtestNames[subtestIndex]}'], | 982 expectations['$testName/${subtestNames[subtestIndex]}'], |
| 1005 info, info.hasCompileError || info.hasRuntimeError, | 983 info, info.hasCompileError || info.hasRuntimeError, |
| (...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1783 * $pass tests are expected to pass | 1761 * $pass tests are expected to pass |
| 1784 * $failOk tests are expected to fail that we won't fix | 1762 * $failOk tests are expected to fail that we won't fix |
| 1785 * $fail tests are expected to fail that we should fix | 1763 * $fail tests are expected to fail that we should fix |
| 1786 * $crash tests are expected to crash that we should fix | 1764 * $crash tests are expected to crash that we should fix |
| 1787 * $timeout tests are allowed to timeout | 1765 * $timeout tests are allowed to timeout |
| 1788 * $compileErrorSkip tests are skipped on browsers due to compile-time error | 1766 * $compileErrorSkip tests are skipped on browsers due to compile-time error |
| 1789 """; | 1767 """; |
| 1790 print(report); | 1768 print(report); |
| 1791 } | 1769 } |
| 1792 } | 1770 } |
| OLD | NEW |