From a7807735b15ad377f281091a85afb3791d9df608 Mon Sep 17 00:00:00 2001 From: Andy Gayton Date: Tue, 14 May 2024 21:48:27 -0400 Subject: [PATCH] Add a passing test for interactivity on slow pipelines (#12865) # Description This PR adds a single test to assert interactivity on slow pipelines Currently the timeout is set to 6 seconds, as the test can sometimes take ~3secs to run on my local m1 mac air, which I don't think is an indication of a slow pipeline, but rather slow test start up time... --- tests/plugins/stream.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/plugins/stream.rs b/tests/plugins/stream.rs index ee62703017..8530e5bc32 100644 --- a/tests/plugins/stream.rs +++ b/tests/plugins/stream.rs @@ -1,3 +1,5 @@ +use rstest::rstest; + use nu_test_support::nu_with_plugins; use pretty_assertions::assert_eq; @@ -190,3 +192,18 @@ fn generate_sequence() { assert_eq!(actual.out, "[0,2,4,6,8,10]"); } + +#[rstest] +#[timeout(std::time::Duration::from_secs(6))] +fn echo_interactivity_on_slow_pipelines() { + // This test works by putting 0 on the upstream immediately, followed by 1 after 10 seconds. + // If values aren't streamed to the plugin as they become available, `example echo` won't emit + // anything until both 0 and 1 are available. The desired behavior is that `example echo` gets + // the 0 immediately, which is consumed by `first`, allowing the pipeline to terminate early. + let actual = nu_with_plugins!( + cwd: "tests/fixtures/formats", + plugin: ("nu_plugin_example"), + r#"[1] | each { |n| sleep 10sec; $n } | prepend 0 | example echo | first"# + ); + assert_eq!(actual.out, "0"); +}