Skip to content

Commit 584142b

Browse files
committed
chore(deps): replace discontinued async-std with smol in dev deps
async-std was flagged by RUSTSEC-2025-0052 as unmaintained. It was only used in the `futures_support` example and integration tests; the library itself never depended on it. Swap the runtime for `smol`, which is the canonical maintained successor from the same ecosystem. - Cargo.toml: replace the `async-std` dev-dep with `smol = "2.0"`. - examples/uncompress_service_futures.rs: port to `smol::block_on` and `smol::net::TcpListener`. smol's `TcpStream` doesn't implement AsyncRead/AsyncWrite through a shared reference, so clone the socket to get an independent reader/writer pair. - tests/integration_test.rs: swap `#[async_std::test]` for `#[test]` wrapping `smol::block_on(async { ... })`, and `async_std::fs::File` for `smol::fs::File`. Closes #153
1 parent 5283d14 commit 584142b

4 files changed

Lines changed: 111 additions & 94 deletions

File tree

CHANGES.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
(`st_size`, `st_{a,m,c}time`) in `ArchiveIterator` entries [#138]
2020
* Upgrade `derive_more` from 0.99 to 2.1 and refresh `Cargo.lock` to the
2121
latest versions compatible with MSRV 1.82.0 [#154]
22+
* Replace the discontinued `async-std` dev-dependency with `smol` in the
23+
`futures_support` example and integration tests (RUSTSEC-2025-0052) [#153]
2224

2325
[#133]: https://github.com/OSSystems/compress-tools-rs/pull/133
2426
[#138]: https://github.com/OSSystems/compress-tools-rs/issues/138
@@ -27,6 +29,7 @@
2729
[#145]: https://github.com/OSSystems/compress-tools-rs/pull/145
2830
[#146]: https://github.com/OSSystems/compress-tools-rs/pull/146
2931
[#148]: https://github.com/OSSystems/compress-tools-rs/pull/148
32+
[#153]: https://github.com/OSSystems/compress-tools-rs/issues/153
3033
[#154]: https://github.com/OSSystems/compress-tools-rs/pull/154
3134

3235
## [0.15.1] - 2024-07-16

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ win_xmllite = []
6969
[dev-dependencies]
7070
tempfile = "3.1"
7171
argh = "0.1"
72-
async-std = { version = "1.6.3", features = ["attributes"] }
72+
smol = "2.0"
7373
tokio = { version = "1.0.0", features = ["fs", "net"] }
7474
encoding_rs = "0.8.32"
7575

examples/uncompress_service_futures.rs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,26 @@
22
//
33
// SPDX-License-Identifier: MIT OR Apache-2.0
44

5-
use async_std::net::TcpListener;
65
use compress_tools::futures_support::uncompress_data;
6+
use smol::net::TcpListener;
77

88
/// Example usage:
99
/// ```
1010
/// $ ncat localhost 1234 < tests/fixtures/file.txt.gz
1111
/// some_file_content
1212
/// ```
1313
14-
#[async_std::main]
15-
async fn main() -> Result<(), Box<dyn std::error::Error>> {
16-
let listener = TcpListener::bind("127.0.0.1:1234").await?;
17-
loop {
18-
let (socket, _) = listener.accept().await?;
19-
async_std::task::spawn(async move {
20-
println!("{:?}", uncompress_data(&socket, &socket).await);
21-
});
22-
}
14+
fn main() -> Result<(), Box<dyn std::error::Error>> {
15+
smol::block_on(async {
16+
let listener = TcpListener::bind("127.0.0.1:1234").await?;
17+
loop {
18+
let (socket, _) = listener.accept().await?;
19+
smol::spawn(async move {
20+
let mut reader = socket.clone();
21+
let mut writer = socket;
22+
println!("{:?}", uncompress_data(&mut reader, &mut writer).await);
23+
})
24+
.detach();
25+
}
26+
})
2327
}

tests/integration_test.rs

Lines changed: 93 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,25 @@ fn get_compressed_file_content() {
2424
assert_eq!(written, 18, "Uncompressed bytes count did not match");
2525
}
2626

27-
#[async_std::test]
27+
#[test]
2828
#[cfg(feature = "futures_support")]
29-
async fn get_compressed_file_content_futures() {
30-
let mut source = async_std::fs::File::open("tests/fixtures/file.txt.gz")
31-
.await
32-
.unwrap();
33-
let mut target = Vec::default();
29+
fn get_compressed_file_content_futures() {
30+
smol::block_on(async {
31+
let mut source = smol::fs::File::open("tests/fixtures/file.txt.gz")
32+
.await
33+
.unwrap();
34+
let mut target = Vec::default();
3435

35-
let written = futures_support::uncompress_data(&mut source, &mut target)
36-
.await
37-
.expect("Failed to uncompress the file");
38-
assert_eq!(
39-
String::from_utf8_lossy(&target),
40-
"some_file_content\n",
41-
"Uncompressed file did not match",
42-
);
43-
assert_eq!(written, 18, "Uncompressed bytes count did not match");
36+
let written = futures_support::uncompress_data(&mut source, &mut target)
37+
.await
38+
.expect("Failed to uncompress the file");
39+
assert_eq!(
40+
String::from_utf8_lossy(&target),
41+
"some_file_content\n",
42+
"Uncompressed file did not match",
43+
);
44+
assert_eq!(written, 18, "Uncompressed bytes count did not match");
45+
});
4446
}
4547

4648
#[tokio::test]
@@ -92,24 +94,26 @@ fn get_a_file_from_7z() {
9294
assert_eq!(written, 14, "Uncompressed bytes count did not match");
9395
}
9496

95-
#[async_std::test]
97+
#[test]
9698
#[cfg(feature = "futures_support")]
97-
async fn get_a_file_from_tar_futures() {
98-
let mut source = async_std::fs::File::open("tests/fixtures/tree.tar")
99-
.await
100-
.unwrap();
101-
let mut target = Vec::default();
102-
103-
let written =
104-
futures_support::uncompress_archive_file(&mut source, &mut target, "tree/branch2/leaf")
99+
fn get_a_file_from_tar_futures() {
100+
smol::block_on(async {
101+
let mut source = smol::fs::File::open("tests/fixtures/tree.tar")
105102
.await
106-
.expect("Failed to get the file");
107-
assert_eq!(
108-
String::from_utf8_lossy(&target),
109-
"Goodbye World\n",
110-
"Uncompressed file did not match",
111-
);
112-
assert_eq!(written, 14, "Uncompressed bytes count did not match");
103+
.unwrap();
104+
let mut target = Vec::default();
105+
106+
let written =
107+
futures_support::uncompress_archive_file(&mut source, &mut target, "tree/branch2/leaf")
108+
.await
109+
.expect("Failed to get the file");
110+
assert_eq!(
111+
String::from_utf8_lossy(&target),
112+
"Goodbye World\n",
113+
"Uncompressed file did not match",
114+
);
115+
assert_eq!(written, 14, "Uncompressed bytes count did not match");
116+
});
113117
}
114118

115119
#[tokio::test]
@@ -149,24 +153,26 @@ fn successfully_list_archive_files() {
149153
);
150154
}
151155

152-
#[async_std::test]
156+
#[test]
153157
#[cfg(feature = "futures_support")]
154-
async fn successfully_list_archive_files_futures() {
155-
let source = async_std::fs::File::open("tests/fixtures/tree.tar")
156-
.await
157-
.unwrap();
158+
fn successfully_list_archive_files_futures() {
159+
smol::block_on(async {
160+
let source = smol::fs::File::open("tests/fixtures/tree.tar")
161+
.await
162+
.unwrap();
158163

159-
assert_eq!(
160-
futures_support::list_archive_files(source).await.unwrap(),
161-
vec![
162-
"tree/".to_string(),
163-
"tree/branch1/".to_string(),
164-
"tree/branch1/leaf".to_string(),
165-
"tree/branch2/".to_string(),
166-
"tree/branch2/leaf".to_string(),
167-
],
168-
"file list inside the archive did not match"
169-
);
164+
assert_eq!(
165+
futures_support::list_archive_files(source).await.unwrap(),
166+
vec![
167+
"tree/".to_string(),
168+
"tree/branch1/".to_string(),
169+
"tree/branch1/leaf".to_string(),
170+
"tree/branch2/".to_string(),
171+
"tree/branch2/leaf".to_string(),
172+
],
173+
"file list inside the archive did not match"
174+
);
175+
});
170176
}
171177

172178
#[tokio::test]
@@ -429,31 +435,33 @@ fn uncompress_same_file_not_preserve_owner() {
429435
.expect("Failed to uncompress the file");
430436
}
431437

432-
#[async_std::test]
438+
#[test]
433439
#[cfg(feature = "futures_support")]
434-
async fn uncompress_same_file_not_preserve_owner_futures() {
435-
futures_support::uncompress_archive(
436-
&mut async_std::fs::File::open("tests/fixtures/tree.tar")
437-
.await
438-
.unwrap(),
439-
tempfile::TempDir::new()
440-
.expect("Failed to create the tmp directory")
441-
.path(),
442-
Ownership::Ignore,
443-
)
444-
.await
445-
.expect("Failed to uncompress the file");
446-
futures_support::uncompress_archive(
447-
&mut async_std::fs::File::open("tests/fixtures/tree.tar")
448-
.await
449-
.unwrap(),
450-
tempfile::TempDir::new()
451-
.expect("Failed to create the tmp directory")
452-
.path(),
453-
Ownership::Ignore,
454-
)
455-
.await
456-
.expect("Failed to uncompress the file");
440+
fn uncompress_same_file_not_preserve_owner_futures() {
441+
smol::block_on(async {
442+
futures_support::uncompress_archive(
443+
&mut smol::fs::File::open("tests/fixtures/tree.tar")
444+
.await
445+
.unwrap(),
446+
tempfile::TempDir::new()
447+
.expect("Failed to create the tmp directory")
448+
.path(),
449+
Ownership::Ignore,
450+
)
451+
.await
452+
.expect("Failed to uncompress the file");
453+
futures_support::uncompress_archive(
454+
&mut smol::fs::File::open("tests/fixtures/tree.tar")
455+
.await
456+
.unwrap(),
457+
tempfile::TempDir::new()
458+
.expect("Failed to create the tmp directory")
459+
.path(),
460+
Ownership::Ignore,
461+
)
462+
.await
463+
.expect("Failed to uncompress the file");
464+
});
457465
}
458466

459467
#[tokio::test]
@@ -494,19 +502,21 @@ fn uncompress_truncated_archive() {
494502
));
495503
}
496504

497-
#[async_std::test]
505+
#[test]
498506
#[cfg(feature = "futures_support")]
499-
async fn uncompress_truncated_archive_futures() {
500-
assert!(matches!(
501-
futures_support::uncompress_data(
502-
async_std::fs::File::open("tests/fixtures/truncated.log.gz")
503-
.await
504-
.unwrap(),
505-
Vec::new()
506-
)
507-
.await,
508-
Err(Error::Unknown)
509-
));
507+
fn uncompress_truncated_archive_futures() {
508+
smol::block_on(async {
509+
assert!(matches!(
510+
futures_support::uncompress_data(
511+
smol::fs::File::open("tests/fixtures/truncated.log.gz")
512+
.await
513+
.unwrap(),
514+
Vec::new()
515+
)
516+
.await,
517+
Err(Error::Unknown)
518+
));
519+
});
510520
}
511521

512522
#[tokio::test]

0 commit comments

Comments
 (0)