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

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

Issue 148913003: Improve how we handle packages/ HTML imports. This resolves better any valid (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 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
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 808 matching lines...) Expand 10 before | Expand all | Expand 10 after
819 if (optionsFromFile['isMultitest']) { 819 if (optionsFromFile['isMultitest']) {
820 group.add(doMultitest(filePath, buildDir, suiteDir, createTestCase)); 820 group.add(doMultitest(filePath, buildDir, suiteDir, createTestCase));
821 } else { 821 } else {
822 createTestCase(filePath, 822 createTestCase(filePath,
823 optionsFromFile['hasCompileError'], 823 optionsFromFile['hasCompileError'],
824 optionsFromFile['hasRuntimeError'], 824 optionsFromFile['hasRuntimeError'],
825 hasStaticWarning: optionsFromFile['hasStaticWarning']); 825 hasStaticWarning: optionsFromFile['hasStaticWarning']);
826 } 826 }
827 } 827 }
828 828
829 static Path _findPubspecYamlFile(Path filePath) {
Siggi Cherem (dart-lang) 2014/01/29 22:15:08 no changes here, I just extracted it and made it p
830 final existsCache = TestUtils.existsCache;
831
832 Path root = TestUtils.dartDir();
833 assert ("$filePath".startsWith("$root"));
834
835 // We start with the parent directory of [filePath] and go up until
836 // the root directory (excluding the root).
837 List<String> segments =
838 filePath.directoryPath.relativeTo(root).segments();
839 while (segments.length > 0) {
840 var pubspecYamlPath =
841 new Path(segments.join('/')).append('pubspec.yaml');
842 if (existsCache.doesFileExist(pubspecYamlPath.toNativePath())) {
843 return root.join(pubspecYamlPath);
844 }
845 segments.removeLast();
846 }
847 return null;
848 }
849
829 void enqueueTestCaseFromTestInformation(TestInformation info) { 850 void enqueueTestCaseFromTestInformation(TestInformation info) {
830 var filePath = info.filePath; 851 var filePath = info.filePath;
831 var optionsFromFile = info.optionsFromFile; 852 var optionsFromFile = info.optionsFromFile;
832 853
833 Path findPubspecYamlFile(Path filePath) {
834 final existsCache = TestUtils.existsCache;
835
836 Path root = TestUtils.dartDir();
837 assert ("$filePath".startsWith("$root"));
838
839 // We start with the parent directory of [filePath] and go up until
840 // the root directory (excluding the root).
841 List<String> segments =
842 filePath.directoryPath.relativeTo(root).segments();
843 while (segments.length > 0) {
844 var pubspecYamlPath =
845 new Path(segments.join('/')).append('pubspec.yaml');
846 if (existsCache.doesFileExist(pubspecYamlPath.toNativePath())) {
847 return root.join(pubspecYamlPath);
848 }
849 segments.removeLast();
850 }
851 return null;
852 }
853
854 Map buildSpecialPackageRoot(Path pubspecYamlFile) { 854 Map buildSpecialPackageRoot(Path pubspecYamlFile) {
855 var commands = <Command>[]; 855 var commands = <Command>[];
856 var packageDir = pubspecYamlFile.directoryPath; 856 var packageDir = pubspecYamlFile.directoryPath;
857 var packageName = packageDir.filename; 857 var packageName = packageDir.filename;
858 858
859 var checkoutDirectory = 859 var checkoutDirectory =
860 createPubspecCheckoutDirectory(packageDir); 860 createPubspecCheckoutDirectory(packageDir);
861 var modifiedYamlFile = new Path(checkoutDirectory).append("pubspec.yaml"); 861 var modifiedYamlFile = new Path(checkoutDirectory).append("pubspec.yaml");
862 var pubCacheDirectory = new Path(checkoutDirectory).append("pub-cache"); 862 var pubCacheDirectory = new Path(checkoutDirectory).append("pub-cache");
863 var newPackageRoot = new Path(checkoutDirectory).append("packages"); 863 var newPackageRoot = new Path(checkoutDirectory).append("packages");
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
908 'package-root' : newPackageRoot, 908 'package-root' : newPackageRoot,
909 }; 909 };
910 } 910 }
911 911
912 // If this test is inside a package, we will check if there is a 912 // If this test is inside a package, we will check if there is a
913 // pubspec.yaml file and if so, create a custom package root for it. 913 // pubspec.yaml file and if so, create a custom package root for it.
914 List<Command> baseCommands = <Command>[]; 914 List<Command> baseCommands = <Command>[];
915 Path packageRoot; 915 Path packageRoot;
916 if (configuration['use_repository_packages'] || 916 if (configuration['use_repository_packages'] ||
917 configuration['use_public_packages']) { 917 configuration['use_public_packages']) {
918 Path pubspecYamlFile = findPubspecYamlFile(filePath); 918 Path pubspecYamlFile = _findPubspecYamlFile(filePath);
919 if (pubspecYamlFile != null) { 919 if (pubspecYamlFile != null) {
920 var result = buildSpecialPackageRoot(pubspecYamlFile); 920 var result = buildSpecialPackageRoot(pubspecYamlFile);
921 baseCommands.addAll(result['commands']); 921 baseCommands.addAll(result['commands']);
922 packageRoot = result['package-root']; 922 packageRoot = result['package-root'];
923 if (optionsFromFile['packageRoot'] == null || 923 if (optionsFromFile['packageRoot'] == null ||
924 optionsFromFile['packageRoot'] == "") { 924 optionsFromFile['packageRoot'] == "") {
925 optionsFromFile['packageRoot'] = packageRoot.toNativePath(); 925 optionsFromFile['packageRoot'] = packageRoot.toNativePath();
926 } 926 }
927 } 927 }
928 } 928 }
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
1231 String htmlPath; 1231 String htmlPath;
1232 if (customHtml.existsSync()) { 1232 if (customHtml.existsSync()) {
1233 // If necessary, run the Polymer deploy steps. 1233 // If necessary, run the Polymer deploy steps.
1234 // TODO(jmesserly): this should be generalized for any tests that 1234 // TODO(jmesserly): this should be generalized for any tests that
1235 // require Pub deploy, not just polymer. 1235 // require Pub deploy, not just polymer.
1236 if (customHtml.readAsStringSync().contains('<!--polymer-test')) { 1236 if (customHtml.readAsStringSync().contains('<!--polymer-test')) {
1237 if (compiler != 'none') { 1237 if (compiler != 'none') {
1238 commands.add(_polymerDeployCommand( 1238 commands.add(_polymerDeployCommand(
1239 customHtmlPath, tempDir, optionsFromFile)); 1239 customHtmlPath, tempDir, optionsFromFile));
1240 1240
1241 htmlPath = '$tempDir/test/$nameNoExt.html'; 1241 Path pubspecYamlFile = _findPubspecYamlFile(filePath);
1242 Path homeDir = pubspecYamlFile == null ? dir :
1243 pubspecYamlFile.directoryPath;
1244 htmlPath = '$tempDir/${dir.relativeTo(homeDir)}/$nameNoExt.html';
1242 dartWrapperFilename = '${htmlPath}_bootstrap.dart'; 1245 dartWrapperFilename = '${htmlPath}_bootstrap.dart';
1243 compiledDartWrapperFilename = '$dartWrapperFilename.js'; 1246 compiledDartWrapperFilename = '$dartWrapperFilename.js';
1244 } else { 1247 } else {
1245 htmlPath = customHtmlPath; 1248 htmlPath = customHtmlPath;
1246 } 1249 }
1247 } else { 1250 } else {
1248 htmlPath = '$tempDir/test.html'; 1251 htmlPath = '$tempDir/test.html';
1249 dartWrapperFilename = filePath.toNativePath(); 1252 dartWrapperFilename = filePath.toNativePath();
1250 1253
1251 var htmlContents = customHtml.readAsStringSync(); 1254 var htmlContents = customHtml.readAsStringSync();
(...skipping 1012 matching lines...) Expand 10 before | Expand all | Expand 10 after
2264 * $pass tests are expected to pass 2267 * $pass tests are expected to pass
2265 * $failOk tests are expected to fail that we won't fix 2268 * $failOk tests are expected to fail that we won't fix
2266 * $fail tests are expected to fail that we should fix 2269 * $fail tests are expected to fail that we should fix
2267 * $crash tests are expected to crash that we should fix 2270 * $crash tests are expected to crash that we should fix
2268 * $timeout tests are allowed to timeout 2271 * $timeout tests are allowed to timeout
2269 * $compileErrorSkip tests are skipped on browsers due to compile-time error 2272 * $compileErrorSkip tests are skipped on browsers due to compile-time error
2270 """; 2273 """;
2271 print(report); 2274 print(report);
2272 } 2275 }
2273 } 2276 }
OLDNEW
« tools/testing/dart/test_controller.js ('K') | « tools/testing/dart/test_controller.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698