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

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

Issue 23702055: test.py: Support for CompileTimeError,RuntimeError,MissingRuntimeError,MissingCompiletimeError mark… (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
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 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 if (testCase.info != null && 291 if (testCase.info != null &&
292 testCase.info.hasCompileError && 292 testCase.info.hasCompileError &&
293 TestUtils.isBrowserRuntime(configuration['runtime']) && 293 TestUtils.isBrowserRuntime(configuration['runtime']) &&
294 configuration['compiler'] != 'none') { 294 configuration['compiler'] != 'none') {
295 SummaryReport.addCompileErrorSkipTest(); 295 SummaryReport.addCompileErrorSkipTest();
296 return; 296 return;
297 } 297 }
298 } 298 }
299 299
300 // Handle skipped tests 300 // Handle skipped tests
301 if (expectations.contains(SKIP) || 301 if (expectations.contains(Expectation.SKIP) ||
302 expectations.contains(SKIP_BY_DESIGN)) { 302 expectations.contains(Expectation.SKIP_BY_DESIGN)) {
303 return; 303 return;
304 } 304 }
305 305
306 doTest(testCase); 306 doTest(testCase);
307 } 307 }
308 308
309 String buildTestCaseDisplayName(Path suiteDir, 309 String buildTestCaseDisplayName(Path suiteDir,
310 Path originTestPath, 310 Path originTestPath,
311 {String multitestName: ""}) { 311 {String multitestName: ""}) {
312 Path testNamePath = originTestPath.relativeTo(suiteDir); 312 Path testNamePath = originTestPath.relativeTo(suiteDir);
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 } 697 }
698 } 698 }
699 699
700 void enqueueTestCaseFromTestInformation(TestInformation info) { 700 void enqueueTestCaseFromTestInformation(TestInformation info) {
701 var filePath = info.filePath; 701 var filePath = info.filePath;
702 var optionsFromFile = info.optionsFromFile; 702 var optionsFromFile = info.optionsFromFile;
703 703
704 String testName = buildTestCaseDisplayName(suiteDir, info.originTestPath, 704 String testName = buildTestCaseDisplayName(suiteDir, info.originTestPath,
705 multitestName: optionsFromFile['isMultitest'] ? info.multitestKey : ""); 705 multitestName: optionsFromFile['isMultitest'] ? info.multitestKey : "");
706 706
707 Set<String> expectations = testExpectations.expectations(testName); 707 Set<Expectation> expectations = testExpectations.expectations(testName);
708 if (configuration['compiler'] != 'none' && info.hasCompileError) { 708 if (configuration['compiler'] != 'none' && info.hasCompileError) {
709 // If a compile-time error is expected, and we're testing a 709 // If a compile-time error is expected, and we're testing a
710 // compiler, we never need to attempt to run the program (in a 710 // compiler, we never need to attempt to run the program (in a
711 // browser or otherwise). 711 // browser or otherwise).
712 enqueueStandardTest(info, testName, expectations); 712 enqueueStandardTest(info, testName, expectations);
713 } else if (TestUtils.isBrowserRuntime(configuration['runtime'])) { 713 } else if (TestUtils.isBrowserRuntime(configuration['runtime'])) {
714 bool isWrappingRequired = configuration['compiler'] != 'dart2js'; 714 bool isWrappingRequired = configuration['compiler'] != 'dart2js';
715 if (info.optionsFromFile['isMultiHtmlTest']) { 715 if (info.optionsFromFile['isMultiHtmlTest']) {
716 // A browser multi-test has multiple expectations for one test file. 716 // A browser multi-test has multiple expectations for one test file.
717 // Find all the different sub-test expecations for one entire test file. 717 // Find all the different sub-test expecations for one entire test file.
718 List<String> subtestNames = info.optionsFromFile['subtestNames']; 718 List<String> subtestNames = info.optionsFromFile['subtestNames'];
719 Map<String, Set<String>> multiHtmlTestExpectations = {}; 719 Map<String, Set<Expectation>> multiHtmlTestExpectations = {};
720 for (String name in subtestNames) { 720 for (String name in subtestNames) {
721 String fullTestName = '$testName/$name'; 721 String fullTestName = '$testName/$name';
722 multiHtmlTestExpectations[fullTestName] = 722 multiHtmlTestExpectations[fullTestName] =
723 testExpectations.expectations(fullTestName); 723 testExpectations.expectations(fullTestName);
724 } 724 }
725 enqueueBrowserTest(info, testName, multiHtmlTestExpectations, 725 enqueueBrowserTest(info, testName, multiHtmlTestExpectations,
726 isWrappingRequired); 726 isWrappingRequired);
727 } else { 727 } else {
728 enqueueBrowserTest(info, testName, expectations, isWrappingRequired); 728 enqueueBrowserTest(info, testName, expectations, isWrappingRequired);
729 } 729 }
730 } else { 730 } else {
731 enqueueStandardTest(info, testName, expectations); 731 enqueueStandardTest(info, testName, expectations);
732 } 732 }
733 } 733 }
734 734
735 void enqueueStandardTest(TestInformation info, 735 void enqueueStandardTest(TestInformation info,
736 String testName, 736 String testName,
737 Set<String> expectations) { 737 Set<Expectation> expectations) {
738 var commonArguments = commonArgumentsFromFile(info.filePath, 738 var commonArguments = commonArgumentsFromFile(info.filePath,
739 info.optionsFromFile); 739 info.optionsFromFile);
740 740
741 List<List<String>> vmOptionsList = getVmOptions(info.optionsFromFile); 741 List<List<String>> vmOptionsList = getVmOptions(info.optionsFromFile);
742 assert(!vmOptionsList.isEmpty); 742 assert(!vmOptionsList.isEmpty);
743 743
744 for (var vmOptions in vmOptionsList) { 744 for (var vmOptions in vmOptionsList) {
745 var allVmOptions = vmOptions; 745 var allVmOptions = vmOptions;
746 if (!extraVmOptions.isEmpty) { 746 if (!extraVmOptions.isEmpty) {
747 allVmOptions = new List.from(vmOptions)..addAll(extraVmOptions); 747 allVmOptions = new List.from(vmOptions)..addAll(extraVmOptions);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
783 783
784 var command = CommandBuilder.instance.getCompilationCommand( 784 var command = CommandBuilder.instance.getCompilationCommand(
785 compiler, "$tempDir/out.js", !useSdk, 785 compiler, "$tempDir/out.js", !useSdk,
786 dart2JsBootstrapDependencies, compilerPath, args, configurationDir); 786 dart2JsBootstrapDependencies, compilerPath, args, configurationDir);
787 787
788 List<Command> commands = <Command>[command]; 788 List<Command> commands = <Command>[command];
789 if (info.hasCompileError) { 789 if (info.hasCompileError) {
790 // Do not attempt to run the compiled result. A compilation 790 // Do not attempt to run the compiled result. A compilation
791 // error should be reported by the compilation command. 791 // error should be reported by the compilation command.
792 } else if (configuration['runtime'] == 'd8') { 792 } else if (configuration['runtime'] == 'd8') {
793 commands.add(CommandBuilder.instance.getCommand( 793 commands.add(CommandBuilder.instance.getJSCommandlineCommand(
794 "d8", d8FileName, ['$tempDir/out.js'], configurationDir)); 794 "d8", d8FileName, ['$tempDir/out.js'], configurationDir));
795 } else if (configuration['runtime'] == 'jsshell') { 795 } else if (configuration['runtime'] == 'jsshell') {
796 commands.add(CommandBuilder.instance.getCommand( 796 commands.add(CommandBuilder.instance.getJSCommandlineCommand(
797 "jsshell", jsShellFileName, ['$tempDir/out.js'], configurationDir)); 797 "jsshell", jsShellFileName, ['$tempDir/out.js'], configurationDir));
798 } 798 }
799 return commands; 799 return commands;
800 800
801 case 'dart2dart': 801 case 'dart2dart':
802 args = new List.from(args); 802 args = new List.from(args);
803 args.add('--output-type=dart'); 803 args.add('--output-type=dart');
804 String tempDir = createOutputDirectory(info.filePath, ''); 804 String tempDir = createOutputDirectory(info.filePath, '');
805 args.add('--out=$tempDir/out.dart'); 805 args.add('--out=$tempDir/out.dart');
806 806
807 List<Command> commands = 807 List<Command> commands =
808 <Command>[CommandBuilder.instance.getCompilationCommand( 808 <Command>[CommandBuilder.instance.getCompilationCommand(
809 compiler, "$tempDir/out.dart", !useSdk, 809 compiler, "$tempDir/out.dart", !useSdk,
810 dart2JsBootstrapDependencies, compilerPath, args, 810 dart2JsBootstrapDependencies, compilerPath, args,
811 configurationDir)]; 811 configurationDir)];
812 if (info.hasCompileError) { 812 if (info.hasCompileError) {
813 // Do not attempt to run the compiled result. A compilation 813 // Do not attempt to run the compiled result. A compilation
814 // error should be reported by the compilation command. 814 // error should be reported by the compilation command.
815 } else if (configuration['runtime'] == 'vm') { 815 } else if (configuration['runtime'] == 'vm') {
816 // TODO(antonm): support checked. 816 // TODO(antonm): support checked.
817 var vmArguments = new List.from(vmOptions); 817 var vmArguments = new List.from(vmOptions);
818 vmArguments.addAll([ 818 vmArguments.addAll([
819 '--ignore-unrecognized-flags', '$tempDir/out.dart']); 819 '--ignore-unrecognized-flags', '$tempDir/out.dart']);
820 commands.add(CommandBuilder.instance.getCommand( 820 commands.add(CommandBuilder.instance.getVmCommand(
821 "vm", vmFileName, vmArguments, configurationDir)); 821 vmFileName, vmArguments, configurationDir));
822 } else { 822 } else {
823 throw 'Unsupported runtime ${configuration["runtime"]} for dart2dart'; 823 throw 'Unsupported runtime ${configuration["runtime"]} for dart2dart';
824 } 824 }
825 return commands; 825 return commands;
826 826
827 case 'none': 827 case 'none':
828 var arguments = new List.from(vmOptions); 828 var arguments = new List.from(vmOptions);
829 arguments.addAll(args); 829 arguments.addAll(args);
830 return <Command>[CommandBuilder.instance.getCommand( 830 return <Command>[CommandBuilder.instance.getVmCommand(
831 'vm', dartShellFileName, arguments, configurationDir)]; 831 dartShellFileName, arguments, configurationDir)];
832 832
833 case 'dartanalyzer': 833 case 'dartanalyzer':
834 case 'dart2analyzer': 834 case 'dart2analyzer':
835 return <Command>[CommandBuilder.instance.getAnalysisCommand( 835 return <Command>[CommandBuilder.instance.getAnalysisCommand(
836 compiler, dartShellFileName, args, configurationDir, 836 compiler, dartShellFileName, args, configurationDir,
837 flavor: compiler)]; 837 flavor: compiler)];
838 838
839 default: 839 default:
840 throw 'Unknown compiler ${configuration["compiler"]}'; 840 throw 'Unknown compiler ${configuration["compiler"]}';
841 } 841 }
(...skipping 1118 matching lines...) Expand 10 before | Expand all | Expand 10 after
1960 * Gets extra vm options passed to the testing script. 1960 * Gets extra vm options passed to the testing script.
1961 */ 1961 */
1962 static List<String> getExtraVmOptions(Map configuration) { 1962 static List<String> getExtraVmOptions(Map configuration) {
1963 var extraVmOptions = []; 1963 var extraVmOptions = [];
1964 if (configuration['vm-options'] != null) { 1964 if (configuration['vm-options'] != null) {
1965 extraVmOptions = configuration['vm-options'].split(" "); 1965 extraVmOptions = configuration['vm-options'].split(" ");
1966 extraVmOptions.removeWhere((s) => s.trim() == ""); 1966 extraVmOptions.removeWhere((s) => s.trim() == "");
1967 } 1967 }
1968 return extraVmOptions; 1968 return extraVmOptions;
1969 } 1969 }
1970
1971
1972 } 1970 }
1973 1971
1974 class SummaryReport { 1972 class SummaryReport {
1975 static int total = 0; 1973 static int total = 0;
1976 static int skipped = 0; 1974 static int skipped = 0;
1977 static int skippedByDesign = 0; 1975 static int skippedByDesign = 0;
1978 static int noCrash = 0; 1976 static int noCrash = 0;
1979 static int pass = 0; 1977 static int pass = 0;
1980 static int failOk = 0; 1978 static int failOk = 0;
1981 static int fail = 0; 1979 static int fail = 0;
1982 static int crash = 0; 1980 static int crash = 0;
1983 static int timeout = 0; 1981 static int timeout = 0;
1984 static int compileErrorSkip = 0; 1982 static int compileErrorSkip = 0;
1985 1983
1986 static void add(Set<String> expectations) { 1984 static void add(Set<Expectation> expectations) {
1987 ++total; 1985 ++total;
1988 if (expectations.contains(SKIP)) { 1986 if (expectations.contains(Expectation.SKIP)) {
1989 ++skipped; 1987 ++skipped;
1990 } else if (expectations.contains(SKIP_BY_DESIGN)) { 1988 } else if (expectations.contains(Expectation.SKIP_BY_DESIGN)) {
1991 ++skipped; 1989 ++skipped;
1992 ++skippedByDesign; 1990 ++skippedByDesign;
1993 } else { 1991 } else {
1994 if (expectations.contains(PASS) && expectations.contains(FAIL) && 1992 if (expectations.contains(Expectation.PASS) &&
1995 !expectations.contains(CRASH) && !expectations.contains(OK)) { 1993 expectations.contains(Expectation.FAIL) &&
1994 !expectations.contains(Expectation.CRASH) &&
1995 !expectations.contains(Expectation.OK)) {
1996 ++noCrash; 1996 ++noCrash;
1997 } 1997 }
1998 if (expectations.contains(PASS) && expectations.length == 1) { 1998 if (expectations.contains(Expectation.PASS) && expectations.length == 1) {
1999 ++pass; 1999 ++pass;
2000 } 2000 }
2001 if (expectations.containsAll([FAIL, OK]) && expectations.length == 2) { 2001 if (expectations.containsAll([Expectation.FAIL, Expectation.OK]) &&
2002 expectations.length == 2) {
2002 ++failOk; 2003 ++failOk;
2003 } 2004 }
2004 if (expectations.contains(FAIL) && expectations.length == 1) { 2005 if (expectations.contains(Expectation.FAIL) && expectations.length == 1) {
2005 ++fail; 2006 ++fail;
2006 } 2007 }
2007 if (expectations.contains(CRASH) && expectations.length == 1) { 2008 if (expectations.contains(Expectation.CRASH) &&
2009 expectations.length == 1) {
2008 ++crash; 2010 ++crash;
2009 } 2011 }
2010 if (expectations.contains(TIMEOUT)) { 2012 if (expectations.contains(Expectation.TIMEOUT)) {
2011 ++timeout; 2013 ++timeout;
2012 } 2014 }
2013 } 2015 }
2014 } 2016 }
2015 2017
2016 static void addCompileErrorSkipTest() { 2018 static void addCompileErrorSkipTest() {
2017 total++; 2019 total++;
2018 compileErrorSkip++; 2020 compileErrorSkip++;
2019 } 2021 }
2020 2022
2021 static void printReport() { 2023 static void printReport() {
2022 if (total == 0) return; 2024 if (total == 0) return;
2023 String report = """Total: $total tests 2025 String report = """Total: $total tests
2024 * $skipped tests will be skipped ($skippedByDesign skipped by design) 2026 * $skipped tests will be skipped ($skippedByDesign skipped by design)
2025 * $noCrash tests are expected to be flaky but not crash 2027 * $noCrash tests are expected to be flaky but not crash
2026 * $pass tests are expected to pass 2028 * $pass tests are expected to pass
2027 * $failOk tests are expected to fail that we won't fix 2029 * $failOk tests are expected to fail that we won't fix
2028 * $fail tests are expected to fail that we should fix 2030 * $fail tests are expected to fail that we should fix
2029 * $crash tests are expected to crash that we should fix 2031 * $crash tests are expected to crash that we should fix
2030 * $timeout tests are allowed to timeout 2032 * $timeout tests are allowed to timeout
2031 * $compileErrorSkip tests are skipped on browsers due to compile-time error 2033 * $compileErrorSkip tests are skipped on browsers due to compile-time error
2032 """; 2034 """;
2033 print(report); 2035 print(report);
2034 } 2036 }
2035 } 2037 }
OLDNEW
« tools/testing/dart/test_runner.dart ('K') | « tools/testing/dart/test_runner.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698