1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
use FromValue;
/// Output of the `complete` command as a struct.
///
/// Working with external processes in tests often require inspecting all of `stdin`, `stdout` and
/// the exit code separately.
/// This is easy to achieve using `complete`:
/// ```no_run
/// # #[macro_use] extern crate nu_test_support;
/// use nu_protocol::Record;
/// use nu_test_support::prelude::*;
///
/// #[test]
/// #[deps(NU)]
/// fn run_non_existent_script() -> Result {
/// # unimplemented!()
/// # }
/// #
/// # fn main() -> Result {
/// let result: Record = test().run("nu non-existent-script.nu | complete")?;
/// let stdout = result["stdout"].as_str()?;
/// let stderr = result["stdrr"].as_str()?;
/// let exit_code = result["exit_code"].as_int()?;
///
/// assert_ne!(exit_code, 0);
/// assert_contains("nu::shell::io::file_not_found", stderr);
///
/// Ok(())
/// }
/// ```
///
/// This type exists to avoid repetition and to make it more convenient to work with `complete`:
/// ```no_run
/// # #[macro_use] extern crate nu_test_support;
/// use nu_test_support::prelude::*;
///
/// #[test]
/// #[deps(NU)]
/// fn run_non_existent_script() -> Result {
/// # unimplemented!()
/// # }
/// #
/// # fn main() -> Result {
/// let result: CompleteResult = test().run("nu non-existent-script.nu | complete")?;
///
/// assert_ne!(result.exit_code, 0);
/// assert_contains("nu::shell::io::file_not_found", result.stderr);
///
/// Ok(())
/// }
/// ```