| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 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. |
| 4 |
| 5 library summary_report; |
| 6 |
| 7 import "status_file_parser.dart"; |
| 8 import "test_runner.dart"; |
| 9 |
| 10 final summaryReport = new SummaryReport(); |
| 11 |
| 12 class SummaryReport { |
| 13 int _total = 0; |
| 14 int _skipped = 0; |
| 15 int _skippedByDesign = 0; |
| 16 int _noCrash = 0; |
| 17 int _flakyCrash = 0; |
| 18 int _pass = 0; |
| 19 int _failOk = 0; |
| 20 int _fail = 0; |
| 21 int _crash = 0; |
| 22 int _timeout = 0; |
| 23 int _compileErrorSkip = 0; |
| 24 |
| 25 int get total => _total; |
| 26 |
| 27 int get bogus => _nonStandardTestCases.length; |
| 28 |
| 29 final List<TestCase> _nonStandardTestCases = <TestCase>[]; |
| 30 |
| 31 void add(TestCase testCase) { |
| 32 var expectations = testCase.expectedOutcomes; |
| 33 |
| 34 bool containsFail = expectations |
| 35 .any((expectation) => expectation.canBeOutcomeOf(Expectation.FAIL)); |
| 36 bool containsPass = expectations.contains(Expectation.PASS); |
| 37 bool containsSkip = expectations.contains(Expectation.SKIP); |
| 38 bool containsSkipByDesign = |
| 39 expectations.contains(Expectation.SKIP_BY_DESIGN); |
| 40 bool containsCrash = expectations.contains(Expectation.CRASH); |
| 41 bool containsOK = expectations.contains(Expectation.OK); |
| 42 bool containsSlow = expectations.contains(Expectation.SLOW); |
| 43 bool containsTimeout = expectations.contains(Expectation.TIMEOUT); |
| 44 |
| 45 ++_total; |
| 46 if (containsSkip) { |
| 47 ++_skipped; |
| 48 } else if (containsSkipByDesign) { |
| 49 ++_skipped; |
| 50 ++_skippedByDesign; |
| 51 } else { |
| 52 // We don't do if-else below because the buckets should be exclusive. |
| 53 // We keep a count around to guarantee that |
| 54 int markers = 0; |
| 55 |
| 56 // Counts the number of flaky tests. |
| 57 if (containsFail && containsPass && !containsCrash && !containsOK) { |
| 58 ++_noCrash; |
| 59 ++markers; |
| 60 } |
| 61 if (containsCrash && !containsOK && expectations.length > 1) { |
| 62 ++_flakyCrash; |
| 63 ++markers; |
| 64 } |
| 65 if ((containsPass && expectations.length == 1) || |
| 66 (containsPass && containsSlow && expectations.length == 2)) { |
| 67 ++_pass; |
| 68 ++markers; |
| 69 } |
| 70 if (containsFail && containsOK) { |
| 71 ++_failOk; |
| 72 ++markers; |
| 73 } |
| 74 if ((containsFail && expectations.length == 1) || |
| 75 (containsFail && containsSlow && expectations.length == 2)) { |
| 76 ++_fail; |
| 77 ++markers; |
| 78 } |
| 79 if ((containsCrash && expectations.length == 1) || |
| 80 (containsCrash && containsSlow && expectations.length == 2)) { |
| 81 ++_crash; |
| 82 ++markers; |
| 83 } |
| 84 if (containsTimeout && expectations.length == 1) { |
| 85 ++_timeout; |
| 86 ++markers; |
| 87 } |
| 88 if (markers != 1) { |
| 89 _nonStandardTestCases.add(testCase); |
| 90 } |
| 91 } |
| 92 } |
| 93 |
| 94 void addCompileErrorSkipTest() { |
| 95 _total++; |
| 96 _compileErrorSkip++; |
| 97 } |
| 98 |
| 99 Map<String, int> get values => { |
| 100 'skipped': _skipped, |
| 101 'skippedByDesign': _skippedByDesign, |
| 102 'pass': _pass, |
| 103 'noCrash': _noCrash, |
| 104 'flakyCrash': _flakyCrash, |
| 105 'failOk': _failOk, |
| 106 'fail': _fail, |
| 107 'crash': _crash, |
| 108 'timeout': _timeout, |
| 109 'compileErrorSkip': _compileErrorSkip, |
| 110 'bogus': bogus |
| 111 }; |
| 112 |
| 113 String get report => """Total: $_total tests |
| 114 * $_skipped tests will be skipped ($_skippedByDesign skipped by design) |
| 115 * $_noCrash tests are expected to be flaky but not crash |
| 116 * $_flakyCrash tests are expected to flaky crash |
| 117 * $_pass tests are expected to pass |
| 118 * $_failOk tests are expected to fail that we won't fix |
| 119 * $_fail tests are expected to fail that we should fix |
| 120 * $_crash tests are expected to crash that we should fix |
| 121 * $_timeout tests are allowed to timeout |
| 122 * $_compileErrorSkip tests are skipped on browsers due to compile-time error |
| 123 * $bogus could not be categorized or are in multiple categories |
| 124 """; |
| 125 |
| 126 void printReport() { |
| 127 if (_total == 0) return; |
| 128 print(report); |
| 129 } |
| 130 } |
| OLD | NEW |