Skip to content

Commit 247c705

Browse files
elinorbgrvberger
authored andcommitted
travis: cross-test full-rust and native-lib
1 parent 9f92f61 commit 247c705

9 files changed

Lines changed: 45 additions & 21 deletions

File tree

.travis.yml

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,14 @@ rust:
2222
- 1.21.0
2323
- stable
2424
- beta
25-
- nightly
2625

2726
env:
28-
- FEATURES="native_lib"
2927
- FEATURES=""
28+
- FEATURES="client_native"
29+
- FEATURES="server_native"
30+
- FEATURES="client_native server_native"
3031

3132
matrix:
32-
allow_failures:
33-
- rust: nightly
3433
include:
3534
- rust: stable
3635
env: BUILD_FMT=1
@@ -98,9 +97,13 @@ script:
9897
rustfmt --check tests/scanner_assets/*.rs
9998
elif [ -n "$TARPAULIN" ]; then
10099
cargo tarpaulin --all --features "" --ignore-tests --out Xml
101-
bash <(curl -s https://codecov.io/bash) -cF rust_impl
102-
cargo tarpaulin --all --features "native_lib" --ignore-tests --out Xml
103-
bash <(curl -s https://codecov.io/bash) -cF native_lib
100+
bash <(curl -s https://codecov.io/bash) -cF full_rust
101+
cargo tarpaulin --all --features "client_native" --ignore-tests --out Xml
102+
bash <(curl -s https://codecov.io/bash) -cF client_native
103+
cargo tarpaulin --all --features "server_native" --ignore-tests --out Xml
104+
bash <(curl -s https://codecov.io/bash) -cF server_native
105+
cargo tarpaulin --all --features "client_native server_native" --ignore-tests --out Xml
106+
bash <(curl -s https://codecov.io/bash) -cF both_native
104107
elif [ -n "$CLIPPY" ]; then
105108
# - renamed_and_removed and deprecared_cfg_attr are necessary because rust 1.21.0 cannot parse
106109
# stuff like #[allow(clippy::all)] or #[rustfmt::skip]
@@ -109,16 +112,15 @@ script:
109112
-A renamed_and_removed_lints \
110113
-A clippy::deprecated_cfg_attr \
111114
-A clippy::for_loop_over_option
112-
cargo clippy --all --features "native_lib" -- -D warnings \
115+
cargo clippy --all --features "client_native server_native" -- -D warnings \
113116
-A renamed_and_removed_lints \
114117
-A clippy::deprecated_cfg_attr \
115118
-A clippy::for_loop_over_option
116-
117119
elif [ -n "$BUILD_DOC" ]; then
118120
cargo doc --all --no-deps --all-features
119121
elif [ -n "$TARGET" ]; then
120122
cross build --all --target "$TARGET"
121-
cross build --all --target "$TARGET" --features "native_lib"
123+
cross build --all --target "$TARGET" --features "client_native server_native"
122124
else
123125
cargo test --all --features "$FEATURES"
124126
fi

Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ wayland-scanner = { path = "./wayland-scanner" }
1010
wayland-client = { path = "./wayland-client", default-features = false, features = ["eventloop"] }
1111
wayland-server = { path = "./wayland-server", default-features = false }
1212
wayland-protocols = { path = "./wayland-protocols", features = ["client", "server"] }
13-
wayland-sys = { path = "./wayland-sys", optional = true }
13+
wayland-sys = { path = "./wayland-sys" }
1414
lazycell = "=1.0.0"
1515

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

2525
[features]
26-
native_lib = [ "wayland-client/dlopen", "wayland-server/dlopen", "wayland-sys" ]
26+
client_native = [ "wayland-client/dlopen" ]
27+
server_native = [ "wayland-server/dlopen" ]
2728

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

tests/globals.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ fn wrong_version_create_global() {
153153
}
154154

155155
#[test]
156-
#[cfg_attr(feature = "native_lib", ignore)]
156+
#[cfg_attr(feature = "server_native", ignore)]
157157
fn wrong_global() {
158158
use wayc::protocol::wl_output::WlOutput;
159159

tests/protocol_errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ fn client_receive_error() {
128128
assert_eq!(error.object_id, 3);
129129
assert_eq!(error.object_interface, "wl_output");
130130
// native lib can't give us the message
131-
#[cfg(not(feature = "native_lib"))]
131+
#[cfg(not(feature = "client_native"))]
132132
{
133133
assert_eq!(error.message, "I don't like you!");
134134
}

tests/send_sync.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ fn send_sync_client() {
99
ensure_both::<wayc::Proxy<::wayc::protocol::wl_callback::WlCallback>>();
1010
}
1111

12-
#[cfg(not(feature = "native_lib"))]
12+
#[cfg(not(feature = "server_native"))]
1313
#[test]
1414
fn send_sync_server() {
1515
ensure_both::<ways::Resource<::ways::protocol::wl_callback::WlCallback>>();

tests/server_created_object.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ fn server_created_race() {
389389

390390
// this test currently crashes when using native_lib, this is a bug from the C lib
391391
// see https://gitlab.freedesktop.org/wayland/wayland/issues/74
392-
#[cfg(not(feature = "native_lib"))]
392+
#[cfg(not(feature = "client_native"))]
393393
#[test]
394394
fn creation_destruction_race() {
395395
let mut server = TestServer::new();
@@ -470,7 +470,7 @@ fn creation_destruction_race() {
470470
.as_ref()
471471
.client()
472472
.unwrap()
473-
.create_resource::<ServerDO>(server_dd.borrow()[0].as_ref().version())
473+
.create_resource::<ServerDO>(server_dd.borrow()[1].as_ref().version())
474474
.unwrap()
475475
.implement_dummy();
476476
server_dd.borrow()[1].data_offer(&offer2);

tests/server_resources.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ fn resource_user_data() {
8484
assert!(cloned.as_ref().user_data::<usize>() == Some(&1000));
8585
}
8686

87-
#[cfg(not(feature = "native_lib"))]
87+
#[cfg(not(feature = "server_native"))]
8888
#[test]
8989
fn resource_user_data_wrong_thread() {
9090
let mut server = TestServer::new();
@@ -124,7 +124,7 @@ fn resource_user_data_wrong_thread() {
124124
.unwrap();
125125
}
126126

127-
#[cfg(not(feature = "native_lib"))]
127+
#[cfg(not(feature = "server_native"))]
128128
#[test]
129129
fn resource_implement_wrong_thread() {
130130
let server = TestServer::new();

wayland-client/src/proxy.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,17 @@ impl<I: Interface> Proxy<I> {
6363
///
6464
/// If your request needs to create an object, use `send_constructor`.
6565
pub fn send(&self, msg: I::Request) {
66-
if !self.is_alive() {
67-
return;
66+
#[cfg(feature = "native_lib")]
67+
{
68+
if !self.is_external() && !self.is_alive() {
69+
return;
70+
}
71+
}
72+
#[cfg(not(feature = "native_lib"))]
73+
{
74+
if !self.is_alive() {
75+
return;
76+
}
6877
}
6978
if msg.since() > self.version() {
7079
let opcode = msg.opcode() as usize;

wayland-server/src/resource.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,18 @@ impl<I: Interface> Resource<I> {
4747
/// The event will be send to the client associated to this
4848
/// object.
4949
pub fn send(&self, msg: I::Event) {
50+
#[cfg(feature = "native_lib")]
51+
{
52+
if !self.is_external() && !self.is_alive() {
53+
return;
54+
}
55+
}
56+
#[cfg(not(feature = "native_lib"))]
57+
{
58+
if !self.is_alive() {
59+
return;
60+
}
61+
}
5062
if msg.since() > self.version() {
5163
let opcode = msg.opcode() as usize;
5264
panic!(

0 commit comments

Comments
 (0)