forked from extern/nushell
Playground infraestructure (tests, etc) additions. (#3179)
* Playground infraestructure (tests, etc) additions. A few things to note: * Nu can be started with a custom configuration file (`nu --config-file /path/to/sample_config.toml`). Useful for mocking the configuration on test runs. * When given a custom configuration file Nu will save any changes to the file supplied appropiately. * The `$nu.config-path` variable either shows the default configuration file (or the custom one, if given) * We can now run end to end tests with finer grained control (currently, since this is baseline work, standard out) This will allow to check things like exit status, assert the contents with a format, etc) * Remove (for another PR)
This commit is contained in:
committed by
GitHub
parent
82b6300dcb
commit
d2213d18fa
@ -1,5 +1,5 @@
|
||||
use nu_test_support::fs::Stub::EmptyFile;
|
||||
use nu_test_support::playground::{Dirs, Playground};
|
||||
use nu_test_support::playground::Playground;
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
#[test]
|
||||
@ -269,61 +269,57 @@ fn lists_files_including_starting_with_dot() {
|
||||
|
||||
#[test]
|
||||
fn list_all_columns() {
|
||||
Playground::setup(
|
||||
"ls_test_all_columns",
|
||||
|dirs: Dirs, sandbox: &mut Playground| {
|
||||
sandbox.with_files(vec![
|
||||
EmptyFile("Leonardo.yaml"),
|
||||
EmptyFile("Raphael.json"),
|
||||
EmptyFile("Donatello.xml"),
|
||||
EmptyFile("Michelangelo.txt"),
|
||||
]);
|
||||
// Normal Operation
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(),
|
||||
"ls | get | to md"
|
||||
);
|
||||
let expected = ["name", "type", "size", "modified"].join("");
|
||||
assert_eq!(actual.out, expected, "column names are incorrect for ls");
|
||||
// Long
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(),
|
||||
"ls -l | get | to md"
|
||||
);
|
||||
let expected = {
|
||||
#[cfg(unix)]
|
||||
{
|
||||
[
|
||||
"name",
|
||||
"type",
|
||||
"target",
|
||||
"num_links",
|
||||
"inode",
|
||||
"readonly",
|
||||
"mode",
|
||||
"uid",
|
||||
"group",
|
||||
"size",
|
||||
"created",
|
||||
"accessed",
|
||||
"modified",
|
||||
]
|
||||
.join("")
|
||||
}
|
||||
Playground::setup("ls_test_all_columns", |dirs, sandbox| {
|
||||
sandbox.with_files(vec![
|
||||
EmptyFile("Leonardo.yaml"),
|
||||
EmptyFile("Raphael.json"),
|
||||
EmptyFile("Donatello.xml"),
|
||||
EmptyFile("Michelangelo.txt"),
|
||||
]);
|
||||
// Normal Operation
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(),
|
||||
"ls | get | to md"
|
||||
);
|
||||
let expected = ["name", "type", "size", "modified"].join("");
|
||||
assert_eq!(actual.out, expected, "column names are incorrect for ls");
|
||||
// Long
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(),
|
||||
"ls -l | get | to md"
|
||||
);
|
||||
let expected = {
|
||||
#[cfg(unix)]
|
||||
{
|
||||
[
|
||||
"name",
|
||||
"type",
|
||||
"target",
|
||||
"num_links",
|
||||
"inode",
|
||||
"readonly",
|
||||
"mode",
|
||||
"uid",
|
||||
"group",
|
||||
"size",
|
||||
"created",
|
||||
"accessed",
|
||||
"modified",
|
||||
]
|
||||
.join("")
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
{
|
||||
[
|
||||
"name", "type", "target", "readonly", "size", "created", "accessed",
|
||||
"modified",
|
||||
]
|
||||
.join("")
|
||||
}
|
||||
};
|
||||
assert_eq!(
|
||||
actual.out, expected,
|
||||
"column names are incorrect for ls long"
|
||||
);
|
||||
},
|
||||
);
|
||||
#[cfg(windows)]
|
||||
{
|
||||
[
|
||||
"name", "type", "target", "readonly", "size", "created", "accessed", "modified",
|
||||
]
|
||||
.join("")
|
||||
}
|
||||
};
|
||||
assert_eq!(
|
||||
actual.out, expected,
|
||||
"column names are incorrect for ls long"
|
||||
);
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user