Skip to content

Commit

Permalink
travis: cross-test full-rust and native-lib
Browse files Browse the repository at this point in the history
  • Loading branch information
elinorbgr authored and vberger committed Feb 17, 2019
1 parent 9f92f61 commit 247c705
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 21 deletions.
22 changes: 12 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,14 @@ rust:
- 1.21.0
- stable
- beta
- nightly

env:
- FEATURES="native_lib"
- FEATURES=""
- FEATURES="client_native"
- FEATURES="server_native"
- FEATURES="client_native server_native"

matrix:
allow_failures:
- rust: nightly
include:
- rust: stable
env: BUILD_FMT=1
Expand Down Expand Up @@ -98,9 +97,13 @@ script:
rustfmt --check tests/scanner_assets/*.rs
elif [ -n "$TARPAULIN" ]; then
cargo tarpaulin --all --features "" --ignore-tests --out Xml
bash <(curl -s https://codecov.io/bash) -cF rust_impl
cargo tarpaulin --all --features "native_lib" --ignore-tests --out Xml
bash <(curl -s https://codecov.io/bash) -cF native_lib
bash <(curl -s https://codecov.io/bash) -cF full_rust
cargo tarpaulin --all --features "client_native" --ignore-tests --out Xml
bash <(curl -s https://codecov.io/bash) -cF client_native
cargo tarpaulin --all --features "server_native" --ignore-tests --out Xml
bash <(curl -s https://codecov.io/bash) -cF server_native
cargo tarpaulin --all --features "client_native server_native" --ignore-tests --out Xml
bash <(curl -s https://codecov.io/bash) -cF both_native
elif [ -n "$CLIPPY" ]; then
# - renamed_and_removed and deprecared_cfg_attr are necessary because rust 1.21.0 cannot parse
# stuff like #[allow(clippy::all)] or #[rustfmt::skip]
Expand All @@ -109,16 +112,15 @@ script:
-A renamed_and_removed_lints \
-A clippy::deprecated_cfg_attr \
-A clippy::for_loop_over_option
cargo clippy --all --features "native_lib" -- -D warnings \
cargo clippy --all --features "client_native server_native" -- -D warnings \
-A renamed_and_removed_lints \
-A clippy::deprecated_cfg_attr \
-A clippy::for_loop_over_option
elif [ -n "$BUILD_DOC" ]; then
cargo doc --all --no-deps --all-features
elif [ -n "$TARGET" ]; then
cross build --all --target "$TARGET"
cross build --all --target "$TARGET" --features "native_lib"
cross build --all --target "$TARGET" --features "client_native server_native"
else
cargo test --all --features "$FEATURES"
fi
Expand Down
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ wayland-scanner = { path = "./wayland-scanner" }
wayland-client = { path = "./wayland-client", default-features = false, features = ["eventloop"] }
wayland-server = { path = "./wayland-server", default-features = false }
wayland-protocols = { path = "./wayland-protocols", features = ["client", "server"] }
wayland-sys = { path = "./wayland-sys", optional = true }
wayland-sys = { path = "./wayland-sys" }
lazycell = "=1.0.0"

[dev-dependencies]
Expand All @@ -23,7 +23,8 @@ calloop = "0.4.2"
members = [ "wayland-sys", "wayland-scanner", "wayland-client", "wayland-server", "wayland-protocols", "wayland-commons" ]

[features]
native_lib = [ "wayland-client/dlopen", "wayland-server/dlopen", "wayland-sys" ]
client_native = [ "wayland-client/dlopen" ]
server_native = [ "wayland-server/dlopen" ]

# Manual list of the tests, required because some need `harness = false`

Expand Down
2 changes: 1 addition & 1 deletion tests/globals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ fn wrong_version_create_global() {
}

#[test]
#[cfg_attr(feature = "native_lib", ignore)]
#[cfg_attr(feature = "server_native", ignore)]
fn wrong_global() {
use wayc::protocol::wl_output::WlOutput;

Expand Down
2 changes: 1 addition & 1 deletion tests/protocol_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ fn client_receive_error() {
assert_eq!(error.object_id, 3);
assert_eq!(error.object_interface, "wl_output");
// native lib can't give us the message
#[cfg(not(feature = "native_lib"))]
#[cfg(not(feature = "client_native"))]
{
assert_eq!(error.message, "I don't like you!");
}
Expand Down
2 changes: 1 addition & 1 deletion tests/send_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fn send_sync_client() {
ensure_both::<wayc::Proxy<::wayc::protocol::wl_callback::WlCallback>>();
}

#[cfg(not(feature = "native_lib"))]
#[cfg(not(feature = "server_native"))]
#[test]
fn send_sync_server() {
ensure_both::<ways::Resource<::ways::protocol::wl_callback::WlCallback>>();
Expand Down
4 changes: 2 additions & 2 deletions tests/server_created_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ fn server_created_race() {

// this test currently crashes when using native_lib, this is a bug from the C lib
// see https://gitlab.freedesktop.org/wayland/wayland/issues/74
#[cfg(not(feature = "native_lib"))]
#[cfg(not(feature = "client_native"))]
#[test]
fn creation_destruction_race() {
let mut server = TestServer::new();
Expand Down Expand Up @@ -470,7 +470,7 @@ fn creation_destruction_race() {
.as_ref()
.client()
.unwrap()
.create_resource::<ServerDO>(server_dd.borrow()[0].as_ref().version())
.create_resource::<ServerDO>(server_dd.borrow()[1].as_ref().version())
.unwrap()
.implement_dummy();
server_dd.borrow()[1].data_offer(&offer2);
Expand Down
4 changes: 2 additions & 2 deletions tests/server_resources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ fn resource_user_data() {
assert!(cloned.as_ref().user_data::<usize>() == Some(&1000));
}

#[cfg(not(feature = "native_lib"))]
#[cfg(not(feature = "server_native"))]
#[test]
fn resource_user_data_wrong_thread() {
let mut server = TestServer::new();
Expand Down Expand Up @@ -124,7 +124,7 @@ fn resource_user_data_wrong_thread() {
.unwrap();
}

#[cfg(not(feature = "native_lib"))]
#[cfg(not(feature = "server_native"))]
#[test]
fn resource_implement_wrong_thread() {
let server = TestServer::new();
Expand Down
13 changes: 11 additions & 2 deletions wayland-client/src/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,17 @@ impl<I: Interface> Proxy<I> {
///
/// If your request needs to create an object, use `send_constructor`.
pub fn send(&self, msg: I::Request) {
if !self.is_alive() {
return;
#[cfg(feature = "native_lib")]
{
if !self.is_external() && !self.is_alive() {
return;
}
}
#[cfg(not(feature = "native_lib"))]
{
if !self.is_alive() {
return;
}
}
if msg.since() > self.version() {
let opcode = msg.opcode() as usize;
Expand Down
12 changes: 12 additions & 0 deletions wayland-server/src/resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,18 @@ impl<I: Interface> Resource<I> {
/// The event will be send to the client associated to this
/// object.
pub fn send(&self, msg: I::Event) {
#[cfg(feature = "native_lib")]
{
if !self.is_external() && !self.is_alive() {
return;
}
}
#[cfg(not(feature = "native_lib"))]
{
if !self.is_alive() {
return;
}
}
if msg.since() > self.version() {
let opcode = msg.opcode() as usize;
panic!(
Expand Down

0 comments on commit 247c705

Please sign in to comment.