Skip to main content

nu_test_support/deprecated/
mod.rs

1//! Deprecated testing utilities.
2//!
3//! The utilities in this module are considered deprecated and new tests should no longer use them.
4//! However they are not yet marked as `#[deprecated]` to avoid a massive amount of warnings during
5//! compilation.
6
7use std::process::ExitStatus;
8
9pub mod commands;
10pub mod locale_override;
11pub mod macros;
12
13#[derive(Debug)]
14pub struct Outcome {
15    pub out: String,
16    pub err: String,
17    pub status: ExitStatus,
18}
19
20impl Outcome {
21    pub fn new(out: String, err: String, status: ExitStatus) -> Outcome {
22        Outcome { out, err, status }
23    }
24}
25
26pub fn nu_repl_code(source_lines: &[&str]) -> String {
27    let mut out = String::from("nu --testbin=nu_repl ...[ ");
28
29    for line in source_lines.iter() {
30        out.push('`');
31        out.push_str(line);
32        out.push('`');
33        out.push(' ');
34    }
35
36    out.push(']');
37
38    out
39}
40
41pub fn shell_os_paths() -> Vec<std::path::PathBuf> {
42    let mut original_paths = vec![];
43
44    if let Some(paths) = std::env::var_os(nu_utils::consts::NATIVE_PATH_ENV_VAR) {
45        original_paths = std::env::split_paths(&paths).collect::<Vec<_>>();
46    }
47
48    original_paths
49}