Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gnalh committed Sep 30, 2024
1 parent 5ebd2d3 commit 75edbd4
Show file tree
Hide file tree
Showing 2,144 changed files with 8,637 additions and 3 deletions.
4 changes: 2 additions & 2 deletions cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,15 +199,15 @@ async fn run_upload(
let mut temp_paths = Vec::new();
// NOTE: This temp directory must be in a higher scope, otherwise it will be dropped before we can use it.
let junit_temp_dir = tempfile::tempdir()?;
if xcresult_path.is_some() && env::consts::OS == "macos" {
if xcresult_path.is_some() && cfg!(target_os = "macos") {
let xcresult = XCResultFile::new(xcresult_path.unwrap());
let junit = xcresult?.junit();
let junit_temp_path = junit_temp_dir.path().join("xcresult_junit.xml");
let mut junit_temp = std::fs::File::create(&junit_temp_path)?;
junit_temp.write_all(&junit)?;
junit_temp.seek(std::io::SeekFrom::Start(0))?;
temp_paths.push(junit_temp_path.to_str().unwrap().to_string());
} else if xcresult_path.is_some() && env::consts::OS != "macos" {
} else if xcresult_path.is_some() && !cfg!(target_os = "macos") {
log::warn!("xcresult was specified but it is only supported on macOS. Ignoring xcresult.");
}

Expand Down
9 changes: 8 additions & 1 deletion cli/src/xcresult.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ fn xcrun_version() -> Result<i32, anyhow::Error> {
}

fn xcrun(args: Vec<&str>) -> Result<serde_json::Value, anyhow::Error> {
if !cfg!(target_os = "macos") {
return Err(anyhow::anyhow!("xcrun is only available on macOS"));
}
let mut cmd = Command::new("xcrun");
// TODO - check version
let bin = cmd.args(args);
Expand Down Expand Up @@ -82,7 +85,10 @@ impl XCResultFile {
Err(_) => return Err(anyhow::anyhow!("failed to get absolute path")),
};
let absolute_path = binding.to_str().unwrap_or("");
let results_obj = xcresulttool(absolute_path, None).unwrap();
let results_obj = match xcresulttool(absolute_path, None) {
Ok(val) => val,
Err(e) => return Err(e),
};
Ok(XCResultFile {
path: absolute_path.to_string(),
results_obj,
Expand Down Expand Up @@ -402,6 +408,7 @@ impl XCResultFile {

let mut writer: Vec<u8> = Vec::new();
xml.generate(&mut writer).unwrap();
print!("junit xml: {}", str::from_utf8(&writer).unwrap());
writer
}
}
2,146 changes: 2,146 additions & 0 deletions cli/tests/.gitattributes

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions cli/tests/data/test1.junit
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
3 changes: 3 additions & 0 deletions cli/tests/data/test1.xcresult/Info.plist
Git LFS file not shown
3 changes: 3 additions & 0 deletions cli/tests/data/test1.xcresult/database.sqlite3
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
3 changes: 3 additions & 0 deletions cli/tests/data/test3.xcresult/database.sqlite3
Git LFS file not shown
3 changes: 3 additions & 0 deletions cli/tests/data/test4.junit
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Loading

0 comments on commit 75edbd4

Please sign in to comment.