1
1
mirror of https://github.com/wez/wezterm.git synced 2024-09-11 14:25:57 +03:00

deps: remove smol-potat, update futures-lite

smol-potat hasn't had updates in 4 years and was bifurcating some
big deps.  It wasn't necessary; it was trivially easy to replace
with smol::block_on with no meaningful increase in boilerplate,
and the result is much more understandable in purpose and effect.
This commit is contained in:
Wez Furlong 2024-05-13 11:43:10 -07:00
parent 944e0b29b6
commit 6ad0da98d8
No known key found for this signature in database
GPG Key ID: 7A7F66A31EC9B387
6 changed files with 984 additions and 1063 deletions

183
Cargo.lock generated
View File

@ -225,8 +225,8 @@ checksum = "b10202063978b3351199d68f8b22c4e47e4b1b822f8d43fd862d5ea8c006b29a"
dependencies = [ dependencies = [
"async-task", "async-task",
"concurrent-queue", "concurrent-queue",
"fastrand 2.1.0", "fastrand",
"futures-lite 2.3.0", "futures-lite",
"slab", "slab",
] ]
@ -236,29 +236,9 @@ version = "2.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ebcd09b382f40fcd159c2d695175b2ae620ffa5f3bd6f664131efff4e8b9e04a" checksum = "ebcd09b382f40fcd159c2d695175b2ae620ffa5f3bd6f664131efff4e8b9e04a"
dependencies = [ dependencies = [
"async-lock 3.3.0", "async-lock",
"blocking", "blocking",
"futures-lite 2.3.0", "futures-lite",
]
[[package]]
name = "async-io"
version = "1.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fc5b45d93ef0529756f812ca52e44c221b35341892d3dcc34132ac02f3dd2af"
dependencies = [
"async-lock 2.8.0",
"autocfg",
"cfg-if",
"concurrent-queue",
"futures-lite 1.13.0",
"log",
"parking",
"polling 2.8.0",
"rustix 0.37.27",
"slab",
"socket2 0.4.10",
"waker-fn",
] ]
[[package]] [[package]]
@ -267,28 +247,19 @@ version = "2.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dcccb0f599cfa2f8ace422d3555572f47424da5648a4382a9dd0310ff8210884" checksum = "dcccb0f599cfa2f8ace422d3555572f47424da5648a4382a9dd0310ff8210884"
dependencies = [ dependencies = [
"async-lock 3.3.0", "async-lock",
"cfg-if", "cfg-if",
"concurrent-queue", "concurrent-queue",
"futures-io", "futures-io",
"futures-lite 2.3.0", "futures-lite",
"parking", "parking",
"polling 3.7.0", "polling",
"rustix 0.38.34", "rustix 0.38.34",
"slab", "slab",
"tracing", "tracing",
"windows-sys 0.52.0", "windows-sys 0.52.0",
] ]
[[package]]
name = "async-lock"
version = "2.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "287272293e9d8c41773cec55e365490fe034813a2f172f502d6ddcf75b2f582b"
dependencies = [
"event-listener 2.5.3",
]
[[package]] [[package]]
name = "async-lock" name = "async-lock"
version = "3.3.0" version = "3.3.0"
@ -306,9 +277,9 @@ version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b948000fad4873c1c9339d60f2623323a0cfd3816e5181033c6a5cb68b2accf7" checksum = "b948000fad4873c1c9339d60f2623323a0cfd3816e5181033c6a5cb68b2accf7"
dependencies = [ dependencies = [
"async-io 2.3.2", "async-io",
"blocking", "blocking",
"futures-lite 2.3.0", "futures-lite",
] ]
[[package]] [[package]]
@ -318,14 +289,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a53fc6301894e04a92cb2584fedde80cb25ba8e02d9dc39d4a87d036e22f397d" checksum = "a53fc6301894e04a92cb2584fedde80cb25ba8e02d9dc39d4a87d036e22f397d"
dependencies = [ dependencies = [
"async-channel", "async-channel",
"async-io 2.3.2", "async-io",
"async-lock 3.3.0", "async-lock",
"async-signal", "async-signal",
"async-task", "async-task",
"blocking", "blocking",
"cfg-if", "cfg-if",
"event-listener 5.3.0", "event-listener 5.3.0",
"futures-lite 2.3.0", "futures-lite",
"rustix 0.38.34", "rustix 0.38.34",
"tracing", "tracing",
"windows-sys 0.52.0", "windows-sys 0.52.0",
@ -348,8 +319,8 @@ version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "afe66191c335039c7bb78f99dc7520b0cbb166b3a1cb33a03f53d8a1c6f2afda" checksum = "afe66191c335039c7bb78f99dc7520b0cbb166b3a1cb33a03f53d8a1c6f2afda"
dependencies = [ dependencies = [
"async-io 2.3.2", "async-io",
"async-lock 3.3.0", "async-lock",
"atomic-waker", "atomic-waker",
"cfg-if", "cfg-if",
"futures-core", "futures-core",
@ -381,7 +352,7 @@ dependencies = [
name = "async_ossl" name = "async_ossl"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"async-io 2.3.2", "async-io",
"openssl", "openssl",
] ]
@ -554,10 +525,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "495f7104e962b7356f0aeb34247aca1fe7d2e783b346582db7f2904cb5717e88" checksum = "495f7104e962b7356f0aeb34247aca1fe7d2e783b346582db7f2904cb5717e88"
dependencies = [ dependencies = [
"async-channel", "async-channel",
"async-lock 3.3.0", "async-lock",
"async-task", "async-task",
"futures-io", "futures-io",
"futures-lite 2.3.0", "futures-lite",
"piper", "piper",
] ]
@ -1583,12 +1554,6 @@ dependencies = [
"num-traits", "num-traits",
] ]
[[package]]
name = "event-listener"
version = "2.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0"
[[package]] [[package]]
name = "event-listener" name = "event-listener"
version = "4.0.3" version = "4.0.3"
@ -1669,15 +1634,6 @@ dependencies = [
"regex", "regex",
] ]
[[package]]
name = "fastrand"
version = "1.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be"
dependencies = [
"instant",
]
[[package]] [[package]]
name = "fastrand" name = "fastrand"
version = "2.1.0" version = "2.1.0"
@ -1932,28 +1888,13 @@ version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1"
[[package]]
name = "futures-lite"
version = "1.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49a9d51ce47660b1e808d3c990b4709f2f415d928835a17dfd16991515c46bce"
dependencies = [
"fastrand 1.9.0",
"futures-core",
"futures-io",
"memchr",
"parking",
"pin-project-lite",
"waker-fn",
]
[[package]] [[package]]
name = "futures-lite" name = "futures-lite"
version = "2.3.0" version = "2.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "52527eb5074e35e9339c6b4e8d12600c7128b68fb25dcb9fa9dec18f7c25f3a5" checksum = "52527eb5074e35e9339c6b4e8d12600c7128b68fb25dcb9fa9dec18f7c25f3a5"
dependencies = [ dependencies = [
"fastrand 2.1.0", "fastrand",
"futures-core", "futures-core",
"futures-io", "futures-io",
"parking", "parking",
@ -2491,7 +2432,7 @@ dependencies = [
"http-body", "http-body",
"hyper", "hyper",
"pin-project-lite", "pin-project-lite",
"socket2 0.5.7", "socket2",
"tokio", "tokio",
"tower", "tower",
"tower-service", "tower-service",
@ -4006,7 +3947,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "464db0c665917b13ebb5d453ccdec4add5658ee1adc7affc7677615356a8afaf" checksum = "464db0c665917b13ebb5d453ccdec4add5658ee1adc7affc7677615356a8afaf"
dependencies = [ dependencies = [
"atomic-waker", "atomic-waker",
"fastrand 2.1.0", "fastrand",
"futures-io", "futures-io",
] ]
@ -4084,22 +4025,6 @@ dependencies = [
"miniz_oxide 0.7.2", "miniz_oxide 0.7.2",
] ]
[[package]]
name = "polling"
version = "2.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4b2d323e8ca7996b3e23126511a523f7e62924d93ecd5ae73b333815b0eb3dce"
dependencies = [
"autocfg",
"bitflags 1.3.2",
"cfg-if",
"concurrent-queue",
"libc",
"log",
"pin-project-lite",
"windows-sys 0.48.0",
]
[[package]] [[package]]
name = "polling" name = "polling"
version = "3.7.0" version = "3.7.0"
@ -4259,7 +4184,7 @@ version = "0.2.0"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"async-executor", "async-executor",
"async-io 2.3.2", "async-io",
"async-task", "async-task",
"flume", "flume",
"lazy_static", "lazy_static",
@ -5123,43 +5048,12 @@ dependencies = [
"async-channel", "async-channel",
"async-executor", "async-executor",
"async-fs", "async-fs",
"async-io 2.3.2", "async-io",
"async-lock 3.3.0", "async-lock",
"async-net", "async-net",
"async-process", "async-process",
"blocking", "blocking",
"futures-lite 2.3.0", "futures-lite",
]
[[package]]
name = "smol-potat"
version = "1.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "894ffa61af5c0fab697c8c29b1ab10cb6ec4978a1ccac4a81b5b312df1ffd88e"
dependencies = [
"async-io 1.13.0",
"smol-potat-macro",
]
[[package]]
name = "smol-potat-macro"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6b7cd8129a18069385b4eadaa81182b1451fab312ad6f58d1d99253082bf3932"
dependencies = [
"proc-macro2",
"quote",
"syn 1.0.109",
]
[[package]]
name = "socket2"
version = "0.4.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9f7916fc008ca5542385b89a3d3ce689953c143e9304a9bf8beec1de48994c0d"
dependencies = [
"libc",
"winapi",
] ]
[[package]] [[package]]
@ -5427,7 +5321,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"fastrand 2.1.0", "fastrand",
"rustix 0.38.34", "rustix 0.38.34",
"windows-sys 0.52.0", "windows-sys 0.52.0",
] ]
@ -5730,7 +5624,7 @@ dependencies = [
"mio", "mio",
"num_cpus", "num_cpus",
"pin-project-lite", "pin-project-lite",
"socket2 0.5.7", "socket2",
"tokio-macros", "tokio-macros",
"windows-sys 0.48.0", "windows-sys 0.48.0",
] ]
@ -6104,12 +5998,6 @@ dependencies = [
"utf8parse", "utf8parse",
] ]
[[package]]
name = "waker-fn"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "317211a0dc0ceedd78fb2ca9a44aed3d7b9b26f81870d485c07122b4350673b7"
[[package]] [[package]]
name = "walkdir" name = "walkdir"
version = "2.5.0" version = "2.5.0"
@ -6398,7 +6286,7 @@ name = "wezterm-client"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"async-io 2.3.2", "async-io",
"async-trait", "async-trait",
"async_ossl", "async_ossl",
"codec", "codec",
@ -6533,7 +6421,7 @@ dependencies = [
"env-bootstrap", "env-bootstrap",
"env_logger 0.11.3", "env_logger 0.11.3",
"euclid", "euclid",
"fastrand 2.1.0", "fastrand",
"filedescriptor", "filedescriptor",
"finl_unicode", "finl_unicode",
"frecency", "frecency",
@ -6651,7 +6539,7 @@ name = "wezterm-mux-server-impl"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"async-io 2.3.2", "async-io",
"async_ossl", "async_ossl",
"codec", "codec",
"config", "config",
@ -6707,8 +6595,7 @@ dependencies = [
"rstest", "rstest",
"shell-words", "shell-words",
"smol", "smol",
"smol-potat", "socket2",
"socket2 0.5.7",
"ssh2", "ssh2",
"termwiz", "termwiz",
"thiserror", "thiserror",
@ -6749,7 +6636,7 @@ dependencies = [
name = "wezterm-toast-notification" name = "wezterm-toast-notification"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"async-io 2.3.2", "async-io",
"cocoa 0.20.2", "cocoa 0.20.2",
"core-foundation 0.7.0", "core-foundation 0.7.0",
"futures-util", "futures-util",
@ -6938,7 +6825,7 @@ version = "0.1.0"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"async-channel", "async-channel",
"async-io 2.3.2", "async-io",
"async-task", "async-task",
"async-trait", "async-trait",
"bitflags 1.3.2", "bitflags 1.3.2",
@ -6953,7 +6840,7 @@ dependencies = [
"downcast-rs", "downcast-rs",
"euclid", "euclid",
"filedescriptor", "filedescriptor",
"futures-lite 1.13.0", "futures-lite",
"futures-util", "futures-util",
"gl_generator", "gl_generator",
"glium", "glium",
@ -7449,8 +7336,8 @@ dependencies = [
"async-broadcast", "async-broadcast",
"async-executor", "async-executor",
"async-fs", "async-fs",
"async-io 2.3.2", "async-io",
"async-lock 3.3.0", "async-lock",
"async-process", "async-process",
"async-recursion", "async-recursion",
"async-task", "async-task",

View File

@ -49,6 +49,5 @@ predicates = "3.0"
env_logger = "0.11" env_logger = "0.11"
rstest = "0.19" rstest = "0.19"
shell-words = "1.1" shell-words = "1.1"
smol-potat = "1.1.2"
termwiz = { version = "0.22", path = "../termwiz" } termwiz = { version = "0.22", path = "../termwiz" }
whoami = "1.5" whoami = "1.5"

View File

@ -14,40 +14,42 @@ async fn session_with_agent_forward(
} }
#[rstest] #[rstest]
#[smol_potat::test]
#[cfg_attr(not(any(target_os = "macos", target_os = "linux")), ignore)] #[cfg_attr(not(any(target_os = "macos", target_os = "linux")), ignore)]
#[cfg_attr(not(feature = "libssh-rs"), ignore)] #[cfg_attr(not(feature = "libssh-rs"), ignore)]
async fn ssh_add_should_be_able_to_list_identities_with_agent_forward( fn ssh_add_should_be_able_to_list_identities_with_agent_forward(
#[future] session_with_agent_forward: SessionWithSshd, #[future] session_with_agent_forward: SessionWithSshd,
) { ) {
let session: SessionWithSshd = session_with_agent_forward.await; smol::block_on(async {
let session: SessionWithSshd = session_with_agent_forward.await;
let (pty, _child_process) = session let (pty, _child_process) = session
.request_pty("dumb", PtySize::default(), Some("ssh-add -l"), None) .request_pty("dumb", PtySize::default(), Some("ssh-add -l"), None)
.await .await
.unwrap(); .unwrap();
let mut reader = pty.try_clone_reader().unwrap(); let mut reader = pty.try_clone_reader().unwrap();
let mut output: String = String::new(); let mut output: String = String::new();
reader.read_to_string(&mut output).unwrap(); reader.read_to_string(&mut output).unwrap();
assert_eq!(output, "The agent has no identities.\r\n"); assert_eq!(output, "The agent has no identities.\r\n");
})
} }
#[rstest] #[rstest]
#[smol_potat::test]
#[cfg_attr(not(any(target_os = "macos", target_os = "linux")), ignore)] #[cfg_attr(not(any(target_os = "macos", target_os = "linux")), ignore)]
#[cfg_attr(not(feature = "libssh-rs"), ignore)] #[cfg_attr(not(feature = "libssh-rs"), ignore)]
async fn no_agent_forward_should_happen_when_disabled(#[future] session: SessionWithSshd) { fn no_agent_forward_should_happen_when_disabled(#[future] session: SessionWithSshd) {
let session: SessionWithSshd = session.await; smol::block_on(async {
let session: SessionWithSshd = session.await;
let (pty, _child_process) = session let (pty, _child_process) = session
.request_pty("dumb", PtySize::default(), Some("ssh-add -l"), None) .request_pty("dumb", PtySize::default(), Some("ssh-add -l"), None)
.await .await
.unwrap(); .unwrap();
let mut reader = pty.try_clone_reader().unwrap(); let mut reader = pty.try_clone_reader().unwrap();
let mut output: String = String::new(); let mut output: String = String::new();
reader.read_to_string(&mut output).unwrap(); reader.read_to_string(&mut output).unwrap();
assert_eq!( assert_eq!(
output, output,
"Could not open a connection to your authentication agent.\r\n" "Could not open a connection to your authentication agent.\r\n"
); );
})
} }

File diff suppressed because it is too large Load Diff

View File

@ -7,187 +7,193 @@ use std::convert::TryInto;
use std::path::PathBuf; use std::path::PathBuf;
#[rstest] #[rstest]
#[smol_potat::test]
#[cfg_attr(not(any(target_os = "macos", target_os = "linux")), ignore)] #[cfg_attr(not(any(target_os = "macos", target_os = "linux")), ignore)]
async fn metadata_should_retrieve_file_stat(#[future] session: SessionWithSshd) { fn metadata_should_retrieve_file_stat(#[future] session: SessionWithSshd) {
let session: SessionWithSshd = session.await; smol::block_on(async {
let session: SessionWithSshd = session.await;
let temp = TempDir::new().unwrap(); let temp = TempDir::new().unwrap();
let file = temp.child("test-file"); let file = temp.child("test-file");
file.touch().unwrap(); file.touch().unwrap();
let remote_file = session let remote_file = session
.sftp() .sftp()
.open(file.path().to_path_buf()) .open(file.path().to_path_buf())
.await .await
.expect("Failed to open remote file"); .expect("Failed to open remote file");
let metadata = remote_file let metadata = remote_file
.metadata() .metadata()
.await .await
.expect("Failed to read file metadata"); .expect("Failed to read file metadata");
// Verify that file stat makes sense // Verify that file stat makes sense
assert!(metadata.is_file(), "Invalid file metadata returned"); assert!(metadata.is_file(), "Invalid file metadata returned");
})
} }
#[rstest] #[rstest]
#[smol_potat::test]
#[cfg_attr(not(any(target_os = "macos", target_os = "linux")), ignore)] #[cfg_attr(not(any(target_os = "macos", target_os = "linux")), ignore)]
async fn read_dir_should_retrieve_next_dir_entry(#[future] session: SessionWithSshd) { fn read_dir_should_retrieve_next_dir_entry(#[future] session: SessionWithSshd) {
let session: SessionWithSshd = session.await; smol::block_on(async {
let session: SessionWithSshd = session.await;
let temp = TempDir::new().unwrap(); let temp = TempDir::new().unwrap();
let dir = temp.child("dir"); let dir = temp.child("dir");
dir.create_dir_all().unwrap(); dir.create_dir_all().unwrap();
let file = temp.child("file"); let file = temp.child("file");
file.touch().unwrap(); file.touch().unwrap();
let link = temp.child("link"); let link = temp.child("link");
link.symlink_to_file(file.path()).unwrap(); link.symlink_to_file(file.path()).unwrap();
let remote_dir = session let remote_dir = session
.sftp() .sftp()
.open_dir(temp.path().to_path_buf()) .open_dir(temp.path().to_path_buf())
.await .await
.expect("Failed to open remote directory"); .expect("Failed to open remote directory");
// Collect all of the directory contents (. and .. are included) // Collect all of the directory contents (. and .. are included)
let mut contents = Vec::new(); let mut contents = Vec::new();
while let Ok((path, metadata)) = remote_dir.read_dir().await { while let Ok((path, metadata)) = remote_dir.read_dir().await {
let ft = metadata.ty; let ft = metadata.ty;
contents.push(( contents.push((
path, path,
if ft.is_dir() { if ft.is_dir() {
"dir" "dir"
} else if ft.is_file() { } else if ft.is_file() {
"file" "file"
} else { } else {
"symlink" "symlink"
}, },
)); ));
} }
contents.sort_unstable_by_key(|(p, _)| p.to_path_buf()); contents.sort_unstable_by_key(|(p, _)| p.to_path_buf());
assert_eq!( assert_eq!(
contents, contents,
vec![ vec![
(PathBuf::from(".").try_into().unwrap(), "dir"), (PathBuf::from(".").try_into().unwrap(), "dir"),
(PathBuf::from("..").try_into().unwrap(), "dir"), (PathBuf::from("..").try_into().unwrap(), "dir"),
(PathBuf::from("dir").try_into().unwrap(), "dir"), (PathBuf::from("dir").try_into().unwrap(), "dir"),
(PathBuf::from("file").try_into().unwrap(), "file"), (PathBuf::from("file").try_into().unwrap(), "file"),
(PathBuf::from("link").try_into().unwrap(), "symlink"), (PathBuf::from("link").try_into().unwrap(), "symlink"),
] ]
); );
})
} }
#[rstest] #[rstest]
#[smol_potat::test]
#[cfg_attr(not(any(target_os = "macos", target_os = "linux")), ignore)] #[cfg_attr(not(any(target_os = "macos", target_os = "linux")), ignore)]
async fn should_support_async_reading(#[future] session: SessionWithSshd) { fn should_support_async_reading(#[future] session: SessionWithSshd) {
let session: SessionWithSshd = session.await; smol::block_on(async {
let session: SessionWithSshd = session.await;
let temp = TempDir::new().unwrap(); let temp = TempDir::new().unwrap();
let file = temp.child("test-file"); let file = temp.child("test-file");
file.write_str("some file contents").unwrap(); file.write_str("some file contents").unwrap();
let mut remote_file = session let mut remote_file = session
.sftp() .sftp()
.open(file.path().to_path_buf()) .open(file.path().to_path_buf())
.await .await
.expect("Failed to open remote file"); .expect("Failed to open remote file");
let mut contents = String::new(); let mut contents = String::new();
remote_file remote_file
.read_to_string(&mut contents) .read_to_string(&mut contents)
.await .await
.expect("Failed to read file to string"); .expect("Failed to read file to string");
assert_eq!(contents, "some file contents"); assert_eq!(contents, "some file contents");
// NOTE: Testing second time to ensure future is properly cleared // NOTE: Testing second time to ensure future is properly cleared
let mut contents = String::new(); let mut contents = String::new();
remote_file remote_file
.read_to_string(&mut contents) .read_to_string(&mut contents)
.await .await
.expect("Failed to read file to string second time"); .expect("Failed to read file to string second time");
})
} }
#[rstest] #[rstest]
#[smol_potat::test]
#[cfg_attr(not(any(target_os = "macos", target_os = "linux")), ignore)] #[cfg_attr(not(any(target_os = "macos", target_os = "linux")), ignore)]
async fn should_support_async_writing(#[future] session: SessionWithSshd) { fn should_support_async_writing(#[future] session: SessionWithSshd) {
let session: SessionWithSshd = session.await; smol::block_on(async {
let session: SessionWithSshd = session.await;
let temp = TempDir::new().unwrap(); let temp = TempDir::new().unwrap();
let file = temp.child("test-file"); let file = temp.child("test-file");
file.write_str("some file contents").unwrap(); file.write_str("some file contents").unwrap();
let mut remote_file = session let mut remote_file = session
.sftp() .sftp()
.create(file.path().to_path_buf()) .create(file.path().to_path_buf())
.await .await
.expect("Failed to open remote file"); .expect("Failed to open remote file");
remote_file remote_file
.write_all(b"new contents for file") .write_all(b"new contents for file")
.await .await
.expect("Failed to write to file"); .expect("Failed to write to file");
file.assert("new contents for file"); file.assert("new contents for file");
// NOTE: Testing second time to ensure future is properly cleared // NOTE: Testing second time to ensure future is properly cleared
remote_file remote_file
.write_all(b"new contents for file") .write_all(b"new contents for file")
.await .await
.expect("Failed to write to file second time"); .expect("Failed to write to file second time");
})
} }
#[rstest] #[rstest]
#[smol_potat::test]
#[cfg_attr(not(any(target_os = "macos", target_os = "linux")), ignore)] #[cfg_attr(not(any(target_os = "macos", target_os = "linux")), ignore)]
async fn should_support_async_flush(#[future] session: SessionWithSshd) { fn should_support_async_flush(#[future] session: SessionWithSshd) {
let session: SessionWithSshd = session.await; smol::block_on(async {
let session: SessionWithSshd = session.await;
let temp = TempDir::new().unwrap(); let temp = TempDir::new().unwrap();
let file = temp.child("test-file"); let file = temp.child("test-file");
file.write_str("some file contents").unwrap(); file.write_str("some file contents").unwrap();
let mut remote_file = session let mut remote_file = session
.sftp() .sftp()
.create(file.path().to_path_buf()) .create(file.path().to_path_buf())
.await .await
.expect("Failed to open remote file"); .expect("Failed to open remote file");
remote_file.flush().await.expect("Failed to flush file"); remote_file.flush().await.expect("Failed to flush file");
// NOTE: Testing second time to ensure future is properly cleared // NOTE: Testing second time to ensure future is properly cleared
remote_file remote_file
.flush() .flush()
.await .await
.expect("Failed to flush file second time"); .expect("Failed to flush file second time");
})
} }
#[rstest] #[rstest]
#[smol_potat::test]
#[cfg_attr(not(any(target_os = "macos", target_os = "linux")), ignore)] #[cfg_attr(not(any(target_os = "macos", target_os = "linux")), ignore)]
async fn should_support_async_close(#[future] session: SessionWithSshd) { fn should_support_async_close(#[future] session: SessionWithSshd) {
let session: SessionWithSshd = session.await; smol::block_on(async {
let session: SessionWithSshd = session.await;
let temp = TempDir::new().unwrap(); let temp = TempDir::new().unwrap();
let file = temp.child("test-file"); let file = temp.child("test-file");
file.write_str("some file contents").unwrap(); file.write_str("some file contents").unwrap();
let mut remote_file = session let mut remote_file = session
.sftp() .sftp()
.create(file.path().to_path_buf()) .create(file.path().to_path_buf())
.await .await
.expect("Failed to open remote file"); .expect("Failed to open remote file");
remote_file.close().await.expect("Failed to close file"); remote_file.close().await.expect("Failed to close file");
// NOTE: Testing second time to ensure future is properly cleared // NOTE: Testing second time to ensure future is properly cleared
remote_file remote_file
.close() .close()
.await .await
.expect("Failed to close file second time"); .expect("Failed to close file second time");
})
} }

View File

@ -71,7 +71,7 @@ winreg = "0.10"
dirs-next = "2.0" dirs-next = "2.0"
filedescriptor = { version="0.8", path = "../filedescriptor" } filedescriptor = { version="0.8", path = "../filedescriptor" }
futures-util = "0.3" futures-util = "0.3"
futures-lite = "1.12" futures-lite = "2.3"
x11 = {version ="2.21", features = ["xlib_xcb", "xlib"]} x11 = {version ="2.21", features = ["xlib_xcb", "xlib"]}
xcb = {version="1.3", features=["render", "randr", "dri2", "xkb", "xlib_xcb", "present", "as-raw-xcb-connection"]} xcb = {version="1.3", features=["render", "randr", "dri2", "xkb", "xlib_xcb", "present", "as-raw-xcb-connection"]}
xkbcommon = { version = "0.7.0", features = ["x11", "wayland"] } xkbcommon = { version = "0.7.0", features = ["x11", "wayland"] }