Chromium Code Reviews| 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 var arguments = new List.from(vmOptions); |
|
Bill Hesse
2012/08/13 08:13:11
We do not need to add vmOptions to dart2js. They
Anton Muhin
2012/08/13 09:23:34
Done.
| |
| 440 arguments.addAll(args); | |
| 438 String tempDir = createOutputDirectory(info.filePath, ''); | 441 String tempDir = createOutputDirectory(info.filePath, ''); |
| 439 args.add('--out=$tempDir/out.js'); | 442 arguments.add('--out=$tempDir/out.js'); |
| 440 List<Command> commands = <Command>[new Command(shellPath(), args)]; | 443 List<Command> commands = <Command>[new Command(shellPath(), arguments)]; |
| 441 if (configuration['runtime'] == 'd8') { | 444 if (configuration['runtime'] == 'd8') { |
| 442 var d8 = TestUtils.d8FileName(configuration); | 445 var d8 = TestUtils.d8FileName(configuration); |
| 443 commands.add(new Command(d8, ['$tempDir/out.js'])); | 446 commands.add(new Command(d8, ['$tempDir/out.js'])); |
| 444 } | 447 } |
| 445 return commands; | 448 return commands; |
| 446 | 449 |
| 447 case 'dart2dart': | 450 case 'dart2dart': |
| 448 args = new List.from(args); | 451 var compilerArguments = new List.from(args); |
| 449 args.add('--output-type=dart'); | 452 compilerArguments.add('--output-type=dart'); |
| 450 String tempDir = createOutputDirectory(info.filePath, ''); | 453 String tempDir = createOutputDirectory(info.filePath, ''); |
| 451 args.add('--out=$tempDir/out.dart'); | 454 compilerArguments.add('--out=$tempDir/out.dart'); |
| 452 List<Command> commands = <Command>[new Command(shellPath(), args)]; | 455 List<Command> commands = |
| 456 <Command>[new Command(shellPath(), compilerArguments)]; | |
| 453 if (configuration['runtime'] == 'vm') { | 457 if (configuration['runtime'] == 'vm') { |
| 454 // TODO(antonm): support checked. | 458 // TODO(antonm): support checked. |
| 459 var vmArguments = new List.from(vmOptions); | |
|
Bill Hesse
2012/08/13 08:13:11
Let's add runtime == 'vm' before adding vmOptions,
Anton Muhin
2012/08/13 09:23:34
Sorry, I do not quite follow.
On 2012/08/13 08:13
| |
| 460 vmArguments.addAll( | |
| 461 ['--enable_checked_mode', '$tempDir/out.dart']); | |
| 455 commands.add(new Command( | 462 commands.add(new Command( |
| 456 TestUtils.vmFileName(configuration), | 463 TestUtils.vmFileName(configuration), |
| 457 ['--enable_checked_mode', '$tempDir/out.dart'])); | 464 vmArguments)); |
| 458 } else { | 465 } else { |
| 459 throw 'Unsupported runtime ${configuration["runtime"]} for dart2dart'; | 466 throw 'Unsupported runtime ${configuration["runtime"]} for dart2dart'; |
| 460 } | 467 } |
| 461 return commands; | 468 return commands; |
| 462 | 469 |
| 463 default: | 470 default: |
|
Bill Hesse
2012/08/13 08:13:11
Perhaps split the default case into 'none' and 'da
Anton Muhin
2012/08/13 09:23:34
Done.
| |
| 464 return <Command>[new Command(shellPath(), args)]; | 471 var arguments = new List.from(vmOptions); |
| 472 arguments.addAll(args); | |
| 473 return <Command>[new Command(shellPath(), arguments)]; | |
| 465 } | 474 } |
| 466 } | 475 } |
| 467 | 476 |
| 468 Function makeTestCaseCreator(Map optionsFromFile) { | 477 Function makeTestCaseCreator(Map optionsFromFile) { |
| 469 return (Path filePath, | 478 return (Path filePath, |
| 470 bool isNegative, | 479 bool isNegative, |
| 471 [bool isNegativeIfChecked = false, | 480 [bool isNegativeIfChecked = false, |
| 472 bool hasFatalTypeErrors = false, | 481 bool hasFatalTypeErrors = false, |
| 473 bool hasRuntimeErrors = false, | 482 bool hasRuntimeErrors = false, |
| 474 Set<String> multitestOutcome = null]) { | 483 Set<String> multitestOutcome = null]) { |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 820 void directoryListingDone(ignore) { | 829 void directoryListingDone(ignore) { |
| 821 listingDone = true; | 830 listingDone = true; |
| 822 if (activeTestGenerators == 0) { | 831 if (activeTestGenerators == 0) { |
| 823 doDone(); | 832 doDone(); |
| 824 } | 833 } |
| 825 } | 834 } |
| 826 | 835 |
| 827 void completeHandler(TestCase testCase) { | 836 void completeHandler(TestCase testCase) { |
| 828 } | 837 } |
| 829 | 838 |
| 830 List<List<String>> argumentListsFromFile(Path filePath, | 839 List<String> commonArgumentsFromFile(Path filePath, Map optionsFromFile) { |
| 831 Map optionsFromFile) { | |
| 832 List args = TestUtils.standardOptions(configuration); | 840 List args = TestUtils.standardOptions(configuration); |
| 833 args.addAll(additionalOptions(filePath)); | 841 args.addAll(additionalOptions(filePath)); |
| 834 if (configuration['compiler'] == 'dartc') { | 842 if (configuration['compiler'] == 'dartc') { |
| 835 args.add('--error_format'); | 843 args.add('--error_format'); |
| 836 args.add('machine'); | 844 args.add('machine'); |
| 837 } | 845 } |
| 838 if ((configuration['compiler'] == 'frog') | 846 if ((configuration['compiler'] == 'frog') |
| 839 && (configuration['runtime'] == 'none')) { | 847 && (configuration['runtime'] == 'none')) { |
| 840 args.add('--compile-only'); | 848 args.add('--compile-only'); |
| 841 } | 849 } |
| 842 | 850 |
| 843 bool isMultitest = optionsFromFile["isMultitest"]; | 851 bool isMultitest = optionsFromFile["isMultitest"]; |
| 844 List<String> dartOptions = optionsFromFile["dartOptions"]; | 852 List<String> dartOptions = optionsFromFile["dartOptions"]; |
| 845 List<List<String>> vmOptionsList = getVmOptions(optionsFromFile); | 853 List<List<String>> vmOptionsList = getVmOptions(optionsFromFile); |
| 846 Expect.isTrue(!isMultitest || dartOptions == null); | 854 Expect.isTrue(!isMultitest || dartOptions == null); |
| 847 if (dartOptions == null) { | 855 if (dartOptions == null) { |
| 848 args.add(filePath.toNativePath()); | 856 args.add(filePath.toNativePath()); |
| 849 } else { | 857 } else { |
| 850 var executable_name = dartOptions[0]; | 858 var executable_name = dartOptions[0]; |
| 851 // TODO(ager): Get rid of this hack when the runtime checkout goes away. | 859 // TODO(ager): Get rid of this hack when the runtime checkout goes away. |
| 852 var file = new File(executable_name); | 860 var file = new File(executable_name); |
| 853 if (!file.existsSync()) { | 861 if (!file.existsSync()) { |
| 854 executable_name = '../$executable_name'; | 862 executable_name = '../$executable_name'; |
| 855 Expect.isTrue(new File(executable_name).existsSync()); | 863 Expect.isTrue(new File(executable_name).existsSync()); |
| 856 dartOptions[0] = executable_name; | 864 dartOptions[0] = executable_name; |
| 857 } | 865 } |
| 858 args.addAll(dartOptions); | 866 args.addAll(dartOptions); |
| 859 } | 867 } |
| 860 | 868 |
| 861 var result = new List<List<String>>(); | 869 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 } | 870 } |
| 871 | 871 |
| 872 /** | 872 /** |
| 873 * Special options for individual tests are currently specified in various | 873 * Special options for individual tests are currently specified in various |
| 874 * ways: with comments directly in test files, by using certain imports, or by | 874 * ways: with comments directly in test files, by using certain imports, or by |
| 875 * creating additional files in the test directories. | 875 * creating additional files in the test directories. |
| 876 * | 876 * |
| 877 * Here is a list of options that are used by 'test.dart' today: | 877 * 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 | 878 * - Flags can be passed to the vm or dartium process that runs the test by |
| 879 * adding a comment to the test file: | 879 * adding a comment to the test file: |
| (...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1427 * $noCrash tests are expected to be flaky but not crash | 1427 * $noCrash tests are expected to be flaky but not crash |
| 1428 * $pass tests are expected to pass | 1428 * $pass tests are expected to pass |
| 1429 * $failOk tests are expected to fail that we won't fix | 1429 * $failOk tests are expected to fail that we won't fix |
| 1430 * $fail tests are expected to fail that we should fix | 1430 * $fail tests are expected to fail that we should fix |
| 1431 * $crash tests are expected to crash that we should fix | 1431 * $crash tests are expected to crash that we should fix |
| 1432 * $timeout tests are allowed to timeout | 1432 * $timeout tests are allowed to timeout |
| 1433 """; | 1433 """; |
| 1434 print(report); | 1434 print(report); |
| 1435 } | 1435 } |
| 1436 } | 1436 } |
| OLD | NEW |