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

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

Issue 2903703002: Tighten types in test.dart even more. (Closed)
Patch Set: Play nicer with strong mode. Created 3 years, 6 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
« no previous file with comments | « tools/testing/dart/test_configurations.dart ('k') | tools/testing/dart/test_runner.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 library test_progress; 5 library test_progress;
6 6
7 import "dart:convert" show JSON; 7 import "dart:convert" show JSON;
8 import "dart:io"; 8 import "dart:io";
9 9
10 import "expectation.dart"; 10 import "expectation.dart";
11 import "http_server.dart";
11 import "path.dart"; 12 import "path.dart";
12 import "summary_report.dart"; 13 import "summary_report.dart";
13 import "test_runner.dart"; 14 import "test_runner.dart";
14 import "test_suite.dart"; 15 import "test_suite.dart";
15 import "utils.dart"; 16 import "utils.dart";
16 17
17 /// Controls how message strings are processed before being displayed. 18 /// Controls how message strings are processed before being displayed.
18 class Formatter { 19 class Formatter {
19 /// Messages are left as-is. 20 /// Messages are left as-is.
20 static const normal = const Formatter._(); 21 static const normal = const Formatter._();
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 } 203 }
203 } 204 }
204 205
205 class UnexpectedCrashLogger extends EventListener { 206 class UnexpectedCrashLogger extends EventListener {
206 final archivedBinaries = <String, String>{}; 207 final archivedBinaries = <String, String>{};
207 208
208 void done(TestCase test) { 209 void done(TestCase test) {
209 if (test.unexpectedOutput && 210 if (test.unexpectedOutput &&
210 test.result == Expectation.crash && 211 test.result == Expectation.crash &&
211 test.lastCommandExecuted is ProcessCommand) { 212 test.lastCommandExecuted is ProcessCommand) {
212 final pid = "${test.lastCommandOutput.pid}"; 213 var pid = "${test.lastCommandOutput.pid}";
213 final lastCommand = test.lastCommandExecuted as ProcessCommand; 214 var lastCommand = test.lastCommandExecuted as ProcessCommand;
214 215
215 // We might have a coredump for the process. This coredump will be 216 // We might have a coredump for the process. This coredump will be
216 // archived by CoreDumpArchiver (see tools/utils.py). 217 // archived by CoreDumpArchiver (see tools/utils.py).
217 // 218 //
218 // For debugging purposes we need to archive the crashed binary as well. 219 // For debugging purposes we need to archive the crashed binary as well.
219 // 220 //
220 // To simplify the archiving code we simply copy binaries into current 221 // To simplify the archiving code we simply copy binaries into current
221 // folder next to core dumps and name them 222 // folder next to core dumps and name them
222 // `binary.${mode}_${arch}_${binary_name}`. 223 // `binary.${mode}_${arch}_${binary_name}`.
223 final binName = lastCommand.executable; 224 var binName = lastCommand.executable;
224 final binFile = new File(binName); 225 var binFile = new File(binName);
225 final binBaseName = new Path(binName).filename; 226 var binBaseName = new Path(binName).filename;
226 if (!archivedBinaries.containsKey(binName) && binFile.existsSync()) { 227 if (!archivedBinaries.containsKey(binName) && binFile.existsSync()) {
227 final mode = test.configuration['mode']; 228 var mode = test.configuration['mode'] as String;
228 final arch = test.configuration['arch']; 229 var arch = test.configuration['arch'] as String;
229 final archived = "binary.${mode}_${arch}_${binBaseName}"; 230 var archived = "binary.${mode}_${arch}_${binBaseName}";
230 TestUtils.copyFile(new Path(binName), new Path(archived)); 231 TestUtils.copyFile(new Path(binName), new Path(archived));
231 archivedBinaries[binName] = archived; 232 archivedBinaries[binName] = archived;
232 } 233 }
233 234
234 if (archivedBinaries.containsKey(binName)) { 235 if (archivedBinaries.containsKey(binName)) {
235 // We have found and copied the binary. 236 // We have found and copied the binary.
236 RandomAccessFile unexpectedCrashesFile; 237 RandomAccessFile unexpectedCrashesFile;
237 try { 238 try {
238 unexpectedCrashesFile = 239 unexpectedCrashesFile =
239 new File('unexpected-crashes').openSync(mode: FileMode.APPEND); 240 new File('unexpected-crashes').openSync(mode: FileMode.APPEND);
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 if (test.commandOutputs.length != test.commands.length && 605 if (test.commandOutputs.length != test.commands.length &&
605 !test.expectCompileError) { 606 !test.expectCompileError) {
606 output.add('Unexpected compile-time error.'); 607 output.add('Unexpected compile-time error.');
607 } else { 608 } else {
608 if (test.expectCompileError) { 609 if (test.expectCompileError) {
609 output.add('Compile-time error expected.'); 610 output.add('Compile-time error expected.');
610 } 611 }
611 if (test.hasRuntimeError) { 612 if (test.hasRuntimeError) {
612 output.add('Runtime error expected.'); 613 output.add('Runtime error expected.');
613 } 614 }
614 if (test.configuration['checked'] && test.isNegativeIfChecked) { 615 if ((test.configuration['checked'] as bool) && test.isNegativeIfChecked) {
615 output.add('Dynamic type error expected.'); 616 output.add('Dynamic type error expected.');
616 } 617 }
617 } 618 }
618 } 619 }
619 620
620 for (var i = 0; i < test.commands.length; i++) { 621 for (var i = 0; i < test.commands.length; i++) {
621 var command = test.commands[i]; 622 var command = test.commands[i];
622 var commandOutput = test.commandOutputs[command]; 623 var commandOutput = test.commandOutputs[command];
623 if (commandOutput != null) { 624 if (commandOutput != null) {
624 output.add("CommandOutput[${command.displayName}]:"); 625 output.add("CommandOutput[${command.displayName}]:");
(...skipping 12 matching lines...) Expand all
637 if (!commandOutput.stderr.isEmpty) { 638 if (!commandOutput.stderr.isEmpty) {
638 output.add(''); 639 output.add('');
639 output.add('stderr:'); 640 output.add('stderr:');
640 output.addAll(_linesWithoutCarriageReturn(commandOutput.stderr)); 641 output.addAll(_linesWithoutCarriageReturn(commandOutput.stderr));
641 } 642 }
642 } 643 }
643 } 644 }
644 645
645 if (test is BrowserTestCase) { 646 if (test is BrowserTestCase) {
646 // Additional command for rerunning the steps locally after the fact. 647 // Additional command for rerunning the steps locally after the fact.
647 var command = test.configuration["_servers_"].httpServerCommandLine(); 648 var command = (test.configuration["_servers_"] as TestingServers)
649 .httpServerCommandLine();
648 output.add(''); 650 output.add('');
649 output.add('To retest, run: $command'); 651 output.add('To retest, run: $command');
650 } 652 }
651 653
652 for (var i = 0; i < test.commands.length; i++) { 654 for (var i = 0; i < test.commands.length; i++) {
653 var command = test.commands[i]; 655 var command = test.commands[i];
654 var commandOutput = test.commandOutputs[command]; 656 var commandOutput = test.commandOutputs[command];
655 output.add(''); 657 output.add('');
656 output.add('Command[${command.displayName}]: $command'); 658 output.add('Command[${command.displayName}]: $command');
657 if (commandOutput != null) { 659 if (commandOutput != null) {
658 output.add('Took ${commandOutput.time}'); 660 output.add('Took ${commandOutput.time}');
659 } else { 661 } else {
660 output.add('Did not run'); 662 output.add('Did not run');
661 } 663 }
662 } 664 }
663 665
664 var arguments = ['python', 'tools/test.py']; 666 var arguments = ['python', 'tools/test.py'];
665 arguments.addAll(test.configuration['_reproducing_arguments_']); 667 arguments
668 .addAll(test.configuration['_reproducing_arguments_'] as List<String>);
666 arguments.add(test.displayName); 669 arguments.add(test.displayName);
667 var testPyCommandline = arguments.map(escapeCommandLineArgument).join(' '); 670 var testPyCommandline = arguments.map(escapeCommandLineArgument).join(' ');
668 671
669 output.add(''); 672 output.add('');
670 output.add('Short reproduction command (experimental):'); 673 output.add('Short reproduction command (experimental):');
671 output.add(" $testPyCommandline"); 674 output.add(" $testPyCommandline");
672 return output; 675 return output;
673 } 676 }
674 677
675 String _buildSummaryEnd(int failedTests) { 678 String _buildSummaryEnd(int failedTests) {
676 if (failedTests == 0) { 679 if (failedTests == 0) {
677 return '\n===\n=== All tests succeeded\n===\n'; 680 return '\n===\n=== All tests succeeded\n===\n';
678 } else { 681 } else {
679 var pluralSuffix = failedTests != 1 ? 's' : ''; 682 var pluralSuffix = failedTests != 1 ? 's' : '';
680 return '\n===\n=== ${failedTests} test$pluralSuffix failed\n===\n'; 683 return '\n===\n=== ${failedTests} test$pluralSuffix failed\n===\n';
681 } 684 }
682 } 685 }
OLDNEW
« no previous file with comments | « tools/testing/dart/test_configurations.dart ('k') | tools/testing/dart/test_runner.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698