|
362 | 362 | {
|
363 | 363 | try
|
364 | 364 | {
|
365 |
| - var outputFile = Path.GetDirectoryName(currentResult) + "/Comparison.txt"; |
| 365 | + var outputFile = Path.Combine(Path.GetDirectoryName(currentResult), "Comparison.txt"); |
366 | 366 | var report = new StringBuilder();
|
367 | 367 |
|
368 | 368 | report.AppendLine("Comparison Results");
|
369 | 369 | report.AppendLine("==================");
|
370 | 370 |
|
371 | 371 | var before = Result.ParseFile(lastResult);
|
372 |
| - var beforeByName = before.GroupBy(b => b.Name).ToDictionary(g => g.Key, g => g.First()); |
| 372 | + var beforeByName = before |
| 373 | + // Some multi-value tests may be duplicated |
| 374 | + .GroupBy(b => b.Name) |
| 375 | + .ToDictionary( |
| 376 | + g => g.Key, |
| 377 | + // Take one, preferably not failing first, thus ensuring an after failing test |
| 378 | + // will be match as broken in case one of the dup was not failing. |
| 379 | + g => g |
| 380 | + // Succeeded |
| 381 | + .OrderByDescending(r => r.Success) |
| 382 | + // Else ignored |
| 383 | + .ThenBy(r => r.Executed) |
| 384 | + // Else inconclusive |
| 385 | + .ThenBy(r => r.Status == ResultStatus.Success ? 0 : 1) |
| 386 | + .First()); |
373 | 387 | var after = Result.ParseFile(currentResult);
|
374 | 388 |
|
375 | 389 | var newFailingTests = new List<Result>();
|
|
379 | 393 | var ignoredTests = new List<Result>();
|
380 | 394 | var brokenTests = new List<Result>();
|
381 | 395 | var inconclusiveTests = new List<Result>();
|
| 396 | + var afterTestNames = new HashSet<string>(); |
382 | 397 | foreach (var afterResult in after)
|
383 | 398 | {
|
| 399 | + afterTestNames.Add(afterResult.Name); |
384 | 400 | Result beforeResult;
|
385 | 401 | if (beforeByName.TryGetValue(afterResult.Name, out beforeResult))
|
386 | 402 | {
|
|
412 | 428 | }
|
413 | 429 | }
|
414 | 430 |
|
415 |
| - var afterTestNames = new HashSet<string>(); |
416 |
| - foreach (var result in after) afterTestNames.Add(result.Name); |
417 | 431 | var missingTests = new List<Result>();
|
418 | 432 | foreach (var result in before)
|
419 | 433 | if (!afterTestNames.Contains(result.Name))
|
|
460 | 474 | report.AppendLine("None");
|
461 | 475 |
|
462 | 476 | report.AppendLine();
|
463 |
| - report.AppendLine("*** Tests new (not failing) since last recorded results ***"); |
464 |
| - if (newNotFailingTests.Count > 0) |
| 477 | + report.AppendLine("*** Tests fixed since last recorded results ***"); |
| 478 | + if (fixedTests.Count > 0) |
465 | 479 | {
|
466 |
| - foreach (var result in newNotFailingTests) |
| 480 | + foreach (Result result in fixedTests) |
467 | 481 | report.AppendLine(result.ToString());
|
468 | 482 | }
|
469 | 483 | else
|
470 | 484 | report.AppendLine("None");
|
471 | 485 |
|
472 | 486 | report.AppendLine();
|
473 |
| - report.AppendLine("*** Tests fixed since last recorded results ***"); |
474 |
| - if (fixedTests.Count > 0) |
| 487 | + report.AppendLine("*** Tests ignored since last recorded results ***"); |
| 488 | + if (ignoredTests.Count > 0) |
475 | 489 | {
|
476 |
| - foreach (Result result in fixedTests) |
| 490 | + foreach (Result result in ignoredTests) |
477 | 491 | report.AppendLine(result.ToString());
|
478 | 492 | }
|
479 | 493 | else
|
480 | 494 | report.AppendLine("None");
|
481 | 495 |
|
482 | 496 | report.AppendLine();
|
483 |
| - report.AppendLine("*** Tests ignored since last recorded results ***"); |
484 |
| - if (ignoredTests.Count > 0) |
| 497 | + report.AppendLine("*** Tests new (not failing) since last recorded results ***"); |
| 498 | + if (newNotFailingTests.Count > 0) |
485 | 499 | {
|
486 |
| - foreach (Result result in ignoredTests) |
| 500 | + foreach (var result in newNotFailingTests) |
487 | 501 | report.AppendLine(result.ToString());
|
488 | 502 | }
|
489 | 503 | else
|
|
0 commit comments