Skip to content

Commit

Permalink
support xcresult expected failures (#265)
Browse files Browse the repository at this point in the history
  • Loading branch information
dfrankland authored Dec 27, 2024
1 parent 328ea9c commit 107654f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
2 changes: 1 addition & 1 deletion xcresult/src/xcresult.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ impl XCResult {
"Error" => TestCaseStatus::non_success(NonSuccessKind::Error),
"Failure" => TestCaseStatus::non_success(NonSuccessKind::Failure),
"Skipped" => TestCaseStatus::skipped(),
"Success" => TestCaseStatus::success(),
"Success" | "Expected Failure" => TestCaseStatus::success(),
_ => TestCaseStatus::non_success(NonSuccessKind::Error),
};
let mut uri = String::new();
Expand Down
4 changes: 2 additions & 2 deletions xcresult/tests/data.tar.gz
Git LFS file not shown
28 changes: 24 additions & 4 deletions xcresult/tests/xcresult.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ fn test_xcresult_with_valid_path() {
let xcresult = XCResult::new(path_str, &REPO, ORG_URL_SLUG);
assert!(xcresult.is_ok());

let junits = xcresult.unwrap().generate_junits().unwrap();
let mut junits = xcresult.unwrap().generate_junits().unwrap();
assert_eq!(junits.len(), 1);
let junit = junits[0].clone();
let junit = junits.pop().unwrap();
let mut junit_writer: Vec<u8> = Vec::new();
junit.serialize(&mut junit_writer).unwrap();
let expected_path = TEMP_DIR.as_ref().join("data/test1.junit");
Expand Down Expand Up @@ -83,9 +83,9 @@ fn test_complex_xcresult_with_valid_path() {
let xcresult = XCResult::new(path_str, &REPO, ORG_URL_SLUG);
assert!(xcresult.is_ok());

let junits = xcresult.unwrap().generate_junits().unwrap();
let mut junits = xcresult.unwrap().generate_junits().unwrap();
assert_eq!(junits.len(), 1);
let junit = junits[0].clone();
let junit = junits.pop().unwrap();
let mut junit_writer: Vec<u8> = Vec::new();
junit.serialize(&mut junit_writer).unwrap();
let expected_path = TEMP_DIR.as_ref().join("data/test4.junit");
Expand All @@ -104,3 +104,23 @@ fn test_xcresult_with_valid_path_invalid_os() {
"xcrun is only available on macOS"
);
}

#[cfg(target_os = "macos")]
#[test]
fn test_expected_failures_xcresult_with_valid_path() {
let path = TEMP_DIR
.as_ref()
.join("data/test-ExpectedFailures.xcresult");
let path_str = path.to_str().unwrap();
let xcresult = XCResult::new(path_str, &REPO, ORG_URL_SLUG);
assert!(xcresult.is_ok());

let mut junits = xcresult.unwrap().generate_junits().unwrap();
assert_eq!(junits.len(), 1);
let junit = junits.pop().unwrap();
let mut junit_writer: Vec<u8> = Vec::new();
junit.serialize(&mut junit_writer).unwrap();
let expected_path = TEMP_DIR.as_ref().join("data/test-ExpectedFailures.junit");
let expected = std::fs::read_to_string(expected_path).unwrap();
assert_eq!(String::from_utf8(junit_writer).unwrap(), expected);
}

0 comments on commit 107654f

Please sign in to comment.