| 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 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 410 if (configuration['compiler'] == 'dartc') { | 410 if (configuration['compiler'] == 'dartc') { |
| 411 // dartc can detect static type warnings by the | 411 // dartc can detect static type warnings by the |
| 412 // format of the error line | 412 // format of the error line |
| 413 if (info.hasFatalTypeErrors) { | 413 if (info.hasFatalTypeErrors) { |
| 414 isNegative = true; | 414 isNegative = true; |
| 415 } else if (info.hasRuntimeErrors) { | 415 } else if (info.hasRuntimeErrors) { |
| 416 isNegative = false; | 416 isNegative = false; |
| 417 } | 417 } |
| 418 } | 418 } |
| 419 | 419 |
| 420 var argumentLists = argumentListsFromFile(info.filePath, | 420 var commonArguments = commonArgumentsFromFile(info.filePath, |
| 421 info.optionsFromFile); | 421 info.optionsFromFile); |
| 422 | 422 |
| 423 for (var args in argumentLists) { | 423 List<List<String>> vmOptionsList = getVmOptions(info.optionsFromFile); |
| 424 Expect.isFalse(vmOptionsList.isEmpty(), "empty vmOptionsList"); |
| 425 for (var vmOptions in vmOptionsList) { |
| 424 doTest(new TestCase('$suiteName/$testName', | 426 doTest(new TestCase('$suiteName/$testName', |
| 425 makeCommands(info, args), | 427 makeCommands(info, vmOptions, commonArguments), |
| 426 configuration, | 428 configuration, |
| 427 completeHandler, | 429 completeHandler, |
| 428 expectations, | 430 expectations, |
| 429 isNegative, | 431 isNegative, |
| 430 info)); | 432 info)); |
| 431 } | 433 } |
| 432 } | 434 } |
| 433 | 435 |
| 434 List<Command> makeCommands(TestInformation info, var args) { | 436 List<Command> makeCommands(TestInformation info, var vmOptions, var args) { |
| 435 switch (configuration['compiler']) { | 437 switch (configuration['compiler']) { |
| 436 case 'dart2js': | 438 case 'dart2js': |
| 437 args = new List.from(args); | 439 args = new List.from(args); |
| 438 String tempDir = createOutputDirectory(info.filePath, ''); | 440 String tempDir = createOutputDirectory(info.filePath, ''); |
| 439 args.add('--out=$tempDir/out.js'); | 441 args.add('--out=$tempDir/out.js'); |
| 440 List<Command> commands = <Command>[new Command(shellPath(), args)]; | 442 List<Command> commands = <Command>[new Command(shellPath(), args)]; |
| 441 if (configuration['runtime'] == 'd8') { | 443 if (configuration['runtime'] == 'd8') { |
| 442 var d8 = TestUtils.d8FileName(configuration); | 444 var d8 = TestUtils.d8FileName(configuration); |
| 443 commands.add(new Command(d8, ['$tempDir/out.js'])); | 445 commands.add(new Command(d8, ['$tempDir/out.js'])); |
| 444 } | 446 } |
| 445 return commands; | 447 return commands; |
| 446 | 448 |
| 447 case 'dart2dart': | 449 case 'dart2dart': |
| 448 args = new List.from(args); | 450 var compilerArguments = new List.from(args); |
| 449 args.add('--output-type=dart'); | 451 compilerArguments.add('--output-type=dart'); |
| 450 String tempDir = createOutputDirectory(info.filePath, ''); | 452 String tempDir = createOutputDirectory(info.filePath, ''); |
| 451 args.add('--out=$tempDir/out.dart'); | 453 compilerArguments.add('--out=$tempDir/out.dart'); |
| 452 List<Command> commands = <Command>[new Command(shellPath(), args)]; | 454 List<Command> commands = |
| 455 <Command>[new Command(shellPath(), compilerArguments)]; |
| 453 if (configuration['runtime'] == 'vm') { | 456 if (configuration['runtime'] == 'vm') { |
| 454 // TODO(antonm): support checked. | 457 // TODO(antonm): support checked. |
| 458 var vmArguments = new List.from(vmOptions); |
| 459 vmArguments.addAll( |
| 460 ['--enable_checked_mode', '$tempDir/out.dart']); |
| 455 commands.add(new Command( | 461 commands.add(new Command( |
| 456 TestUtils.vmFileName(configuration), | 462 TestUtils.vmFileName(configuration), |
| 457 ['--enable_checked_mode', '$tempDir/out.dart'])); | 463 vmArguments)); |
| 458 } else { | 464 } else { |
| 459 throw 'Unsupported runtime ${configuration["runtime"]} for dart2dart'; | 465 throw 'Unsupported runtime ${configuration["runtime"]} for dart2dart'; |
| 460 } | 466 } |
| 461 return commands; | 467 return commands; |
| 462 | 468 |
| 469 case 'none': |
| 470 var arguments = new List.from(vmOptions); |
| 471 arguments.addAll(args); |
| 472 return <Command>[new Command(shellPath(), arguments)]; |
| 473 |
| 474 case 'dartc': |
| 475 return <Command>[new Command(shellPath(), args)]; |
| 476 |
| 463 default: | 477 default: |
| 464 return <Command>[new Command(shellPath(), args)]; | 478 throw 'Unknown compiler ${configuration["compiler"]}'; |
| 465 } | 479 } |
| 466 } | 480 } |
| 467 | 481 |
| 468 Function makeTestCaseCreator(Map optionsFromFile) { | 482 Function makeTestCaseCreator(Map optionsFromFile) { |
| 469 return (Path filePath, | 483 return (Path filePath, |
| 470 bool isNegative, | 484 bool isNegative, |
| 471 [bool isNegativeIfChecked = false, | 485 [bool isNegativeIfChecked = false, |
| 472 bool hasFatalTypeErrors = false, | 486 bool hasFatalTypeErrors = false, |
| 473 bool hasRuntimeErrors = false, | 487 bool hasRuntimeErrors = false, |
| 474 Set<String> multitestOutcome = null]) { | 488 Set<String> multitestOutcome = null]) { |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 820 void directoryListingDone(ignore) { | 834 void directoryListingDone(ignore) { |
| 821 listingDone = true; | 835 listingDone = true; |
| 822 if (activeTestGenerators == 0) { | 836 if (activeTestGenerators == 0) { |
| 823 doDone(); | 837 doDone(); |
| 824 } | 838 } |
| 825 } | 839 } |
| 826 | 840 |
| 827 void completeHandler(TestCase testCase) { | 841 void completeHandler(TestCase testCase) { |
| 828 } | 842 } |
| 829 | 843 |
| 830 List<List<String>> argumentListsFromFile(Path filePath, | 844 List<String> commonArgumentsFromFile(Path filePath, Map optionsFromFile) { |
| 831 Map optionsFromFile) { | |
| 832 List args = TestUtils.standardOptions(configuration); | 845 List args = TestUtils.standardOptions(configuration); |
| 833 args.addAll(additionalOptions(filePath)); | 846 args.addAll(additionalOptions(filePath)); |
| 834 if (configuration['compiler'] == 'dartc') { | 847 if (configuration['compiler'] == 'dartc') { |
| 835 args.add('--error_format'); | 848 args.add('--error_format'); |
| 836 args.add('machine'); | 849 args.add('machine'); |
| 837 } | 850 } |
| 838 if ((configuration['compiler'] == 'frog') | 851 if ((configuration['compiler'] == 'frog') |
| 839 && (configuration['runtime'] == 'none')) { | 852 && (configuration['runtime'] == 'none')) { |
| 840 args.add('--compile-only'); | 853 args.add('--compile-only'); |
| 841 } | 854 } |
| 842 | 855 |
| 843 bool isMultitest = optionsFromFile["isMultitest"]; | 856 bool isMultitest = optionsFromFile["isMultitest"]; |
| 844 List<String> dartOptions = optionsFromFile["dartOptions"]; | 857 List<String> dartOptions = optionsFromFile["dartOptions"]; |
| 845 List<List<String>> vmOptionsList = getVmOptions(optionsFromFile); | 858 List<List<String>> vmOptionsList = getVmOptions(optionsFromFile); |
| 846 Expect.isTrue(!isMultitest || dartOptions == null); | 859 Expect.isTrue(!isMultitest || dartOptions == null); |
| 847 if (dartOptions == null) { | 860 if (dartOptions == null) { |
| 848 args.add(filePath.toNativePath()); | 861 args.add(filePath.toNativePath()); |
| 849 } else { | 862 } else { |
| 850 var executable_name = dartOptions[0]; | 863 var executable_name = dartOptions[0]; |
| 851 // TODO(ager): Get rid of this hack when the runtime checkout goes away. | 864 // TODO(ager): Get rid of this hack when the runtime checkout goes away. |
| 852 var file = new File(executable_name); | 865 var file = new File(executable_name); |
| 853 if (!file.existsSync()) { | 866 if (!file.existsSync()) { |
| 854 executable_name = '../$executable_name'; | 867 executable_name = '../$executable_name'; |
| 855 Expect.isTrue(new File(executable_name).existsSync()); | 868 Expect.isTrue(new File(executable_name).existsSync()); |
| 856 dartOptions[0] = executable_name; | 869 dartOptions[0] = executable_name; |
| 857 } | 870 } |
| 858 args.addAll(dartOptions); | 871 args.addAll(dartOptions); |
| 859 } | 872 } |
| 860 | 873 |
| 861 var result = new List<List<String>>(); | 874 return args; |
| 862 Expect.isFalse(vmOptionsList.isEmpty(), "empty vmOptionsList"); | |
| 863 for (var vmOptions in vmOptionsList) { | |
| 864 var options = new List<String>.from(vmOptions); | |
| 865 options.addAll(args); | |
| 866 result.add(options); | |
| 867 } | |
| 868 | |
| 869 return result; | |
| 870 } | 875 } |
| 871 | 876 |
| 872 /** | 877 /** |
| 873 * Special options for individual tests are currently specified in various | 878 * Special options for individual tests are currently specified in various |
| 874 * ways: with comments directly in test files, by using certain imports, or by | 879 * ways: with comments directly in test files, by using certain imports, or by |
| 875 * creating additional files in the test directories. | 880 * creating additional files in the test directories. |
| 876 * | 881 * |
| 877 * Here is a list of options that are used by 'test.dart' today: | 882 * Here is a list of options that are used by 'test.dart' today: |
| 878 * - Flags can be passed to the vm or dartium process that runs the test by | 883 * - Flags can be passed to the vm or dartium process that runs the test by |
| 879 * adding a comment to the test file: | 884 * adding a comment to the test file: |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1024 "containsLeadingHash": containsLeadingHash, | 1029 "containsLeadingHash": containsLeadingHash, |
| 1025 "isolateStubs": isolateStubs, | 1030 "isolateStubs": isolateStubs, |
| 1026 "containsDomImport": containsDomImport, | 1031 "containsDomImport": containsDomImport, |
| 1027 "isLibraryDefinition": isLibraryDefinition, | 1032 "isLibraryDefinition": isLibraryDefinition, |
| 1028 "containsSourceOrImport": containsSourceOrImport, | 1033 "containsSourceOrImport": containsSourceOrImport, |
| 1029 "numStaticTypeAnnotations": numStaticTypeAnnotations, | 1034 "numStaticTypeAnnotations": numStaticTypeAnnotations, |
| 1030 "numCompileTimeAnnotations": numCompileTimeAnnotations}; | 1035 "numCompileTimeAnnotations": numCompileTimeAnnotations}; |
| 1031 } | 1036 } |
| 1032 | 1037 |
| 1033 List<List<String>> getVmOptions(Map optionsFromFile) { | 1038 List<List<String>> getVmOptions(Map optionsFromFile) { |
| 1034 if (configuration['compiler'] == 'dart2js') { | 1039 bool needsVmOptions = |
| 1035 return [[]]; | 1040 Contains(configuration['compiler'], const ['none', 'dart2dart']) && |
| 1036 } else { | 1041 Contains(configuration['runtime'], const ['vm', 'drt', 'dartium']); |
| 1037 return optionsFromFile['vmOptions']; | 1042 if (!needsVmOptions) return [[]]; |
| 1038 } | 1043 return optionsFromFile['vmOptions']; |
| 1039 } | 1044 } |
| 1040 } | 1045 } |
| 1041 | 1046 |
| 1042 | 1047 |
| 1043 class DartcCompilationTestSuite extends StandardTestSuite { | 1048 class DartcCompilationTestSuite extends StandardTestSuite { |
| 1044 List<String> _testDirs; | 1049 List<String> _testDirs; |
| 1045 int activityCount = 0; | 1050 int activityCount = 0; |
| 1046 | 1051 |
| 1047 DartcCompilationTestSuite(Map configuration, | 1052 DartcCompilationTestSuite(Map configuration, |
| 1048 String suiteName, | 1053 String suiteName, |
| (...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1427 * $noCrash tests are expected to be flaky but not crash | 1432 * $noCrash tests are expected to be flaky but not crash |
| 1428 * $pass tests are expected to pass | 1433 * $pass tests are expected to pass |
| 1429 * $failOk tests are expected to fail that we won't fix | 1434 * $failOk tests are expected to fail that we won't fix |
| 1430 * $fail tests are expected to fail that we should fix | 1435 * $fail tests are expected to fail that we should fix |
| 1431 * $crash tests are expected to crash that we should fix | 1436 * $crash tests are expected to crash that we should fix |
| 1432 * $timeout tests are allowed to timeout | 1437 * $timeout tests are allowed to timeout |
| 1433 """; | 1438 """; |
| 1434 print(report); | 1439 print(report); |
| 1435 } | 1440 } |
| 1436 } | 1441 } |
| OLD | NEW |