tests: only use PipeWriter if rust-version >= 1.87
By using conditional compilation, we now support running the test suite with Rust versions 1.83 to 1.86 again. This allows us to lower the `rust-version` specified in the root Cargo.toml (because it was controlling the toolchain used in CI) to 1.83, resolving #230. This solution keeps tests operational on our MSRV while also lowering it. It would have been unsatisfying to have an MSRV which could not compile the tests. `rustversion` was selected as the dependency to control the conditional compilation since it was already a build dependency needed by `vergen-gitcl`, so no new dependencies were added.
This commit is contained in:
parent
c0497c990d
commit
0fd0dd75e9
4 changed files with 38 additions and 10 deletions
5
Cargo.lock
generated
5
Cargo.lock
generated
|
|
@ -530,9 +530,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "rustversion"
|
||||
version = "1.0.21"
|
||||
version = "1.0.22"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8a0d197bd2c9dc6e53b84da9556a69ba4cdfab8619eb41a8bd1cc2027a0f6b1d"
|
||||
checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d"
|
||||
|
||||
[[package]]
|
||||
name = "sd-notify"
|
||||
|
|
@ -635,6 +635,7 @@ name = "testwl"
|
|||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"rustix",
|
||||
"rustversion",
|
||||
"wayland-protocols",
|
||||
"wayland-server",
|
||||
"wl_drm",
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
[workspace]
|
||||
members = ["macros", "testwl"]
|
||||
members = ["macros", "testwl", "wl_drm"]
|
||||
|
||||
[workspace.dependencies]
|
||||
wayland-client = "0.31.2"
|
||||
|
|
@ -12,7 +12,7 @@ rustix = "0.38.31"
|
|||
all = "deny"
|
||||
|
||||
[workspace.package]
|
||||
rust-version = "1.87.0"
|
||||
rust-version = "1.83.0"
|
||||
|
||||
[package]
|
||||
name = "xwayland-satellite"
|
||||
|
|
|
|||
|
|
@ -11,3 +11,4 @@ wayland-protocols = { workspace = true, features = ["server", "staging", "unstab
|
|||
wayland-server.workspace = true
|
||||
wl_drm = { path = "../wl_drm" }
|
||||
rustix = { workspace = true, features = ["pipe"] }
|
||||
rustversion = "1.0.22"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
use std::collections::{hash_map, HashMap, HashSet};
|
||||
use std::io::Read;
|
||||
use std::io::{PipeWriter, Write};
|
||||
#[rustversion::since(1.87)]
|
||||
use std::io::PipeWriter;
|
||||
use std::io::{Read, Write};
|
||||
use std::os::fd::{AsFd, BorrowedFd, OwnedFd};
|
||||
use std::os::unix::net::UnixStream;
|
||||
use std::sync::{Arc, Mutex, OnceLock};
|
||||
|
|
@ -908,6 +909,33 @@ pub struct PasteData {
|
|||
pub data: Vec<u8>,
|
||||
}
|
||||
|
||||
#[rustversion::since(1.87)]
|
||||
pub struct TransferFd(PipeWriter);
|
||||
#[rustversion::since(1.87)]
|
||||
impl From<OwnedFd> for TransferFd {
|
||||
fn from(value: OwnedFd) -> Self {
|
||||
Self(PipeWriter::from(value))
|
||||
}
|
||||
}
|
||||
|
||||
#[rustversion::before(1.87)]
|
||||
pub struct TransferFd(UnixStream);
|
||||
#[rustversion::before(1.87)]
|
||||
impl From<OwnedFd> for TransferFd {
|
||||
fn from(value: OwnedFd) -> Self {
|
||||
Self(UnixStream::from(value))
|
||||
}
|
||||
}
|
||||
|
||||
impl Write for TransferFd {
|
||||
fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
|
||||
self.0.write(buf)
|
||||
}
|
||||
fn flush(&mut self) -> std::io::Result<()> {
|
||||
self.0.flush()
|
||||
}
|
||||
}
|
||||
|
||||
simple_global_dispatch!(WlShm);
|
||||
simple_global_dispatch!(WlCompositor);
|
||||
simple_global_dispatch!(XdgWmBase);
|
||||
|
|
@ -1134,8 +1162,7 @@ impl Dispatch<ZwpPrimarySelectionOfferV1, Vec<PasteData>> for State {
|
|||
.position(|data| data.mime_type == mime_type)
|
||||
.unwrap_or_else(|| panic!("Invalid mime type: {mime_type}"));
|
||||
|
||||
let mut stream = PipeWriter::from(fd);
|
||||
stream.write_all(&data[pos].data).unwrap();
|
||||
TransferFd::from(fd).write_all(&data[pos].data).unwrap();
|
||||
}
|
||||
Request::Destroy => {}
|
||||
other => todo!("{other:?}"),
|
||||
|
|
@ -1219,8 +1246,7 @@ impl Dispatch<WlDataOffer, Vec<PasteData>> for State {
|
|||
.position(|data| data.mime_type == mime_type)
|
||||
.unwrap_or_else(|| panic!("Invalid mime type: {mime_type}"));
|
||||
|
||||
let mut stream = PipeWriter::from(fd);
|
||||
stream.write_all(&data[pos].data).unwrap();
|
||||
TransferFd::from(fd).write_all(&data[pos].data).unwrap();
|
||||
}
|
||||
wl_data_offer::Request::Destroy => {}
|
||||
other => todo!("unhandled request: {other:?}"),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue