mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-27 00:00:12 +02:00
process: Fix drop_kills test when running on macOS with a single thread
This commit is contained in:
+17
-2
@@ -85,6 +85,18 @@ fn feed_a_lot() {
|
||||
assert_eq!(status.code(), Some(0));
|
||||
}
|
||||
|
||||
// FIXME: delete this test once we have a resolution for #51
|
||||
// This test's setup is flaky, and setting up a consistent test is nearly
|
||||
// impossible: right now we invoke `cat` and immediately kill it, expecting
|
||||
// that it didn't write anything, but if there's something wrong with the
|
||||
// command itself (e.g. redirection issues, it doesn't actually print anything
|
||||
// out, etc.) this test can falsely pass. Attempting a solution which writes
|
||||
// some data, *then* kill the child, write more data, and assert that only the
|
||||
// first write is echoed back seems like a good approach, however, due to the
|
||||
// ordering of context switches or how the kernel buffers data we can get
|
||||
// inconsistent results. We can keep this test around for now, but as soon as
|
||||
// we have a solution for #51, we may have a better avenue for testing this
|
||||
// functionality.
|
||||
#[test]
|
||||
fn drop_kills() {
|
||||
let mut child = cat().spawn_async().unwrap();
|
||||
@@ -96,9 +108,12 @@ fn drop_kills() {
|
||||
let writer = write_all(stdin, b"1234").then(|_| Ok(()));
|
||||
let reader = read_to_end(stdout, Vec::new());
|
||||
|
||||
let future = writer.join(reader).map(|(_, (_, out))| out);
|
||||
let (_, output) = support::CurrentThreadRuntime::new()
|
||||
.expect("failed to get rt")
|
||||
.spawn(writer)
|
||||
.block_on(support::with_timeout(reader))
|
||||
.expect("failed to get output");
|
||||
|
||||
let output = support::run_with_timeout(future).unwrap();
|
||||
assert_eq!(output.len(), 0);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user