OLD | NEW |
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"; | |
11 import "path.dart"; | 10 import "path.dart"; |
| 11 import "status_file_parser.dart"; |
12 import "summary_report.dart"; | 12 import "summary_report.dart"; |
13 import "test_runner.dart"; | 13 import "test_runner.dart"; |
14 import "test_suite.dart"; | 14 import "test_suite.dart"; |
15 import "utils.dart"; | 15 import "utils.dart"; |
16 | 16 |
17 /// Controls how message strings are processed before being displayed. | 17 /// Controls how message strings are processed before being displayed. |
18 class Formatter { | 18 class Formatter { |
19 /// Messages are left as-is. | 19 /// Messages are left as-is. |
20 static const normal = const Formatter._(); | 20 static const normal = const Formatter._(); |
21 | 21 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 } | 60 } |
61 } | 61 } |
62 } | 62 } |
63 | 63 |
64 class IgnoredTestMonitor extends EventListener { | 64 class IgnoredTestMonitor extends EventListener { |
65 static final int maxIgnored = 10; | 65 static final int maxIgnored = 10; |
66 | 66 |
67 int countIgnored = 0; | 67 int countIgnored = 0; |
68 | 68 |
69 void done(TestCase test) { | 69 void done(TestCase test) { |
70 if (test.lastCommandOutput.result(test) == Expectation.ignore) { | 70 if (test.lastCommandOutput.result(test) == Expectation.IGNORE) { |
71 countIgnored++; | 71 countIgnored++; |
72 if (countIgnored > maxIgnored) { | 72 if (countIgnored > maxIgnored) { |
73 print("/nMore than $maxIgnored tests were ignored due to flakes in"); | 73 print("/nMore than $maxIgnored tests were ignored due to flakes in"); |
74 print("the test infrastructure. Notify whesse@google.com."); | 74 print("the test infrastructure. Notify whesse@google.com."); |
75 print("Output of the last ignored test was:"); | 75 print("Output of the last ignored test was:"); |
76 print(_buildFailureOutput(test)); | 76 print(_buildFailureOutput(test)); |
77 exit(1); | 77 exit(1); |
78 } | 78 } |
79 } | 79 } |
80 } | 80 } |
81 | 81 |
82 void allDone() { | 82 void allDone() { |
83 if (countIgnored > 0) { | 83 if (countIgnored > 0) { |
84 print("Ignored $countIgnored tests due to flaky infrastructure"); | 84 print("Ignored $countIgnored tests due to flaky infrastructure"); |
85 } | 85 } |
86 } | 86 } |
87 } | 87 } |
88 | 88 |
89 class FlakyLogWriter extends EventListener { | 89 class FlakyLogWriter extends EventListener { |
90 void done(TestCase test) { | 90 void done(TestCase test) { |
91 if (test.isFlaky && test.result != Expectation.pass) { | 91 if (test.isFlaky && test.result != Expectation.PASS) { |
92 var buf = new StringBuffer(); | 92 var buf = new StringBuffer(); |
93 for (var l in _buildFailureOutput(test)) { | 93 for (var l in _buildFailureOutput(test)) { |
94 buf.write("$l\n"); | 94 buf.write("$l\n"); |
95 } | 95 } |
96 _appendToFlakyFile(buf.toString()); | 96 _appendToFlakyFile(buf.toString()); |
97 } | 97 } |
98 } | 98 } |
99 | 99 |
100 void _appendToFlakyFile(String msg) { | 100 void _appendToFlakyFile(String msg) { |
101 var file = new File(TestUtils.flakyFileName); | 101 var file = new File(TestUtils.flakyFileName); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 } | 200 } |
201 _sink.write("${JSON.encode(record)}\n"); | 201 _sink.write("${JSON.encode(record)}\n"); |
202 } | 202 } |
203 } | 203 } |
204 | 204 |
205 class UnexpectedCrashLogger extends EventListener { | 205 class UnexpectedCrashLogger extends EventListener { |
206 final archivedBinaries = <String, String>{}; | 206 final archivedBinaries = <String, String>{}; |
207 | 207 |
208 void done(TestCase test) { | 208 void done(TestCase test) { |
209 if (test.unexpectedOutput && | 209 if (test.unexpectedOutput && |
210 test.result == Expectation.crash && | 210 test.result == Expectation.CRASH && |
211 test.lastCommandExecuted is ProcessCommand) { | 211 test.lastCommandExecuted is ProcessCommand) { |
212 final pid = "${test.lastCommandOutput.pid}"; | 212 final pid = "${test.lastCommandOutput.pid}"; |
213 final lastCommand = test.lastCommandExecuted as ProcessCommand; | 213 final lastCommand = test.lastCommandExecuted as ProcessCommand; |
214 | 214 |
215 // We might have a coredump for the process. This coredump will be | 215 // We might have a coredump for the process. This coredump will be |
216 // archived by CoreDumpArchiver (see tools/utils.py). | 216 // archived by CoreDumpArchiver (see tools/utils.py). |
217 // | 217 // |
218 // For debugging purposes we need to archive the crashed binary as well. | 218 // For debugging purposes we need to archive the crashed binary as well. |
219 // | 219 // |
220 // To simplify the archiving code we simply copy binaries into current | 220 // To simplify the archiving code we simply copy binaries into current |
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
673 } | 673 } |
674 | 674 |
675 String _buildSummaryEnd(int failedTests) { | 675 String _buildSummaryEnd(int failedTests) { |
676 if (failedTests == 0) { | 676 if (failedTests == 0) { |
677 return '\n===\n=== All tests succeeded\n===\n'; | 677 return '\n===\n=== All tests succeeded\n===\n'; |
678 } else { | 678 } else { |
679 var pluralSuffix = failedTests != 1 ? 's' : ''; | 679 var pluralSuffix = failedTests != 1 ? 's' : ''; |
680 return '\n===\n=== ${failedTests} test$pluralSuffix failed\n===\n'; | 680 return '\n===\n=== ${failedTests} test$pluralSuffix failed\n===\n'; |
681 } | 681 } |
682 } | 682 } |
OLD | NEW |