mirror of
https://github.com/wez/wezterm.git
synced 2024-08-16 17:50:28 +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:
parent
944e0b29b6
commit
6ad0da98d8
183
Cargo.lock
generated
183
Cargo.lock
generated
@ -225,8 +225,8 @@ checksum = "b10202063978b3351199d68f8b22c4e47e4b1b822f8d43fd862d5ea8c006b29a"
|
||||
dependencies = [
|
||||
"async-task",
|
||||
"concurrent-queue",
|
||||
"fastrand 2.1.0",
|
||||
"futures-lite 2.3.0",
|
||||
"fastrand",
|
||||
"futures-lite",
|
||||
"slab",
|
||||
]
|
||||
|
||||
@ -236,29 +236,9 @@ version = "2.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ebcd09b382f40fcd159c2d695175b2ae620ffa5f3bd6f664131efff4e8b9e04a"
|
||||
dependencies = [
|
||||
"async-lock 3.3.0",
|
||||
"async-lock",
|
||||
"blocking",
|
||||
"futures-lite 2.3.0",
|
||||
]
|
||||
|
||||
[[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",
|
||||
"futures-lite",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -267,28 +247,19 @@ version = "2.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dcccb0f599cfa2f8ace422d3555572f47424da5648a4382a9dd0310ff8210884"
|
||||
dependencies = [
|
||||
"async-lock 3.3.0",
|
||||
"async-lock",
|
||||
"cfg-if",
|
||||
"concurrent-queue",
|
||||
"futures-io",
|
||||
"futures-lite 2.3.0",
|
||||
"futures-lite",
|
||||
"parking",
|
||||
"polling 3.7.0",
|
||||
"polling",
|
||||
"rustix 0.38.34",
|
||||
"slab",
|
||||
"tracing",
|
||||
"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]]
|
||||
name = "async-lock"
|
||||
version = "3.3.0"
|
||||
@ -306,9 +277,9 @@ version = "2.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b948000fad4873c1c9339d60f2623323a0cfd3816e5181033c6a5cb68b2accf7"
|
||||
dependencies = [
|
||||
"async-io 2.3.2",
|
||||
"async-io",
|
||||
"blocking",
|
||||
"futures-lite 2.3.0",
|
||||
"futures-lite",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -318,14 +289,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a53fc6301894e04a92cb2584fedde80cb25ba8e02d9dc39d4a87d036e22f397d"
|
||||
dependencies = [
|
||||
"async-channel",
|
||||
"async-io 2.3.2",
|
||||
"async-lock 3.3.0",
|
||||
"async-io",
|
||||
"async-lock",
|
||||
"async-signal",
|
||||
"async-task",
|
||||
"blocking",
|
||||
"cfg-if",
|
||||
"event-listener 5.3.0",
|
||||
"futures-lite 2.3.0",
|
||||
"futures-lite",
|
||||
"rustix 0.38.34",
|
||||
"tracing",
|
||||
"windows-sys 0.52.0",
|
||||
@ -348,8 +319,8 @@ version = "0.2.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "afe66191c335039c7bb78f99dc7520b0cbb166b3a1cb33a03f53d8a1c6f2afda"
|
||||
dependencies = [
|
||||
"async-io 2.3.2",
|
||||
"async-lock 3.3.0",
|
||||
"async-io",
|
||||
"async-lock",
|
||||
"atomic-waker",
|
||||
"cfg-if",
|
||||
"futures-core",
|
||||
@ -381,7 +352,7 @@ dependencies = [
|
||||
name = "async_ossl"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"async-io 2.3.2",
|
||||
"async-io",
|
||||
"openssl",
|
||||
]
|
||||
|
||||
@ -554,10 +525,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "495f7104e962b7356f0aeb34247aca1fe7d2e783b346582db7f2904cb5717e88"
|
||||
dependencies = [
|
||||
"async-channel",
|
||||
"async-lock 3.3.0",
|
||||
"async-lock",
|
||||
"async-task",
|
||||
"futures-io",
|
||||
"futures-lite 2.3.0",
|
||||
"futures-lite",
|
||||
"piper",
|
||||
]
|
||||
|
||||
@ -1583,12 +1554,6 @@ dependencies = [
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "event-listener"
|
||||
version = "2.5.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0"
|
||||
|
||||
[[package]]
|
||||
name = "event-listener"
|
||||
version = "4.0.3"
|
||||
@ -1669,15 +1634,6 @@ dependencies = [
|
||||
"regex",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fastrand"
|
||||
version = "1.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be"
|
||||
dependencies = [
|
||||
"instant",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fastrand"
|
||||
version = "2.1.0"
|
||||
@ -1932,28 +1888,13 @@ version = "0.3.30"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
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]]
|
||||
name = "futures-lite"
|
||||
version = "2.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "52527eb5074e35e9339c6b4e8d12600c7128b68fb25dcb9fa9dec18f7c25f3a5"
|
||||
dependencies = [
|
||||
"fastrand 2.1.0",
|
||||
"fastrand",
|
||||
"futures-core",
|
||||
"futures-io",
|
||||
"parking",
|
||||
@ -2491,7 +2432,7 @@ dependencies = [
|
||||
"http-body",
|
||||
"hyper",
|
||||
"pin-project-lite",
|
||||
"socket2 0.5.7",
|
||||
"socket2",
|
||||
"tokio",
|
||||
"tower",
|
||||
"tower-service",
|
||||
@ -4006,7 +3947,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "464db0c665917b13ebb5d453ccdec4add5658ee1adc7affc7677615356a8afaf"
|
||||
dependencies = [
|
||||
"atomic-waker",
|
||||
"fastrand 2.1.0",
|
||||
"fastrand",
|
||||
"futures-io",
|
||||
]
|
||||
|
||||
@ -4084,22 +4025,6 @@ dependencies = [
|
||||
"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]]
|
||||
name = "polling"
|
||||
version = "3.7.0"
|
||||
@ -4259,7 +4184,7 @@ version = "0.2.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-executor",
|
||||
"async-io 2.3.2",
|
||||
"async-io",
|
||||
"async-task",
|
||||
"flume",
|
||||
"lazy_static",
|
||||
@ -5123,43 +5048,12 @@ dependencies = [
|
||||
"async-channel",
|
||||
"async-executor",
|
||||
"async-fs",
|
||||
"async-io 2.3.2",
|
||||
"async-lock 3.3.0",
|
||||
"async-io",
|
||||
"async-lock",
|
||||
"async-net",
|
||||
"async-process",
|
||||
"blocking",
|
||||
"futures-lite 2.3.0",
|
||||
]
|
||||
|
||||
[[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",
|
||||
"futures-lite",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -5427,7 +5321,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"fastrand 2.1.0",
|
||||
"fastrand",
|
||||
"rustix 0.38.34",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
@ -5730,7 +5624,7 @@ dependencies = [
|
||||
"mio",
|
||||
"num_cpus",
|
||||
"pin-project-lite",
|
||||
"socket2 0.5.7",
|
||||
"socket2",
|
||||
"tokio-macros",
|
||||
"windows-sys 0.48.0",
|
||||
]
|
||||
@ -6104,12 +5998,6 @@ dependencies = [
|
||||
"utf8parse",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "waker-fn"
|
||||
version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "317211a0dc0ceedd78fb2ca9a44aed3d7b9b26f81870d485c07122b4350673b7"
|
||||
|
||||
[[package]]
|
||||
name = "walkdir"
|
||||
version = "2.5.0"
|
||||
@ -6398,7 +6286,7 @@ name = "wezterm-client"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-io 2.3.2",
|
||||
"async-io",
|
||||
"async-trait",
|
||||
"async_ossl",
|
||||
"codec",
|
||||
@ -6533,7 +6421,7 @@ dependencies = [
|
||||
"env-bootstrap",
|
||||
"env_logger 0.11.3",
|
||||
"euclid",
|
||||
"fastrand 2.1.0",
|
||||
"fastrand",
|
||||
"filedescriptor",
|
||||
"finl_unicode",
|
||||
"frecency",
|
||||
@ -6651,7 +6539,7 @@ name = "wezterm-mux-server-impl"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-io 2.3.2",
|
||||
"async-io",
|
||||
"async_ossl",
|
||||
"codec",
|
||||
"config",
|
||||
@ -6707,8 +6595,7 @@ dependencies = [
|
||||
"rstest",
|
||||
"shell-words",
|
||||
"smol",
|
||||
"smol-potat",
|
||||
"socket2 0.5.7",
|
||||
"socket2",
|
||||
"ssh2",
|
||||
"termwiz",
|
||||
"thiserror",
|
||||
@ -6749,7 +6636,7 @@ dependencies = [
|
||||
name = "wezterm-toast-notification"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"async-io 2.3.2",
|
||||
"async-io",
|
||||
"cocoa 0.20.2",
|
||||
"core-foundation 0.7.0",
|
||||
"futures-util",
|
||||
@ -6938,7 +6825,7 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-channel",
|
||||
"async-io 2.3.2",
|
||||
"async-io",
|
||||
"async-task",
|
||||
"async-trait",
|
||||
"bitflags 1.3.2",
|
||||
@ -6953,7 +6840,7 @@ dependencies = [
|
||||
"downcast-rs",
|
||||
"euclid",
|
||||
"filedescriptor",
|
||||
"futures-lite 1.13.0",
|
||||
"futures-lite",
|
||||
"futures-util",
|
||||
"gl_generator",
|
||||
"glium",
|
||||
@ -7449,8 +7336,8 @@ dependencies = [
|
||||
"async-broadcast",
|
||||
"async-executor",
|
||||
"async-fs",
|
||||
"async-io 2.3.2",
|
||||
"async-lock 3.3.0",
|
||||
"async-io",
|
||||
"async-lock",
|
||||
"async-process",
|
||||
"async-recursion",
|
||||
"async-task",
|
||||
|
@ -49,6 +49,5 @@ predicates = "3.0"
|
||||
env_logger = "0.11"
|
||||
rstest = "0.19"
|
||||
shell-words = "1.1"
|
||||
smol-potat = "1.1.2"
|
||||
termwiz = { version = "0.22", path = "../termwiz" }
|
||||
whoami = "1.5"
|
||||
|
@ -14,40 +14,42 @@ async fn session_with_agent_forward(
|
||||
}
|
||||
|
||||
#[rstest]
|
||||
#[smol_potat::test]
|
||||
#[cfg_attr(not(any(target_os = "macos", target_os = "linux")), 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,
|
||||
) {
|
||||
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
|
||||
.request_pty("dumb", PtySize::default(), Some("ssh-add -l"), None)
|
||||
.await
|
||||
.unwrap();
|
||||
let mut reader = pty.try_clone_reader().unwrap();
|
||||
let mut output: String = String::new();
|
||||
reader.read_to_string(&mut output).unwrap();
|
||||
assert_eq!(output, "The agent has no identities.\r\n");
|
||||
let (pty, _child_process) = session
|
||||
.request_pty("dumb", PtySize::default(), Some("ssh-add -l"), None)
|
||||
.await
|
||||
.unwrap();
|
||||
let mut reader = pty.try_clone_reader().unwrap();
|
||||
let mut output: String = String::new();
|
||||
reader.read_to_string(&mut output).unwrap();
|
||||
assert_eq!(output, "The agent has no identities.\r\n");
|
||||
})
|
||||
}
|
||||
|
||||
#[rstest]
|
||||
#[smol_potat::test]
|
||||
#[cfg_attr(not(any(target_os = "macos", target_os = "linux")), ignore)]
|
||||
#[cfg_attr(not(feature = "libssh-rs"), ignore)]
|
||||
async fn no_agent_forward_should_happen_when_disabled(#[future] session: SessionWithSshd) {
|
||||
let session: SessionWithSshd = session.await;
|
||||
fn no_agent_forward_should_happen_when_disabled(#[future] session: SessionWithSshd) {
|
||||
smol::block_on(async {
|
||||
let session: SessionWithSshd = session.await;
|
||||
|
||||
let (pty, _child_process) = session
|
||||
.request_pty("dumb", PtySize::default(), Some("ssh-add -l"), None)
|
||||
.await
|
||||
.unwrap();
|
||||
let mut reader = pty.try_clone_reader().unwrap();
|
||||
let mut output: String = String::new();
|
||||
reader.read_to_string(&mut output).unwrap();
|
||||
assert_eq!(
|
||||
output,
|
||||
"Could not open a connection to your authentication agent.\r\n"
|
||||
);
|
||||
let (pty, _child_process) = session
|
||||
.request_pty("dumb", PtySize::default(), Some("ssh-add -l"), None)
|
||||
.await
|
||||
.unwrap();
|
||||
let mut reader = pty.try_clone_reader().unwrap();
|
||||
let mut output: String = String::new();
|
||||
reader.read_to_string(&mut output).unwrap();
|
||||
assert_eq!(
|
||||
output,
|
||||
"Could not open a connection to your authentication agent.\r\n"
|
||||
);
|
||||
})
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -7,187 +7,193 @@ use std::convert::TryInto;
|
||||
use std::path::PathBuf;
|
||||
|
||||
#[rstest]
|
||||
#[smol_potat::test]
|
||||
#[cfg_attr(not(any(target_os = "macos", target_os = "linux")), ignore)]
|
||||
async fn metadata_should_retrieve_file_stat(#[future] session: SessionWithSshd) {
|
||||
let session: SessionWithSshd = session.await;
|
||||
fn metadata_should_retrieve_file_stat(#[future] session: SessionWithSshd) {
|
||||
smol::block_on(async {
|
||||
let session: SessionWithSshd = session.await;
|
||||
|
||||
let temp = TempDir::new().unwrap();
|
||||
let file = temp.child("test-file");
|
||||
file.touch().unwrap();
|
||||
let temp = TempDir::new().unwrap();
|
||||
let file = temp.child("test-file");
|
||||
file.touch().unwrap();
|
||||
|
||||
let remote_file = session
|
||||
.sftp()
|
||||
.open(file.path().to_path_buf())
|
||||
.await
|
||||
.expect("Failed to open remote file");
|
||||
let remote_file = session
|
||||
.sftp()
|
||||
.open(file.path().to_path_buf())
|
||||
.await
|
||||
.expect("Failed to open remote file");
|
||||
|
||||
let metadata = remote_file
|
||||
.metadata()
|
||||
.await
|
||||
.expect("Failed to read file metadata");
|
||||
let metadata = remote_file
|
||||
.metadata()
|
||||
.await
|
||||
.expect("Failed to read file metadata");
|
||||
|
||||
// Verify that file stat makes sense
|
||||
assert!(metadata.is_file(), "Invalid file metadata returned");
|
||||
// Verify that file stat makes sense
|
||||
assert!(metadata.is_file(), "Invalid file metadata returned");
|
||||
})
|
||||
}
|
||||
|
||||
#[rstest]
|
||||
#[smol_potat::test]
|
||||
#[cfg_attr(not(any(target_os = "macos", target_os = "linux")), ignore)]
|
||||
async fn read_dir_should_retrieve_next_dir_entry(#[future] session: SessionWithSshd) {
|
||||
let session: SessionWithSshd = session.await;
|
||||
fn read_dir_should_retrieve_next_dir_entry(#[future] session: SessionWithSshd) {
|
||||
smol::block_on(async {
|
||||
let session: SessionWithSshd = session.await;
|
||||
|
||||
let temp = TempDir::new().unwrap();
|
||||
let dir = temp.child("dir");
|
||||
dir.create_dir_all().unwrap();
|
||||
let file = temp.child("file");
|
||||
file.touch().unwrap();
|
||||
let link = temp.child("link");
|
||||
link.symlink_to_file(file.path()).unwrap();
|
||||
let temp = TempDir::new().unwrap();
|
||||
let dir = temp.child("dir");
|
||||
dir.create_dir_all().unwrap();
|
||||
let file = temp.child("file");
|
||||
file.touch().unwrap();
|
||||
let link = temp.child("link");
|
||||
link.symlink_to_file(file.path()).unwrap();
|
||||
|
||||
let remote_dir = session
|
||||
.sftp()
|
||||
.open_dir(temp.path().to_path_buf())
|
||||
.await
|
||||
.expect("Failed to open remote directory");
|
||||
let remote_dir = session
|
||||
.sftp()
|
||||
.open_dir(temp.path().to_path_buf())
|
||||
.await
|
||||
.expect("Failed to open remote directory");
|
||||
|
||||
// Collect all of the directory contents (. and .. are included)
|
||||
let mut contents = Vec::new();
|
||||
while let Ok((path, metadata)) = remote_dir.read_dir().await {
|
||||
let ft = metadata.ty;
|
||||
contents.push((
|
||||
path,
|
||||
if ft.is_dir() {
|
||||
"dir"
|
||||
} else if ft.is_file() {
|
||||
"file"
|
||||
} else {
|
||||
"symlink"
|
||||
},
|
||||
));
|
||||
}
|
||||
contents.sort_unstable_by_key(|(p, _)| p.to_path_buf());
|
||||
// Collect all of the directory contents (. and .. are included)
|
||||
let mut contents = Vec::new();
|
||||
while let Ok((path, metadata)) = remote_dir.read_dir().await {
|
||||
let ft = metadata.ty;
|
||||
contents.push((
|
||||
path,
|
||||
if ft.is_dir() {
|
||||
"dir"
|
||||
} else if ft.is_file() {
|
||||
"file"
|
||||
} else {
|
||||
"symlink"
|
||||
},
|
||||
));
|
||||
}
|
||||
contents.sort_unstable_by_key(|(p, _)| p.to_path_buf());
|
||||
|
||||
assert_eq!(
|
||||
contents,
|
||||
vec![
|
||||
(PathBuf::from(".").try_into().unwrap(), "dir"),
|
||||
(PathBuf::from("..").try_into().unwrap(), "dir"),
|
||||
(PathBuf::from("dir").try_into().unwrap(), "dir"),
|
||||
(PathBuf::from("file").try_into().unwrap(), "file"),
|
||||
(PathBuf::from("link").try_into().unwrap(), "symlink"),
|
||||
]
|
||||
);
|
||||
assert_eq!(
|
||||
contents,
|
||||
vec![
|
||||
(PathBuf::from(".").try_into().unwrap(), "dir"),
|
||||
(PathBuf::from("..").try_into().unwrap(), "dir"),
|
||||
(PathBuf::from("dir").try_into().unwrap(), "dir"),
|
||||
(PathBuf::from("file").try_into().unwrap(), "file"),
|
||||
(PathBuf::from("link").try_into().unwrap(), "symlink"),
|
||||
]
|
||||
);
|
||||
})
|
||||
}
|
||||
|
||||
#[rstest]
|
||||
#[smol_potat::test]
|
||||
#[cfg_attr(not(any(target_os = "macos", target_os = "linux")), ignore)]
|
||||
async fn should_support_async_reading(#[future] session: SessionWithSshd) {
|
||||
let session: SessionWithSshd = session.await;
|
||||
fn should_support_async_reading(#[future] session: SessionWithSshd) {
|
||||
smol::block_on(async {
|
||||
let session: SessionWithSshd = session.await;
|
||||
|
||||
let temp = TempDir::new().unwrap();
|
||||
let file = temp.child("test-file");
|
||||
file.write_str("some file contents").unwrap();
|
||||
let temp = TempDir::new().unwrap();
|
||||
let file = temp.child("test-file");
|
||||
file.write_str("some file contents").unwrap();
|
||||
|
||||
let mut remote_file = session
|
||||
.sftp()
|
||||
.open(file.path().to_path_buf())
|
||||
.await
|
||||
.expect("Failed to open remote file");
|
||||
let mut remote_file = session
|
||||
.sftp()
|
||||
.open(file.path().to_path_buf())
|
||||
.await
|
||||
.expect("Failed to open remote file");
|
||||
|
||||
let mut contents = String::new();
|
||||
remote_file
|
||||
.read_to_string(&mut contents)
|
||||
.await
|
||||
.expect("Failed to read file to string");
|
||||
let mut contents = String::new();
|
||||
remote_file
|
||||
.read_to_string(&mut contents)
|
||||
.await
|
||||
.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
|
||||
let mut contents = String::new();
|
||||
remote_file
|
||||
.read_to_string(&mut contents)
|
||||
.await
|
||||
.expect("Failed to read file to string second time");
|
||||
// NOTE: Testing second time to ensure future is properly cleared
|
||||
let mut contents = String::new();
|
||||
remote_file
|
||||
.read_to_string(&mut contents)
|
||||
.await
|
||||
.expect("Failed to read file to string second time");
|
||||
})
|
||||
}
|
||||
|
||||
#[rstest]
|
||||
#[smol_potat::test]
|
||||
#[cfg_attr(not(any(target_os = "macos", target_os = "linux")), ignore)]
|
||||
async fn should_support_async_writing(#[future] session: SessionWithSshd) {
|
||||
let session: SessionWithSshd = session.await;
|
||||
fn should_support_async_writing(#[future] session: SessionWithSshd) {
|
||||
smol::block_on(async {
|
||||
let session: SessionWithSshd = session.await;
|
||||
|
||||
let temp = TempDir::new().unwrap();
|
||||
let file = temp.child("test-file");
|
||||
file.write_str("some file contents").unwrap();
|
||||
let temp = TempDir::new().unwrap();
|
||||
let file = temp.child("test-file");
|
||||
file.write_str("some file contents").unwrap();
|
||||
|
||||
let mut remote_file = session
|
||||
.sftp()
|
||||
.create(file.path().to_path_buf())
|
||||
.await
|
||||
.expect("Failed to open remote file");
|
||||
let mut remote_file = session
|
||||
.sftp()
|
||||
.create(file.path().to_path_buf())
|
||||
.await
|
||||
.expect("Failed to open remote file");
|
||||
|
||||
remote_file
|
||||
.write_all(b"new contents for file")
|
||||
.await
|
||||
.expect("Failed to write to file");
|
||||
remote_file
|
||||
.write_all(b"new contents for file")
|
||||
.await
|
||||
.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
|
||||
remote_file
|
||||
.write_all(b"new contents for file")
|
||||
.await
|
||||
.expect("Failed to write to file second time");
|
||||
// NOTE: Testing second time to ensure future is properly cleared
|
||||
remote_file
|
||||
.write_all(b"new contents for file")
|
||||
.await
|
||||
.expect("Failed to write to file second time");
|
||||
})
|
||||
}
|
||||
|
||||
#[rstest]
|
||||
#[smol_potat::test]
|
||||
#[cfg_attr(not(any(target_os = "macos", target_os = "linux")), ignore)]
|
||||
async fn should_support_async_flush(#[future] session: SessionWithSshd) {
|
||||
let session: SessionWithSshd = session.await;
|
||||
fn should_support_async_flush(#[future] session: SessionWithSshd) {
|
||||
smol::block_on(async {
|
||||
let session: SessionWithSshd = session.await;
|
||||
|
||||
let temp = TempDir::new().unwrap();
|
||||
let file = temp.child("test-file");
|
||||
file.write_str("some file contents").unwrap();
|
||||
let temp = TempDir::new().unwrap();
|
||||
let file = temp.child("test-file");
|
||||
file.write_str("some file contents").unwrap();
|
||||
|
||||
let mut remote_file = session
|
||||
.sftp()
|
||||
.create(file.path().to_path_buf())
|
||||
.await
|
||||
.expect("Failed to open remote file");
|
||||
let mut remote_file = session
|
||||
.sftp()
|
||||
.create(file.path().to_path_buf())
|
||||
.await
|
||||
.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
|
||||
remote_file
|
||||
.flush()
|
||||
.await
|
||||
.expect("Failed to flush file second time");
|
||||
// NOTE: Testing second time to ensure future is properly cleared
|
||||
remote_file
|
||||
.flush()
|
||||
.await
|
||||
.expect("Failed to flush file second time");
|
||||
})
|
||||
}
|
||||
|
||||
#[rstest]
|
||||
#[smol_potat::test]
|
||||
#[cfg_attr(not(any(target_os = "macos", target_os = "linux")), ignore)]
|
||||
async fn should_support_async_close(#[future] session: SessionWithSshd) {
|
||||
let session: SessionWithSshd = session.await;
|
||||
fn should_support_async_close(#[future] session: SessionWithSshd) {
|
||||
smol::block_on(async {
|
||||
let session: SessionWithSshd = session.await;
|
||||
|
||||
let temp = TempDir::new().unwrap();
|
||||
let file = temp.child("test-file");
|
||||
file.write_str("some file contents").unwrap();
|
||||
let temp = TempDir::new().unwrap();
|
||||
let file = temp.child("test-file");
|
||||
file.write_str("some file contents").unwrap();
|
||||
|
||||
let mut remote_file = session
|
||||
.sftp()
|
||||
.create(file.path().to_path_buf())
|
||||
.await
|
||||
.expect("Failed to open remote file");
|
||||
let mut remote_file = session
|
||||
.sftp()
|
||||
.create(file.path().to_path_buf())
|
||||
.await
|
||||
.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
|
||||
remote_file
|
||||
.close()
|
||||
.await
|
||||
.expect("Failed to close file second time");
|
||||
// NOTE: Testing second time to ensure future is properly cleared
|
||||
remote_file
|
||||
.close()
|
||||
.await
|
||||
.expect("Failed to close file second time");
|
||||
})
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ winreg = "0.10"
|
||||
dirs-next = "2.0"
|
||||
filedescriptor = { version="0.8", path = "../filedescriptor" }
|
||||
futures-util = "0.3"
|
||||
futures-lite = "1.12"
|
||||
futures-lite = "2.3"
|
||||
x11 = {version ="2.21", features = ["xlib_xcb", "xlib"]}
|
||||
xcb = {version="1.3", features=["render", "randr", "dri2", "xkb", "xlib_xcb", "present", "as-raw-xcb-connection"]}
|
||||
xkbcommon = { version = "0.7.0", features = ["x11", "wayland"] }
|
||||
|
Loading…
Reference in New Issue
Block a user