Sha256: ee7b0cb0fc15e416ecdbb3a7ac7061e53e851b0860928d490fc9570c1faeb7d4

Contents?: true

Size: 1.03 KB

Versions: 5

Compression:

Stored size: 1.03 KB

Contents

#![cfg(feature = "process")]
#![warn(rust_2018_idioms)]
// This tests test the behavior of `process::Command::spawn` when it is used
// outside runtime, and when `process::Child::wait ` is used in a different
// runtime from which `process::Command::spawn` is used.
#![cfg(all(unix, not(target_os = "freebsd"), not(miri)))]

use std::process::Stdio;
use tokio::{process::Command, runtime::Runtime};

#[test]
fn process_spawned_and_wait_in_different_runtime() {
    let mut child = Runtime::new().unwrap().block_on(async {
        Command::new("true")
            .stdin(Stdio::piped())
            .stdout(Stdio::null())
            .spawn()
            .unwrap()
    });
    Runtime::new().unwrap().block_on(async {
        let _ = child.wait().await.unwrap();
    });
}

#[test]
#[should_panic(
    expected = "there is no reactor running, must be called from the context of a Tokio 1.x runtime"
)]
fn process_spawned_outside_runtime() {
    let _ = Command::new("true")
        .stdin(Stdio::piped())
        .stdout(Stdio::null())
        .spawn();
}

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
wasmtime-30.0.2 ./ext/cargo-vendor/tokio-1.43.0/tests/process_change_of_runtime.rs
wasmtime-29.0.0 ./ext/cargo-vendor/tokio-1.43.0/tests/process_change_of_runtime.rs
wasmtime-28.0.0 ./ext/cargo-vendor/tokio-1.43.0/tests/process_change_of_runtime.rs
wasmtime-27.0.0 ./ext/cargo-vendor/tokio-1.41.1/tests/process_change_of_runtime.rs
wasmtime-26.0.0 ./ext/cargo-vendor/tokio-1.41.0/tests/process_change_of_runtime.rs