Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: tools/testing/dart/test_suite.dart

Issue 23678009: fixed TodoMVC tests to include deploying to JS (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « samples/third_party/todomvc/test/mainpage_test.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 951 matching lines...) Expand 10 before | Expand all | Expand 10 after
962 if (getVmOptions(optionsFromFile).length > 1) { 962 if (getVmOptions(optionsFromFile).length > 1) {
963 optionsName = vmOptions.join('-').replaceAll('-','') 963 optionsName = vmOptions.join('-').replaceAll('-','')
964 .replaceAll('=','') 964 .replaceAll('=','')
965 .replaceAll('/',''); 965 .replaceAll('/','');
966 } 966 }
967 final String tempDir = createOutputDirectory(info.filePath, optionsName); 967 final String tempDir = createOutputDirectory(info.filePath, optionsName);
968 968
969 String dartWrapperFilename = '$tempDir/test.dart'; 969 String dartWrapperFilename = '$tempDir/test.dart';
970 String compiledDartWrapperFilename = '$tempDir/test.js'; 970 String compiledDartWrapperFilename = '$tempDir/test.js';
971 971
972 String htmlPath = '$tempDir/test.html';
973 if (isWrappingRequired && !isWebTest) {
974 // test.dart will import the dart test.
975 _createWrapperFile(dartWrapperFilename, filePath);
976 } else {
977 dartWrapperFilename = filename;
978 }
979 String scriptPath = (compiler == 'none') ?
980 dartWrapperFilename : compiledDartWrapperFilename;
981 scriptPath = _createUrlPathFromFile(new Path(scriptPath));
982
983 // Create the HTML file for the test.
984 RandomAccessFile htmlTest =
985 new File(htmlPath).openSync(mode: FileMode.WRITE);
986 String content = null; 972 String content = null;
987 Path dir = filePath.directoryPath; 973 Path dir = filePath.directoryPath;
988 String nameNoExt = filePath.filenameWithoutExtension; 974 String nameNoExt = filePath.filenameWithoutExtension;
989 975
990 Path pngPath = dir.append('$nameNoExt.png'); 976 Path pngPath = dir.append('$nameNoExt.png');
991 Path txtPath = dir.append('$nameNoExt.txt'); 977 Path txtPath = dir.append('$nameNoExt.txt');
992 Path customHtmlPath = dir.append('$nameNoExt.html'); 978 String customHtmlPath = dir.append('$nameNoExt.html').toNativePath();
979 File customHtml = new File(customHtmlPath);
993 Path expectedOutput = null; 980 Path expectedOutput = null;
994 981
995 if (new File(customHtmlPath.toNativePath()).existsSync()) { 982 // Construct the command(s) that compile all the inputs needed by the
996 // Use existing HTML document if available. 983 // browser test. For running Dart in DRT, this will be noop commands.
997 htmlPath = customHtmlPath.toNativePath(); 984 List<Command> commands = [];
985
986 // Use existing HTML document if available.
987 String htmlPath;
988 if (customHtml.existsSync()) {
989
990 // If necessary, run the Polymer deploy steps.
991 // TODO(jmesserly): this should be generalized for any tests that
992 // require Pub deploy, not just polymer.
993 if (compiler != 'none' &&
994 customHtml.readAsStringSync().contains('polymer/boot.js')) {
995
996 commands.add(_polymerDeployCommand(
997 customHtmlPath, tempDir, optionsFromFile));
998
999 htmlPath = '$tempDir/test/$nameNoExt.html';
1000 dartWrapperFilename = '${htmlPath}_bootstrap.dart';
1001 compiledDartWrapperFilename = '$dartWrapperFilename.js';
1002 } else {
1003 htmlPath = customHtmlPath;
1004 }
998 } else { 1005 } else {
1006 htmlPath = '$tempDir/test.html';
1007 if (isWrappingRequired && !isWebTest) {
1008 // test.dart will import the dart test.
1009 _createWrapperFile(dartWrapperFilename, filePath);
1010 } else {
1011 dartWrapperFilename = filename;
1012 }
1013
1014 // Create the HTML file for the test.
1015 RandomAccessFile htmlTest =
1016 new File(htmlPath).openSync(mode: FileMode.WRITE);
1017
1018 String scriptPath = (compiler == 'none') ?
1019 dartWrapperFilename : compiledDartWrapperFilename;
1020 scriptPath = _createUrlPathFromFile(new Path(scriptPath));
1021
999 if (new File(pngPath.toNativePath()).existsSync()) { 1022 if (new File(pngPath.toNativePath()).existsSync()) {
1000 expectedOutput = pngPath; 1023 expectedOutput = pngPath;
1001 content = getHtmlLayoutContents(scriptType, new Path("$scriptPath")); 1024 content = getHtmlLayoutContents(scriptType, new Path("$scriptPath"));
1002 } else if (new File(txtPath.toNativePath()).existsSync()) { 1025 } else if (new File(txtPath.toNativePath()).existsSync()) {
1003 expectedOutput = txtPath; 1026 expectedOutput = txtPath;
1004 content = getHtmlLayoutContents(scriptType, new Path("$scriptPath")); 1027 content = getHtmlLayoutContents(scriptType, new Path("$scriptPath"));
1005 } else { 1028 } else {
1006 content = getHtmlContents(filename, scriptType, 1029 content = getHtmlContents(filename, scriptType,
1007 new Path("$scriptPath")); 1030 new Path("$scriptPath"));
1008 } 1031 }
1009 htmlTest.writeStringSync(content); 1032 htmlTest.writeStringSync(content);
1010 htmlTest.closeSync(); 1033 htmlTest.closeSync();
1011 } 1034 }
1012 1035
1013 // Construct the command(s) that compile all the inputs needed by the
1014 // browser test. For running Dart in DRT, this will be noop commands.
1015 List<Command> commands = [];
1016 if (compiler != 'none') { 1036 if (compiler != 'none') {
1017 commands.add(_compileCommand( 1037 commands.add(_compileCommand(
1018 dartWrapperFilename, compiledDartWrapperFilename, 1038 dartWrapperFilename, compiledDartWrapperFilename,
1019 compiler, tempDir, vmOptions, optionsFromFile)); 1039 compiler, tempDir, vmOptions, optionsFromFile));
1020 } 1040 }
1021 1041
1022 // some tests require compiling multiple input scripts. 1042 // some tests require compiling multiple input scripts.
1023 List<String> otherScripts = optionsFromFile['otherScripts']; 1043 List<String> otherScripts = optionsFromFile['otherScripts'];
1024 for (String name in otherScripts) { 1044 for (String name in otherScripts) {
1025 Path namePath = new Path(name); 1045 Path namePath = new Path(name);
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
1145 if (executable.endsWith('.dart')) { 1165 if (executable.endsWith('.dart')) {
1146 // Run the compiler script via the Dart VM. 1166 // Run the compiler script via the Dart VM.
1147 args.insert(0, executable); 1167 args.insert(0, executable);
1148 executable = dartShellFileName; 1168 executable = dartShellFileName;
1149 } 1169 }
1150 return CommandBuilder.instance.getCompilationCommand( 1170 return CommandBuilder.instance.getCompilationCommand(
1151 compiler, outputFile, !useSdk, 1171 compiler, outputFile, !useSdk,
1152 dart2JsBootstrapDependencies, compilerPath, args, configurationDir); 1172 dart2JsBootstrapDependencies, compilerPath, args, configurationDir);
1153 } 1173 }
1154 1174
1175 /** Helper to create a Polymer deploy command for a single HTML file. */
1176 Command _polymerDeployCommand(String inputFile, String outputDir,
1177 optionsFromFile) {
1178 List<String> args = [];
1179 String packageRoot = packageRootArgument(optionsFromFile['packageRoot']);
1180 if (packageRoot != null) args.add(packageRoot);
1181 args..add('package:polymer/deploy.dart')
1182 ..add('--test')..add(inputFile)
1183 ..add('--out')..add(outputDir);
1184
1185 return CommandBuilder.instance.getCommand(
1186 'polymer_deploy', vmFileName, args, configurationDir);
1187 }
1188
1155 /** 1189 /**
1156 * Create a directory for the generated test. If a Dart language test 1190 * Create a directory for the generated test. If a Dart language test
1157 * needs to be run in a browser, the Dart test needs to be embedded in 1191 * needs to be run in a browser, the Dart test needs to be embedded in
1158 * an HTML page, with a testing framework based on scripting and DOM events. 1192 * an HTML page, with a testing framework based on scripting and DOM events.
1159 * These scripts and pages are written to a generated_test directory 1193 * These scripts and pages are written to a generated_test directory
1160 * inside the build directory of the checkout. 1194 * inside the build directory of the checkout.
1161 * 1195 *
1162 * Those tests which are already HTML web applications (web tests), with 1196 * Those tests which are already HTML web applications (web tests), with
1163 * resources including CSS files and HTML files, need to be compiled into 1197 * resources including CSS files and HTML files, need to be compiled into
1164 * a work directory where the relative URLS to the resources work. 1198 * a work directory where the relative URLS to the resources work.
(...skipping 827 matching lines...) Expand 10 before | Expand all | Expand 10 after
1992 * $pass tests are expected to pass 2026 * $pass tests are expected to pass
1993 * $failOk tests are expected to fail that we won't fix 2027 * $failOk tests are expected to fail that we won't fix
1994 * $fail tests are expected to fail that we should fix 2028 * $fail tests are expected to fail that we should fix
1995 * $crash tests are expected to crash that we should fix 2029 * $crash tests are expected to crash that we should fix
1996 * $timeout tests are allowed to timeout 2030 * $timeout tests are allowed to timeout
1997 * $compileErrorSkip tests are skipped on browsers due to compile-time error 2031 * $compileErrorSkip tests are skipped on browsers due to compile-time error
1998 """; 2032 """;
1999 print(report); 2033 print(report);
2000 } 2034 }
2001 } 2035 }
OLDNEW
« no previous file with comments | « samples/third_party/todomvc/test/mainpage_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698