Skip to content

Commit 3e9aee8

Browse files
committed
Introduce force-inprocess feature
1 parent ebede24 commit 3e9aee8

File tree

6 files changed

+27
-19
lines changed

6 files changed

+27
-19
lines changed

.travis.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,13 @@ os:
77
- linux
88
- osx
99

10+
env:
11+
- FEATURES=""
12+
- FEATURES="--features force-inprocess"
13+
1014
notifications:
1115
webhooks: http://build.servo.org:54856/travis
16+
17+
script:
18+
- cargo build $FEATURES
19+
- cargo test $FEATURES

Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@ authors = ["The Servo Project Developers"]
66
license = "MIT/Apache-2.0"
77
repository = "https://github.com/servo/ipc-channel"
88

9+
[features]
10+
force-inprocess = []
11+
912
[dependencies]
1013
bincode = "0.6"
1114
lazy_static = "0.2"
1215
libc = "0.2.12"
1316
rand = "0.3"
1417
serde = "0.8"
15-
16-
[target.'cfg(any(target_os = "windows", target_os = "android"))'.dependencies]
1718
uuid = {version = "0.3", features = ["v4"]}
1819

1920
[dev-dependencies]

src/lib.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
// option. This file may not be copied, modified, or distributed
88
// except according to those terms.
99

10-
#![cfg_attr(any(target_os="windows", target_os="android"), feature(mpsc_select))]
10+
#![cfg_attr(any(feature = "force-inprocess", target_os = "windows", target_os = "android"),
11+
feature(mpsc_select))]
1112

1213
#[macro_use]
1314
extern crate lazy_static;
@@ -16,7 +17,8 @@ extern crate bincode;
1617
extern crate libc;
1718
extern crate rand;
1819
extern crate serde;
19-
#[cfg(any(target_os = "windows", target_os = "android"))] extern crate uuid;
20+
#[cfg(any(feature = "force-inprocess", target_os = "windows", target_os = "android"))]
21+
extern crate uuid;
2022

2123
pub mod ipc;
2224
pub mod platform;

src/platform/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
// except according to those terms.
99

1010
mod os {
11-
#[cfg(target_os = "linux")]
11+
#[cfg(all(not(feature = "force-inprocess"), target_os = "linux"))]
1212
include!("linux/mod.rs");
1313

14-
#[cfg(target_os = "macos")]
14+
#[cfg(all(not(feature = "force-inprocess"), target_os = "macos"))]
1515
include!("macos/mod.rs");
1616

17-
#[cfg(any(target_os = "windows", target_os = "android"))]
17+
#[cfg(any(feature = "force-inprocess", target_os = "windows", target_os = "android"))]
1818
include!("inprocess/mod.rs");
1919
}
2020

src/platform/test.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use std::sync::Arc;
1414
use std::time::{Duration, Instant};
1515
use std::thread;
1616

17-
#[cfg(not(windows))]
17+
#[cfg(not(any(feature = "force-inprocess", target_os = "windows", target_os = "android")))]
1818
use test::{fork, Wait};
1919

2020
#[test]
@@ -173,6 +173,7 @@ fn big_data_with_sender_transfer() {
173173
thread.join().unwrap();
174174
}
175175

176+
#[cfg(all(not(feature = "force-inprocess"), target_os = "linux"))]
176177
fn with_n_fds(n: usize, size: usize) {
177178
let (sender_fds, receivers): (Vec<_>, Vec<_>) = (0..n).map(|_| platform::channel().unwrap())
178179
.map(|(tx, rx)| (OsIpcChannel::Sender(tx), rx))
@@ -204,7 +205,7 @@ fn with_n_fds(n: usize, size: usize) {
204205
}
205206

206207
// These tests only apply to platforms that need fragmentation.
207-
#[cfg(target_os="linux")]
208+
#[cfg(all(not(feature = "force-inprocess"), target_os = "linux"))]
208209
mod fragment_tests {
209210
use platform;
210211
use super::with_n_fds;
@@ -392,9 +393,9 @@ fn receiver_set() {
392393
}
393394
}
394395

396+
#[cfg(not(any(feature = "force-inprocess", target_os = "windows", target_os = "android")))]
395397
#[test]
396-
//XXXjdm This hangs indefinitely on appveyor and warrants further investigation.
397-
#[cfg(not(windows))]
398+
//XXXjdm This hangs indefinitely with inprocess impl and warrants further investigation.
398399
fn server() {
399400
let (server, name) = OsIpcOneShotServer::new().unwrap();
400401
let data: &[u8] = b"1234567";
@@ -411,8 +412,7 @@ fn server() {
411412
(data, vec![], vec![]));
412413
}
413414

414-
///XXXjdm Windows' libc doesn't include fork.
415-
#[cfg(not(windows))]
415+
#[cfg(not(any(feature = "force-inprocess", target_os = "windows", target_os = "android")))]
416416
#[test]
417417
fn cross_process() {
418418
let (server, name) = OsIpcOneShotServer::new().unwrap();
@@ -432,8 +432,7 @@ fn cross_process() {
432432
(data, vec![], vec![]));
433433
}
434434

435-
///XXXjdm Windows' libc doesn't include fork.
436-
#[cfg(not(windows))]
435+
#[cfg(not(any(feature = "force-inprocess", target_os = "windows", target_os = "android")))]
437436
#[test]
438437
fn cross_process_sender_transfer() {
439438
let (server, name) = OsIpcOneShotServer::new().unwrap();

src/test.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ use std::sync::Arc;
1818
use std::sync::mpsc::{self, Sender};
1919
use std::thread;
2020

21-
///XXXjdm Windows' libc doesn't include fork.
22-
#[cfg(not(windows))]
21+
#[cfg(not(any(feature = "force-inprocess", target_os = "windows", target_os = "android")))]
2322
// I'm not actually sure invoking this is indeed unsafe -- but better safe than sorry...
2423
pub unsafe fn fork<F: FnOnce()>(child_func: F) -> libc::pid_t {
2524
match libc::fork() {
@@ -129,9 +128,8 @@ fn select() {
129128
}
130129
}
131130

131+
#[cfg(not(any(feature = "force-inprocess", target_os = "windows", target_os = "android")))]
132132
#[test]
133-
///XXXjdm Windows' libc doesn't include fork.
134-
#[cfg(not(windows))]
135133
fn cross_process_embedded_senders() {
136134
let person = ("Patrick Walton".to_owned(), 29);
137135
let (server0, server0_name) = IpcOneShotServer::new().unwrap();

0 commit comments

Comments
 (0)