| 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 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 */ | 421 */ |
| 422 class StandardTestSuite extends TestSuite { | 422 class StandardTestSuite extends TestSuite { |
| 423 final Path suiteDir; | 423 final Path suiteDir; |
| 424 final List<String> statusFilePaths; | 424 final List<String> statusFilePaths; |
| 425 TestCaseEvent doTest; | 425 TestCaseEvent doTest; |
| 426 TestExpectations testExpectations; | 426 TestExpectations testExpectations; |
| 427 List<TestInformation> cachedTests; | 427 List<TestInformation> cachedTests; |
| 428 final Path dartDir; | 428 final Path dartDir; |
| 429 Predicate<String> isTestFilePredicate; | 429 Predicate<String> isTestFilePredicate; |
| 430 final bool listRecursively; | 430 final bool listRecursively; |
| 431 final extraVmOptions; |
| 431 | 432 |
| 432 static final RegExp multiTestRegExp = new RegExp(r"/// [0-9][0-9]:(.*)"); | 433 static final RegExp multiTestRegExp = new RegExp(r"/// [0-9][0-9]:(.*)"); |
| 433 | 434 |
| 435 |
| 434 StandardTestSuite(Map configuration, | 436 StandardTestSuite(Map configuration, |
| 435 String suiteName, | 437 String suiteName, |
| 436 Path suiteDirectory, | 438 Path suiteDirectory, |
| 437 this.statusFilePaths, | 439 this.statusFilePaths, |
| 438 {this.isTestFilePredicate, | 440 {this.isTestFilePredicate, |
| 439 bool recursive: false}) | 441 bool recursive: false}) |
| 440 : super(configuration, suiteName), | 442 : super(configuration, suiteName), |
| 441 dartDir = TestUtils.dartDir(), | 443 dartDir = TestUtils.dartDir(), |
| 442 listRecursively = recursive, | 444 listRecursively = recursive, |
| 443 suiteDir = TestUtils.dartDir().join(suiteDirectory); | 445 suiteDir = TestUtils.dartDir().join(suiteDirectory), |
| 446 extraVmOptions = TestUtils.getExtraVmOptions(configuration); |
| 444 | 447 |
| 445 /** | 448 /** |
| 446 * Creates a test suite whose file organization matches an expected structure. | 449 * Creates a test suite whose file organization matches an expected structure. |
| 447 * To use this, your suite should look like: | 450 * To use this, your suite should look like: |
| 448 * | 451 * |
| 449 * dart/ | 452 * dart/ |
| 450 * path/ | 453 * path/ |
| 451 * to/ | 454 * to/ |
| 452 * mytestsuite/ | 455 * mytestsuite/ |
| 453 * mytestsuite.status | 456 * mytestsuite.status |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 729 } | 732 } |
| 730 } | 733 } |
| 731 | 734 |
| 732 var commonArguments = commonArgumentsFromFile(info.filePath, | 735 var commonArguments = commonArgumentsFromFile(info.filePath, |
| 733 info.optionsFromFile); | 736 info.optionsFromFile); |
| 734 | 737 |
| 735 List<List<String>> vmOptionsList = getVmOptions(info.optionsFromFile); | 738 List<List<String>> vmOptionsList = getVmOptions(info.optionsFromFile); |
| 736 assert(!vmOptionsList.isEmpty); | 739 assert(!vmOptionsList.isEmpty); |
| 737 | 740 |
| 738 for (var vmOptions in vmOptionsList) { | 741 for (var vmOptions in vmOptionsList) { |
| 742 var allVmOptions = vmOptions; |
| 743 if (!extraVmOptions.isEmpty) { |
| 744 allVmOptions = new List.from(vmOptions)..addAll(extraVmOptions); |
| 745 } |
| 746 |
| 739 doTest(new TestCase('$suiteName/$testName', | 747 doTest(new TestCase('$suiteName/$testName', |
| 740 makeCommands(info, vmOptions, commonArguments), | 748 makeCommands(info, allVmOptions, commonArguments), |
| 741 configuration, | 749 configuration, |
| 742 completeHandler, | 750 completeHandler, |
| 743 expectations, | 751 expectations, |
| 744 isNegative: isNegative, | 752 isNegative: isNegative, |
| 745 info: info)); | 753 info: info)); |
| 746 } | 754 } |
| 747 } | 755 } |
| 748 | 756 |
| 749 List<Command> makeCommands(TestInformation info, var vmOptions, var args) { | 757 List<Command> makeCommands(TestInformation info, var vmOptions, var args) { |
| 750 var compiler = configuration['compiler']; | 758 var compiler = configuration['compiler']; |
| (...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1238 if (packageRoot != null) { | 1246 if (packageRoot != null) { |
| 1239 args.add(packageRoot); | 1247 args.add(packageRoot); |
| 1240 } | 1248 } |
| 1241 args.addAll(additionalOptions(filePath)); | 1249 args.addAll(additionalOptions(filePath)); |
| 1242 if (configuration['analyzer']) { | 1250 if (configuration['analyzer']) { |
| 1243 args.add('--machine'); | 1251 args.add('--machine'); |
| 1244 } | 1252 } |
| 1245 | 1253 |
| 1246 bool isMultitest = optionsFromFile["isMultitest"]; | 1254 bool isMultitest = optionsFromFile["isMultitest"]; |
| 1247 List<String> dartOptions = optionsFromFile["dartOptions"]; | 1255 List<String> dartOptions = optionsFromFile["dartOptions"]; |
| 1248 List<List<String>> vmOptionsList = getVmOptions(optionsFromFile); | 1256 |
| 1249 assert(!isMultitest || dartOptions == null); | 1257 assert(!isMultitest || dartOptions == null); |
| 1250 if (dartOptions == null) { | 1258 if (dartOptions == null) { |
| 1251 args.add(filePath.toNativePath()); | 1259 args.add(filePath.toNativePath()); |
| 1252 } else { | 1260 } else { |
| 1253 var executable_name = dartOptions[0]; | 1261 var executable_name = dartOptions[0]; |
| 1254 // TODO(ager): Get rid of this hack when the runtime checkout goes away. | 1262 // TODO(ager): Get rid of this hack when the runtime checkout goes away. |
| 1255 var file = new File(executable_name); | 1263 var file = new File(executable_name); |
| 1256 if (!file.existsSync()) { | 1264 if (!file.existsSync()) { |
| 1257 executable_name = '../$executable_name'; | 1265 executable_name = '../$executable_name'; |
| 1258 assert(new File(executable_name).existsSync()); | 1266 assert(new File(executable_name).existsSync()); |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1461 "numCompileTimeAnnotations": numCompileTimeAnnotations }; | 1469 "numCompileTimeAnnotations": numCompileTimeAnnotations }; |
| 1462 } | 1470 } |
| 1463 | 1471 |
| 1464 List<List<String>> getVmOptions(Map optionsFromFile) { | 1472 List<List<String>> getVmOptions(Map optionsFromFile) { |
| 1465 var COMPILERS = const ['none', 'dart2dart']; | 1473 var COMPILERS = const ['none', 'dart2dart']; |
| 1466 var RUNTIMES = const ['none', 'vm', 'drt', 'dartium']; | 1474 var RUNTIMES = const ['none', 'vm', 'drt', 'dartium']; |
| 1467 var needsVmOptions = COMPILERS.contains(configuration['compiler']) && | 1475 var needsVmOptions = COMPILERS.contains(configuration['compiler']) && |
| 1468 RUNTIMES.contains(configuration['runtime']); | 1476 RUNTIMES.contains(configuration['runtime']); |
| 1469 if (!needsVmOptions) return [[]]; | 1477 if (!needsVmOptions) return [[]]; |
| 1470 final vmOptions = optionsFromFile['vmOptions']; | 1478 final vmOptions = optionsFromFile['vmOptions']; |
| 1479 |
| 1471 if (configuration['compiler'] != 'dart2dart') return vmOptions; | 1480 if (configuration['compiler'] != 'dart2dart') return vmOptions; |
| 1472 // Temporary workaround for race in test suite: tests with different | 1481 // Temporary workaround for race in test suite: tests with different |
| 1473 // vm options are still compiled into the same output file which | 1482 // vm options are still compiled into the same output file which |
| 1474 // may lead to reads from empty files. | 1483 // may lead to reads from empty files. |
| 1475 return [vmOptions[0]]; | 1484 return [vmOptions[0]]; |
| 1476 } | 1485 } |
| 1477 | 1486 |
| 1478 /** | 1487 /** |
| 1479 * Read options from a co19 test file. | 1488 * Read options from a co19 test file. |
| 1480 * | 1489 * |
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1906 * bootstrapping test.dart. | 1915 * bootstrapping test.dart. |
| 1907 */ | 1916 */ |
| 1908 static Path get dartTestExecutable { | 1917 static Path get dartTestExecutable { |
| 1909 var path = '${TestUtils.dartDir()}/tools/testing/bin/' | 1918 var path = '${TestUtils.dartDir()}/tools/testing/bin/' |
| 1910 '${Platform.operatingSystem}/dart'; | 1919 '${Platform.operatingSystem}/dart'; |
| 1911 if (Platform.operatingSystem == 'windows') { | 1920 if (Platform.operatingSystem == 'windows') { |
| 1912 path = '$path.exe'; | 1921 path = '$path.exe'; |
| 1913 } | 1922 } |
| 1914 return new Path(path); | 1923 return new Path(path); |
| 1915 } | 1924 } |
| 1925 |
| 1926 /** |
| 1927 * Gets extra vm options passed to the testing script. |
| 1928 */ |
| 1929 static List<String> getExtraVmOptions(Map configuration) { |
| 1930 var extraVmOptions = []; |
| 1931 if (configuration['vm-options'] != null) { |
| 1932 extraVmOptions = configuration['vm-options'].split(" "); |
| 1933 extraVmOptions.removeWhere((s) => s.trim() == ""); |
| 1934 } |
| 1935 return extraVmOptions; |
| 1936 } |
| 1937 |
| 1938 |
| 1916 } | 1939 } |
| 1917 | 1940 |
| 1918 class SummaryReport { | 1941 class SummaryReport { |
| 1919 static int total = 0; | 1942 static int total = 0; |
| 1920 static int skipped = 0; | 1943 static int skipped = 0; |
| 1921 static int noCrash = 0; | 1944 static int noCrash = 0; |
| 1922 static int pass = 0; | 1945 static int pass = 0; |
| 1923 static int failOk = 0; | 1946 static int failOk = 0; |
| 1924 static int fail = 0; | 1947 static int fail = 0; |
| 1925 static int crash = 0; | 1948 static int crash = 0; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1966 * $pass tests are expected to pass | 1989 * $pass tests are expected to pass |
| 1967 * $failOk tests are expected to fail that we won't fix | 1990 * $failOk tests are expected to fail that we won't fix |
| 1968 * $fail tests are expected to fail that we should fix | 1991 * $fail tests are expected to fail that we should fix |
| 1969 * $crash tests are expected to crash that we should fix | 1992 * $crash tests are expected to crash that we should fix |
| 1970 * $timeout tests are allowed to timeout | 1993 * $timeout tests are allowed to timeout |
| 1971 * $compileErrorSkip tests are skipped on browsers due to compile-time error | 1994 * $compileErrorSkip tests are skipped on browsers due to compile-time error |
| 1972 """; | 1995 """; |
| 1973 print(report); | 1996 print(report); |
| 1974 } | 1997 } |
| 1975 } | 1998 } |
| OLD | NEW |