Skip to content

Enable testing on macOS #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 15, 2022
Merged
Show file tree
Hide file tree
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
Binary file added assets/bin/bsdiff.macos
Binary file not shown.
Binary file added assets/bin/bspatch.macos
Binary file not shown.
10 changes: 9 additions & 1 deletion utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,14 +289,22 @@ fn get_binary_in<P: AsRef<Path>>(dir: P, name: &str) -> io::Result<path::PathBuf
Ok(dir.as_ref().join(format!("{}.exe", name)))
}

#[cfg(unix)]
#[cfg(all(unix, not(target_os = "macos")))]
fn get_binary_in<P: AsRef<Path>>(dir: P, name: &str) -> io::Result<path::PathBuf> {
use std::os::unix::fs::PermissionsExt;
let bin = dir.as_ref().join(name);
fs::set_permissions(bin.as_path(), fs::Permissions::from_mode(0o755))?;
Ok(bin)
}

#[cfg(all(unix, target_os = "macos"))]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have noticed that the shipped bsdiff/bspatch were dynamically linked aarch64 executables.
Maybe a target_arch = "aarch64" condition should be added here, to indicate that the legacy x86_64 support for Mac is missing at now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May have been my omission, I thought they were universal binaries. I'll look into this to rectify the situation.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Github actions for running test has been added on the master branch, where os: macos-latest is temporarily removed because github actions seems to be lack of arm64 containers support. It might be helpful.

fn get_binary_in<P: AsRef<Path>>(dir: P, name: &str) -> io::Result<path::PathBuf> {
use std::os::unix::fs::PermissionsExt;
let bin = dir.as_ref().join(name).with_extension("macos");
fs::set_permissions(bin.as_path(), fs::Permissions::from_mode(0o755))?;
Ok(bin)
}

/// Test sample.
pub struct Sample {
pub name: String,
Expand Down