Skip to content

Commit

Permalink
Remove proc argument to parse_logger_status
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkusPettersson98 committed Dec 13, 2024
1 parent 646a45d commit 2719672
Showing 1 changed file with 5 additions and 17 deletions.
22 changes: 5 additions & 17 deletions talpid-core/src/split_tunnel/macos/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ use libc::pid_t;
use serde::Deserialize;
use std::{
collections::{HashMap, HashSet},
future::Future,
io,
path::PathBuf,
process::{ExitStatus, Stdio},
process::Stdio,
sync::{Arc, LazyLock, Mutex},
time::Duration,
};
Expand Down Expand Up @@ -110,8 +109,7 @@ pub async fn has_full_disk_access() -> bool {
let stderr = proc.stderr.take().unwrap();
drop(proc.stdin.take());

let has_full_disk_access =
parse_logger_status(proc.wait(), stdout, stderr).await == NeedFda::No;
let has_full_disk_access = parse_logger_status(stdout, stderr).await == NeedFda::No;
Ok::<bool, Error>(has_full_disk_access)
})
.await
Expand All @@ -127,8 +125,6 @@ enum NeedFda {
/// Return whether `proc` reports that full-disk access is unavailable based on its output
/// If it cannot be determined that access is available, it is assumed to be available
async fn parse_logger_status(
// TODO: Remove me
proc: impl Future<Output = io::Result<ExitStatus>>,
stdout: impl AsyncRead + Unpin + Send + 'static,
stderr: impl AsyncRead + Unpin + Send + 'static,
) -> NeedFda {
Expand Down Expand Up @@ -559,7 +555,7 @@ fn check_os_version_support_inner(version: MacosVersion) -> Result<(), Error> {
mod test {
use super::*;

use std::{process::ExitStatus, time::Duration};
use std::time::Duration;

use talpid_platform_metadata::MacosVersion;
use tokio::io::{simplex, AsyncWriteExt};
Expand Down Expand Up @@ -604,7 +600,6 @@ mod test {
#[tokio::test]
async fn test_parse_logger_status_missing_access() {
let need_fda = parse_logger_status(
async { Ok(ExitStatus::default()) },
&[][..],
b"ES_NEW_CLIENT_RESULT_ERR_NOT_PERMITTED\n".as_slice(),
)
Expand All @@ -622,10 +617,6 @@ mod test {
#[tokio::test]
async fn test_parse_logger_status_timeout() {
let need_fda = parse_logger_status(
async {
tokio::time::sleep(EARLY_FAIL_TIMEOUT + Duration::from_secs(10)).await;
Ok(ExitStatus::default())
},
b"nothing to see here\n".as_slice(),
b"nothing to see here\n".as_slice(),
)
Expand All @@ -643,7 +634,6 @@ mod test {
#[tokio::test]
async fn test_parse_logger_status_immediate_exit() {
let need_fda = parse_logger_status(
async { Ok(ExitStatus::default()) },
b"nothing to see here\n".as_slice(),
b"nothing to see here\n".as_slice(),
)
Expand All @@ -669,8 +659,7 @@ mod test {
);
tokio::time::resume();

let need_fda =
parse_logger_status(async { Ok(ExitStatus::default()) }, stdout, stderr).await;
let need_fda = parse_logger_status(stdout, stderr).await;

tokio::time::pause();

Expand All @@ -691,8 +680,7 @@ mod test {
let stdout = output("This will never be printed\n", Duration::MAX);
let stderr = output("This will never be printed\n", Duration::MAX);

let need_fda =
parse_logger_status(async { Ok(ExitStatus::default()) }, stdout, stderr).await;
let need_fda = parse_logger_status(stdout, stderr).await;

assert_eq!(
need_fda,
Expand Down

0 comments on commit 2719672

Please sign in to comment.