Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions src/cmds/dotnet/binlog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ lazy_static! {
r"(?mi)^\s*Test summary:\s*total:\s*(?P<total>\d+),\s*failed:\s*(?P<failed>\d+),\s*(?:succeeded|passed):\s*(?P<passed>\d+),\s*skipped:\s*(?P<skipped>\d+),\s*duration:\s*(?P<duration>[^\r\n]+)$"
)
.expect("valid regex");
static ref MTP_MULTILINE_SUMMARY_RE: Regex = Regex::new(
r"(?mi)Test\s+run\s+summary:\s*(?:Passed!|Failed!)\s*\n\s*total:\s*(?P<total>\d+)\s*\n\s*failed:\s*(?P<failed>\d+)\s*\n\s*(?:succeeded|passed):\s*(?P<passed>\d+)\s*\n\s*skipped:\s*(?P<skipped>\d+)\s*\n\s*duration:\s*(?P<duration>[^\r\n]+)"
)
.expect("valid regex");
static ref FAILED_TEST_HEAD_RE: Regex = Regex::new(
r"(?m)^\s*Failed\s+(?P<name>[^\r\n\[]+)\s+\[[^\]\r\n]+\]\s*$"
)
Expand Down Expand Up @@ -907,6 +911,31 @@ pub fn parse_test_from_text(text: &str) -> TestSummary {
}
}

if summary.total == 0 {
if let Some(captures) = MTP_MULTILINE_SUMMARY_RE.captures_iter(&scrubbed).last() {
summary.passed = captures
.name("passed")
.and_then(|m| m.as_str().parse::<usize>().ok())
.unwrap_or(summary.passed);
summary.failed = captures
.name("failed")
.and_then(|m| m.as_str().parse::<usize>().ok())
.unwrap_or(summary.failed);
summary.skipped = captures
.name("skipped")
.and_then(|m| m.as_str().parse::<usize>().ok())
.unwrap_or(summary.skipped);
summary.total = captures
.name("total")
.and_then(|m| m.as_str().parse::<usize>().ok())
.unwrap_or(summary.total);

if let Some(duration) = captures.name("duration") {
summary.duration_text = Some(duration.as_str().trim().to_string());
}
}
}

let lines: Vec<&str> = scrubbed.lines().collect();
let mut idx = 0;
while idx < lines.len() {
Expand Down Expand Up @@ -1653,4 +1682,42 @@ Time Elapsed 00:00:00.12
let selected = select_best_issues(primary.clone(), fallback);
assert_eq!(selected, primary);
}

#[test]
fn test_parse_test_from_text_mtp_multiline_passed() {
let input = "\
Determining projects to restore...
All projects are up-to-date for restore.
Test run summary: Passed!
total: 72
failed: 0
succeeded: 72
skipped: 0
duration: 1s 672ms
";
let summary = parse_test_from_text(input);
assert_eq!(summary.total, 72);
assert_eq!(summary.passed, 72);
assert_eq!(summary.failed, 0);
assert_eq!(summary.skipped, 0);
assert_eq!(summary.duration_text.as_deref(), Some("1s 672ms"));
}

#[test]
fn test_parse_test_from_text_mtp_multiline_failed() {
let input = "\
Test run summary: Failed!
total: 50
failed: 3
succeeded: 45
skipped: 2
duration: 2s 100ms
";
let summary = parse_test_from_text(input);
assert_eq!(summary.total, 50);
assert_eq!(summary.passed, 45);
assert_eq!(summary.failed, 3);
assert_eq!(summary.skipped, 2);
assert_eq!(summary.duration_text.as_deref(), Some("2s 100ms"));
}
}