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]]
|
[[package]]
|
||||||
name = "rustversion"
|
name = "rustversion"
|
||||||
version = "1.0.21"
|
version = "1.0.22"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8a0d197bd2c9dc6e53b84da9556a69ba4cdfab8619eb41a8bd1cc2027a0f6b1d"
|
checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "sd-notify"
|
name = "sd-notify"
|
||||||
|
|
@ -635,6 +635,7 @@ name = "testwl"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"rustix",
|
"rustix",
|
||||||
|
"rustversion",
|
||||||
"wayland-protocols",
|
"wayland-protocols",
|
||||||
"wayland-server",
|
"wayland-server",
|
||||||
"wl_drm",
|
"wl_drm",
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
[workspace]
|
[workspace]
|
||||||
members = ["macros", "testwl"]
|
members = ["macros", "testwl", "wl_drm"]
|
||||||
|
|
||||||
[workspace.dependencies]
|
[workspace.dependencies]
|
||||||
wayland-client = "0.31.2"
|
wayland-client = "0.31.2"
|
||||||
|
|
@ -12,7 +12,7 @@ rustix = "0.38.31"
|
||||||
all = "deny"
|
all = "deny"
|
||||||
|
|
||||||
[workspace.package]
|
[workspace.package]
|
||||||
rust-version = "1.87.0"
|
rust-version = "1.83.0"
|
||||||
|
|
||||||
[package]
|
[package]
|
||||||
name = "xwayland-satellite"
|
name = "xwayland-satellite"
|
||||||
|
|
|
||||||
|
|
@ -11,3 +11,4 @@ wayland-protocols = { workspace = true, features = ["server", "staging", "unstab
|
||||||
wayland-server.workspace = true
|
wayland-server.workspace = true
|
||||||
wl_drm = { path = "../wl_drm" }
|
wl_drm = { path = "../wl_drm" }
|
||||||
rustix = { workspace = true, features = ["pipe"] }
|
rustix = { workspace = true, features = ["pipe"] }
|
||||||
|
rustversion = "1.0.22"
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
use std::collections::{hash_map, HashMap, HashSet};
|
use std::collections::{hash_map, HashMap, HashSet};
|
||||||
use std::io::Read;
|
#[rustversion::since(1.87)]
|
||||||
use std::io::{PipeWriter, Write};
|
use std::io::PipeWriter;
|
||||||
|
use std::io::{Read, Write};
|
||||||
use std::os::fd::{AsFd, BorrowedFd, OwnedFd};
|
use std::os::fd::{AsFd, BorrowedFd, OwnedFd};
|
||||||
use std::os::unix::net::UnixStream;
|
use std::os::unix::net::UnixStream;
|
||||||
use std::sync::{Arc, Mutex, OnceLock};
|
use std::sync::{Arc, Mutex, OnceLock};
|
||||||
|
|
@ -908,6 +909,33 @@ pub struct PasteData {
|
||||||
pub data: Vec<u8>,
|
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!(WlShm);
|
||||||
simple_global_dispatch!(WlCompositor);
|
simple_global_dispatch!(WlCompositor);
|
||||||
simple_global_dispatch!(XdgWmBase);
|
simple_global_dispatch!(XdgWmBase);
|
||||||
|
|
@ -1134,8 +1162,7 @@ impl Dispatch<ZwpPrimarySelectionOfferV1, Vec<PasteData>> for State {
|
||||||
.position(|data| data.mime_type == mime_type)
|
.position(|data| data.mime_type == mime_type)
|
||||||
.unwrap_or_else(|| panic!("Invalid mime type: {mime_type}"));
|
.unwrap_or_else(|| panic!("Invalid mime type: {mime_type}"));
|
||||||
|
|
||||||
let mut stream = PipeWriter::from(fd);
|
TransferFd::from(fd).write_all(&data[pos].data).unwrap();
|
||||||
stream.write_all(&data[pos].data).unwrap();
|
|
||||||
}
|
}
|
||||||
Request::Destroy => {}
|
Request::Destroy => {}
|
||||||
other => todo!("{other:?}"),
|
other => todo!("{other:?}"),
|
||||||
|
|
@ -1219,8 +1246,7 @@ impl Dispatch<WlDataOffer, Vec<PasteData>> for State {
|
||||||
.position(|data| data.mime_type == mime_type)
|
.position(|data| data.mime_type == mime_type)
|
||||||
.unwrap_or_else(|| panic!("Invalid mime type: {mime_type}"));
|
.unwrap_or_else(|| panic!("Invalid mime type: {mime_type}"));
|
||||||
|
|
||||||
let mut stream = PipeWriter::from(fd);
|
TransferFd::from(fd).write_all(&data[pos].data).unwrap();
|
||||||
stream.write_all(&data[pos].data).unwrap();
|
|
||||||
}
|
}
|
||||||
wl_data_offer::Request::Destroy => {}
|
wl_data_offer::Request::Destroy => {}
|
||||||
other => todo!("unhandled request: {other:?}"),
|
other => todo!("unhandled request: {other:?}"),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue