-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add integration test Fixes #382 * Skip integration test where not appropriate
- Loading branch information
Showing
2 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright 2025 The Servo Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
use ipc_channel::ipc::IpcSender; | ||
use std::{env, process}; | ||
|
||
/// Test executable which connects to the one-shot server with name | ||
/// passed in as an argument and then sends a test message to the | ||
/// server. | ||
fn main() { | ||
let args: Vec<String> = env::args().collect(); | ||
let token = args.get(1).expect("missing argument"); | ||
|
||
let tx: IpcSender<String> = IpcSender::connect(token.to_string()).expect("connect failed"); | ||
tx.send("test message".to_string()).expect("send failed"); | ||
|
||
process::exit(0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright 2025 The Servo Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
#[cfg(not(any(feature = "force-inprocess", target_os = "android", target_os = "ios")))] | ||
use ipc_channel::ipc::IpcOneShotServer; | ||
#[cfg(not(any(feature = "force-inprocess", target_os = "android", target_os = "ios")))] | ||
use std::{env, process}; | ||
|
||
// These integration tests may be run on their own by issuing: | ||
// cargo test --test '*' | ||
|
||
/// Test spawing a process which then acts as a client to a | ||
/// one-shot server in the parent process. | ||
#[cfg(not(any(feature = "force-inprocess", target_os = "android", target_os = "ios")))] | ||
#[test] | ||
fn spawn_one_shot_server_client() { | ||
let executable_path: String = env!("CARGO_BIN_EXE_spawn_client_test_helper").to_string(); | ||
|
||
let (server, token) = | ||
IpcOneShotServer::<String>::new().expect("Failed to create IPC one-shot server."); | ||
|
||
let mut command = process::Command::new(executable_path); | ||
let child_process = command.arg(token); | ||
|
||
let mut child = child_process | ||
.spawn() | ||
.expect("Failed to start child process"); | ||
|
||
let (_rx, msg) = server.accept().expect("accept failed"); | ||
assert_eq!("test message", msg); | ||
|
||
let result = child.wait().expect("wait for child process failed"); | ||
assert!( | ||
result.success(), | ||
"child process failed with exit status code {}", | ||
result.code().expect("exit status code not available") | ||
); | ||
} |