| 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 902 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 913 | 913 |
| 914 String dartWrapperFilename = '$tempDir/test.dart'; | 914 String dartWrapperFilename = '$tempDir/test.dart'; |
| 915 String compiledDartWrapperFilename = '$tempDir/test.js'; | 915 String compiledDartWrapperFilename = '$tempDir/test.js'; |
| 916 | 916 |
| 917 String htmlPath = '$tempDir/test.html'; | 917 String htmlPath = '$tempDir/test.html'; |
| 918 if (isWrappingRequired && !isWebTest) { | 918 if (isWrappingRequired && !isWebTest) { |
| 919 // test.dart will import the dart test. | 919 // test.dart will import the dart test. |
| 920 _createWrapperFile(dartWrapperFilename, filePath); | 920 _createWrapperFile(dartWrapperFilename, filePath); |
| 921 } else { | 921 } else { |
| 922 dartWrapperFilename = filename; | 922 dartWrapperFilename = filename; |
| 923 // TODO(whesse): Once test.py is retired, adjust the relative path in | |
| 924 // the client/samples/dartcombat test to its css file, remove the | |
| 925 // "../../" from this path, and move this out of the isWebTest guard. | |
| 926 // Also remove getHtmlName, and just use test.html. | |
| 927 // TODO(efortuna): this shortening of htmlFilename is a band-aid until | |
| 928 // the above TODO gets fixed. Windows cannot have paths that are longer | |
| 929 // than 260 characters, and without this hack, we were running past the | |
| 930 // the limit. | |
| 931 String htmlFilename = getHtmlName(filename); | |
| 932 while ('$tempDir/../$htmlFilename'.length >= 260) { | |
| 933 htmlFilename = htmlFilename.substring(htmlFilename.length~/2); | |
| 934 } | |
| 935 htmlPath = '$tempDir/../$htmlFilename'; | |
| 936 } | 923 } |
| 937 String scriptPath = (compiler == 'none') ? | 924 String scriptPath = (compiler == 'none') ? |
| 938 dartWrapperFilename : compiledDartWrapperFilename; | 925 dartWrapperFilename : compiledDartWrapperFilename; |
| 939 scriptPath = _createUrlPathFromFile(new Path(scriptPath)); | 926 scriptPath = _createUrlPathFromFile(new Path(scriptPath)); |
| 940 | 927 |
| 941 // Create the HTML file for the test. | 928 // Create the HTML file for the test. |
| 942 RandomAccessFile htmlTest = new File(htmlPath).openSync(FileMode.WRITE); | 929 RandomAccessFile htmlTest = new File(htmlPath).openSync(FileMode.WRITE); |
| 943 String content = null; | 930 String content = null; |
| 944 Path dir = filePath.directoryPath; | 931 Path dir = filePath.directoryPath; |
| 945 String nameNoExt = filePath.filenameWithoutExtension; | 932 String nameNoExt = filePath.filenameWithoutExtension; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 959 htmlTest.writeStringSync(content); | 946 htmlTest.writeStringSync(content); |
| 960 htmlTest.closeSync(); | 947 htmlTest.closeSync(); |
| 961 | 948 |
| 962 // Construct the command(s) that compile all the inputs needed by the | 949 // Construct the command(s) that compile all the inputs needed by the |
| 963 // browser test. For running Dart in DRT, this will be noop commands. | 950 // browser test. For running Dart in DRT, this will be noop commands. |
| 964 List<Command> commands = []; | 951 List<Command> commands = []; |
| 965 if (compiler != 'none') { | 952 if (compiler != 'none') { |
| 966 commands.add(_compileCommand( | 953 commands.add(_compileCommand( |
| 967 dartWrapperFilename, compiledDartWrapperFilename, | 954 dartWrapperFilename, compiledDartWrapperFilename, |
| 968 compiler, tempDir, vmOptions, optionsFromFile)); | 955 compiler, tempDir, vmOptions, optionsFromFile)); |
| 956 } |
| 969 | 957 |
| 970 // some tests require compiling multiple input scripts. | 958 // some tests require compiling multiple input scripts. |
| 971 List<String> otherScripts = optionsFromFile['otherScripts']; | 959 List<String> otherScripts = optionsFromFile['otherScripts']; |
| 972 for (String name in otherScripts) { | 960 for (String name in otherScripts) { |
| 973 Path namePath = new Path(name); | 961 Path namePath = new Path(name); |
| 962 String baseName = namePath.filenameWithoutExtension; |
| 963 Path fromPath = filePath.directoryPath.join(namePath); |
| 964 if (compiler != 'none') { |
| 974 assert(namePath.extension == 'dart'); | 965 assert(namePath.extension == 'dart'); |
| 975 String baseName = namePath.filenameWithoutExtension; | |
| 976 Path fromPath = filePath.directoryPath.join(namePath); | |
| 977 commands.add(_compileCommand( | 966 commands.add(_compileCommand( |
| 978 fromPath.toNativePath(), '$tempDir/$baseName.js', | 967 fromPath.toNativePath(), '$tempDir/$baseName.js', |
| 979 compiler, tempDir, vmOptions, optionsFromFile)); | 968 compiler, tempDir, vmOptions, optionsFromFile)); |
| 980 } | 969 } |
| 970 if (compiler == 'none') { |
| 971 // For the tests that require multiple input scripts but are not |
| 972 // compiled, move the input scripts over with the script so they can |
| 973 // be accessed. |
| 974 String result = new File.fromPath(fromPath).readAsStringSync(); |
| 975 new File('$tempDir/$baseName.dart').writeAsStringSync(result); |
| 976 } |
| 981 } | 977 } |
| 982 | 978 |
| 983 // Variables for browser multi-tests. | 979 // Variables for browser multi-tests. |
| 984 List<String> subtestNames = info.optionsFromFile['subtestNames']; | 980 List<String> subtestNames = info.optionsFromFile['subtestNames']; |
| 985 TestCase multitestParentTest; | 981 TestCase multitestParentTest; |
| 986 int subtestIndex = 0; | 982 int subtestIndex = 0; |
| 987 // Construct the command that executes the browser test | 983 // Construct the command that executes the browser test |
| 988 do { | 984 do { |
| 989 List<Command> commandSet = new List<Command>.from(commands); | 985 List<Command> commandSet = new List<Command>.from(commands); |
| 990 if (subtestIndex != 0) { | 986 if (subtestIndex != 0) { |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1166 | 1162 |
| 1167 bool get hasRuntime { | 1163 bool get hasRuntime { |
| 1168 switch(configuration['runtime']) { | 1164 switch(configuration['runtime']) { |
| 1169 case 'none': | 1165 case 'none': |
| 1170 return false; | 1166 return false; |
| 1171 default: | 1167 default: |
| 1172 return true; | 1168 return true; |
| 1173 } | 1169 } |
| 1174 } | 1170 } |
| 1175 | 1171 |
| 1176 String getHtmlName(String filename) { | |
| 1177 var cleanFilename = filename.replaceAll('/', '_') | |
| 1178 .replaceAll(':', '_') | |
| 1179 .replaceAll('\\', '_'); | |
| 1180 | |
| 1181 return "$cleanFilename" | |
| 1182 "${configuration['compiler']}-${configuration['runtime']}.html"; | |
| 1183 } | |
| 1184 | |
| 1185 String get dumpRenderTreeFilename { | 1172 String get dumpRenderTreeFilename { |
| 1186 if (configuration['drt'] != '') { | 1173 if (configuration['drt'] != '') { |
| 1187 return configuration['drt']; | 1174 return configuration['drt']; |
| 1188 } | 1175 } |
| 1189 if (Platform.operatingSystem == 'macos') { | 1176 if (Platform.operatingSystem == 'macos') { |
| 1190 return dartDir.append('/client/tests/drt/DumpRenderTree.app/Contents/' | 1177 return dartDir.append('/client/tests/drt/DumpRenderTree.app/Contents/' |
| 1191 'MacOS/DumpRenderTree').toNativePath(); | 1178 'MacOS/DumpRenderTree').toNativePath(); |
| 1192 } | 1179 } |
| 1193 return dartDir.append('client/tests/drt/DumpRenderTree').toNativePath(); | 1180 return dartDir.append('client/tests/drt/DumpRenderTree').toNativePath(); |
| 1194 } | 1181 } |
| (...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1938 * $pass tests are expected to pass | 1925 * $pass tests are expected to pass |
| 1939 * $failOk tests are expected to fail that we won't fix | 1926 * $failOk tests are expected to fail that we won't fix |
| 1940 * $fail tests are expected to fail that we should fix | 1927 * $fail tests are expected to fail that we should fix |
| 1941 * $crash tests are expected to crash that we should fix | 1928 * $crash tests are expected to crash that we should fix |
| 1942 * $timeout tests are allowed to timeout | 1929 * $timeout tests are allowed to timeout |
| 1943 * $compileErrorSkip tests are skipped on browsers due to compile-time error | 1930 * $compileErrorSkip tests are skipped on browsers due to compile-time error |
| 1944 """; | 1931 """; |
| 1945 print(report); | 1932 print(report); |
| 1946 } | 1933 } |
| 1947 } | 1934 } |
| OLD | NEW |