| 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 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 } | 275 } |
| 276 | 276 |
| 277 // Update Summary report | 277 // Update Summary report |
| 278 if (configuration['report']) { | 278 if (configuration['report']) { |
| 279 if (testCase.expectCompileError && | 279 if (testCase.expectCompileError && |
| 280 TestUtils.isBrowserRuntime(configuration['runtime']) && | 280 TestUtils.isBrowserRuntime(configuration['runtime']) && |
| 281 new CompilerConfiguration(configuration).hasCompiler) { | 281 new CompilerConfiguration(configuration).hasCompiler) { |
| 282 SummaryReport.addCompileErrorSkipTest(); | 282 SummaryReport.addCompileErrorSkipTest(); |
| 283 return; | 283 return; |
| 284 } else { | 284 } else { |
| 285 SummaryReport.add(expectations); | 285 SummaryReport.add(testCase); |
| 286 } | 286 } |
| 287 } | 287 } |
| 288 | 288 |
| 289 // Handle skipped tests | 289 // Handle skipped tests |
| 290 if (expectations.contains(Expectation.SKIP) || | 290 if (expectations.contains(Expectation.SKIP) || |
| 291 expectations.contains(Expectation.SKIP_BY_DESIGN)) { | 291 expectations.contains(Expectation.SKIP_BY_DESIGN)) { |
| 292 return; | 292 return; |
| 293 } | 293 } |
| 294 | 294 |
| 295 doTest(testCase); | 295 doTest(testCase); |
| (...skipping 2110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2406 return path; | 2406 return path; |
| 2407 } | 2407 } |
| 2408 } | 2408 } |
| 2409 | 2409 |
| 2410 | 2410 |
| 2411 class SummaryReport { | 2411 class SummaryReport { |
| 2412 static int total = 0; | 2412 static int total = 0; |
| 2413 static int skipped = 0; | 2413 static int skipped = 0; |
| 2414 static int skippedByDesign = 0; | 2414 static int skippedByDesign = 0; |
| 2415 static int noCrash = 0; | 2415 static int noCrash = 0; |
| 2416 static int flakyCrash = 0; |
| 2416 static int pass = 0; | 2417 static int pass = 0; |
| 2417 static int failOk = 0; | 2418 static int failOk = 0; |
| 2418 static int fail = 0; | 2419 static int fail = 0; |
| 2419 static int crash = 0; | 2420 static int crash = 0; |
| 2420 static int timeout = 0; | 2421 static int timeout = 0; |
| 2421 static int compileErrorSkip = 0; | 2422 static int compileErrorSkip = 0; |
| 2422 | 2423 |
| 2423 static void add(Set<Expectation> expectations) { | 2424 static List<TestCase> nonStandardTestCases = []; |
| 2425 |
| 2426 static void add(TestCase testCase) { |
| 2427 var expectations = testCase.expectedOutcomes; |
| 2428 |
| 2424 bool containsFail = expectations.any( | 2429 bool containsFail = expectations.any( |
| 2425 (expectation) => expectation.canBeOutcomeOf(Expectation.FAIL)); | 2430 (expectation) => expectation.canBeOutcomeOf(Expectation.FAIL)); |
| 2431 bool containsPass = expectations.contains(Expectation.PASS); |
| 2432 bool containsSkip = expectations.contains(Expectation.SKIP); |
| 2433 bool containsSkipByDesign = |
| 2434 expectations.contains(Expectation.SKIP_BY_DESIGN); |
| 2435 bool containsCrash = expectations.contains(Expectation.CRASH); |
| 2436 bool containsOK = expectations.contains(Expectation.OK); |
| 2437 bool containsSlow = expectations.contains(Expectation.SLOW); |
| 2438 bool containsTimeout = expectations.contains(Expectation.TIMEOUT); |
| 2439 |
| 2426 ++total; | 2440 ++total; |
| 2427 if (expectations.contains(Expectation.SKIP)) { | 2441 if (containsSkip) { |
| 2428 ++skipped; | 2442 ++skipped; |
| 2429 } else if (expectations.contains(Expectation.SKIP_BY_DESIGN)) { | 2443 } else if (containsSkipByDesign) { |
| 2430 ++skipped; | 2444 ++skipped; |
| 2431 ++skippedByDesign; | 2445 ++skippedByDesign; |
| 2432 } else { | 2446 } else { |
| 2447 // We don't do if-else below because the buckets should be exclusive. |
| 2448 // We keep a count around to guarantee that |
| 2449 int markers = 0; |
| 2450 |
| 2433 // Counts the number of flaky tests. | 2451 // Counts the number of flaky tests. |
| 2434 if (expectations.contains(Expectation.PASS) && | 2452 if (containsFail && containsPass && !containsCrash && !containsOK) { |
| 2435 containsFail && | |
| 2436 !expectations.contains(Expectation.CRASH) && | |
| 2437 !expectations.contains(Expectation.OK)) { | |
| 2438 ++noCrash; | 2453 ++noCrash; |
| 2454 ++markers; |
| 2439 } | 2455 } |
| 2440 if (expectations.contains(Expectation.PASS) && expectations.length == 1) { | 2456 if (containsCrash && !containsOK && expectations.length > 1) { |
| 2457 ++flakyCrash; |
| 2458 ++markers; |
| 2459 } |
| 2460 if ((containsPass && expectations.length == 1) || |
| 2461 (containsPass && containsSlow && expectations.length == 2)) { |
| 2441 ++pass; | 2462 ++pass; |
| 2463 ++markers; |
| 2442 } | 2464 } |
| 2443 if (expectations.containsAll([Expectation.FAIL, Expectation.OK]) && | 2465 if (containsFail && containsOK) { |
| 2444 expectations.length == 2) { | |
| 2445 ++failOk; | 2466 ++failOk; |
| 2467 ++markers; |
| 2446 } | 2468 } |
| 2447 if (containsFail && expectations.length == 1) { | 2469 if ((containsFail && expectations.length == 1) || |
| 2470 (containsFail && containsSlow && expectations.length == 2)) { |
| 2448 ++fail; | 2471 ++fail; |
| 2472 ++markers; |
| 2449 } | 2473 } |
| 2450 if (expectations.contains(Expectation.CRASH) && | 2474 if ((containsCrash && expectations.length == 1) || |
| 2451 expectations.length == 1) { | 2475 (containsCrash && containsSlow && expectations.length == 2)) { |
| 2452 ++crash; | 2476 ++crash; |
| 2477 ++markers; |
| 2453 } | 2478 } |
| 2454 if (expectations.contains(Expectation.TIMEOUT)) { | 2479 if (containsTimeout && expectations.length == 1) { |
| 2455 ++timeout; | 2480 ++timeout; |
| 2481 ++markers; |
| 2482 } |
| 2483 if (markers != 1) { |
| 2484 nonStandardTestCases.add(testCase); |
| 2456 } | 2485 } |
| 2457 } | 2486 } |
| 2458 } | 2487 } |
| 2459 | 2488 |
| 2460 static void addCompileErrorSkipTest() { | 2489 static void addCompileErrorSkipTest() { |
| 2461 total++; | 2490 total++; |
| 2462 compileErrorSkip++; | 2491 compileErrorSkip++; |
| 2463 } | 2492 } |
| 2464 | 2493 |
| 2465 static void printReport() { | 2494 static void printReport() { |
| 2466 if (total == 0) return; | 2495 if (total == 0) return; |
| 2496 var bogus = nonStandardTestCases.length; |
| 2467 String report = """Total: $total tests | 2497 String report = """Total: $total tests |
| 2468 * $skipped tests will be skipped ($skippedByDesign skipped by design) | 2498 * $skipped tests will be skipped ($skippedByDesign skipped by design) |
| 2469 * $noCrash tests are expected to be flaky but not crash | 2499 * $noCrash tests are expected to be flaky but not crash |
| 2500 * $flakyCrash tests are expected to flaky crash |
| 2470 * $pass tests are expected to pass | 2501 * $pass tests are expected to pass |
| 2471 * $failOk tests are expected to fail that we won't fix | 2502 * $failOk tests are expected to fail that we won't fix |
| 2472 * $fail tests are expected to fail that we should fix | 2503 * $fail tests are expected to fail that we should fix |
| 2473 * $crash tests are expected to crash that we should fix | 2504 * $crash tests are expected to crash that we should fix |
| 2474 * $timeout tests are allowed to timeout | 2505 * $timeout tests are allowed to timeout |
| 2475 * $compileErrorSkip tests are skipped on browsers due to compile-time error | 2506 * $compileErrorSkip tests are skipped on browsers due to compile-time error |
| 2507 * $bogus could not be categorized or are in multiple categories |
| 2476 """; | 2508 """; |
| 2477 print(report); | 2509 print(report); |
| 2478 } | 2510 } |
| 2479 } | 2511 } |
| OLD | NEW |