Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Procspawn failing in tests #36

Open
FedericoPonzi opened this issue Jun 18, 2020 · 4 comments
Open

Procspawn failing in tests #36

FedericoPonzi opened this issue Jun 18, 2020 · 4 comments

Comments

@FedericoPonzi
Copy link

Hello,
In order to fix this issue servo/ipc-channel#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!

@mitsuhiko
Copy link
Owner

Very hard to say. Unfortunately the test support is super wonky since there are no good hook points for rust test. Does this happen outside of a testsuite too?

@FedericoPonzi
Copy link
Author

Unfortunately, I've tried this a while ago anyways IIRC though I think I've tried it outside the testsuite and it was working fine.

@simrankedia
Copy link

simrankedia commented Jun 30, 2021

Not related but I am getting the following error while trying to use this in a test

error: attribute must be applied to a `static` variable
 --> libwail/tests/tests/messaging_test.rs:5:1
  |
5 | procspawn::enable_test_support!();
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to previous error

What am I missing here? I am using it in an integration test file inside the tests/ folder in my crate.

@mitsuhiko
Copy link
Owner

@simrankedia this has been fixed in the latest version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants