feat: support macOS (#247)

* feat: support macOS

* fix tests
This commit is contained in:
Bryan Oltman
2024-12-05 17:53:45 -05:00
committed by GitHub
parent 6298d37d86
commit b4775d30dd
4 changed files with 274 additions and 130 deletions
+3 -3
View File
@@ -27,7 +27,7 @@ dyn-clone = "1.0.16"
# For decoding the hex-encoded hashes in Patch network responses.
hex = "0.4.3"
# Used to construct mock responses.
http = "0.2.9"
http = "1.2.0"
libc = "0.2.98"
# For error!(), info!(), etc macros. `print` will not show up on Android.
log = "0.4.14"
@@ -37,7 +37,7 @@ once_cell = "1.17.1"
# Pipe is a simple in-memory pipe implementation, there might be a std way too?
pipe = "0.4.0"
# Used for networking.
reqwest = { version = "0.11", default-features = false, features = [
reqwest = { version = "0.12", default-features = false, features = [
"blocking",
"json",
"rustls-tls",
@@ -58,7 +58,7 @@ android_logger = "0.13.0"
# Send panics to log (instead of stderr), thus logcat on Android.
log-panics = { version = "2", features = ["with-backtrace"] }
[target.'cfg(target_os = "ios")'.dependencies]
[target.'cfg(any(target_os = "ios", target_os = "macos"))'.dependencies]
# Send panics to syslog (instead of stderr).
log-panics = { version = "2", features = ["with-backtrace"] }
# Support for logging on iOS (https://developer.apple.com/documentation/oslog)
+6 -2
View File
@@ -11,7 +11,7 @@ pub fn init_logging() {
shorebird_debug!("Logging initialized");
}
#[cfg(target_os = "ios")]
#[cfg(any(target_os = "ios", target_os = "macos"))]
pub fn init_logging() {
let init_result = oslog::OsLogger::new("dev.shorebird")
.level_filter(log::LevelFilter::Info)
@@ -22,7 +22,11 @@ pub fn init_logging() {
}
}
#[cfg(all(not(target_os = "android"), not(target_os = "ios")))]
#[cfg(all(
not(target_os = "android"),
not(target_os = "ios"),
not(target_os = "macos")
))]
pub fn init_logging() {
// Nothing to do on non-Android, non-iOS platforms.
}
+2 -9
View File
@@ -100,11 +100,7 @@ fn handle_network_result(
}
}
Err(e) => match e.source() {
Some(source)
if source
.to_string()
.contains("failed to lookup address information") =>
{
Some(source) if source.to_string().contains("client error (Connect)") => {
bail!("Patch check request failed due to network error. Please check your internet connection.");
}
_ => bail!(e),
@@ -420,9 +416,6 @@ mod tests {
assert!(result.is_err());
let error = result.err().unwrap();
assert_eq!(
error.to_string(),
"builder error: relative URL without a base"
)
assert_eq!(error.to_string(), "builder error")
}
}