mitsuhiko / mitsuhiko/procspawn

Procspawn failing in tests

Open
#36 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
166
Forks
24
PR merge metrics
No merged PRs in 30d

Description

Hello,
In order to fix this issue https://github.com/servo/ipc-channel/issues/263, I wanted to create a test with two processes. procspawn would be really helpful there, thus I wanted to use it.

For some reason, when I try to start a process sending a rx channel, this fails.
This is a minimal failing example:

procspawn::enable_test_support!();
#[test]
fn test_basic() {
    let (tx, rx) = ipc::channel().unwrap();
    let handle = procspawn::spawn((rx), |(rx)| {
        println!("Hello world!");
        let receved = rx.recv().expect("Something went wrong.");
        receved
    });
    tx.send(3).unwrap();
    let value = handle.join().unwrap();
    assert_eq!(value, 3);
}

The error:

thread 'test_basic' panicked at 'called `Result::unwrap()` on an `Err` value: SpawnError { kind: IpcChannelClosed(Custom { kind: ConnectionReset, error: "remote closed" }) }', tests/fd_passing.rs:18:17

Version:

rustc --version
rustc 1.43.1 (8d69840ab 2020-05-04)

procspawn = {version = "~0.9" , features= ["test-support"]}

If instead of passing channels I use a number for example, everything works as expected.
Any idea on what would be the issue? Thanks!

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the minimal example and the failure at tests/fd_passing.rs:18:17, then inspect procspawn::enable_test_support! and the procspawn::spawn path for receiving an IPC channel. Compare this with the working case that passes a number. Done means the two-process test can pass the channel, send 3, join successfully, and return 3.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.