mirror of
https://github.com/nushell/nushell.git
synced 2025-04-24 21:28:20 +02:00
Test support fixes (#4517)
* Fix failing pipeline() The `skip(1)` was there likely to remove the welcome message. * Fix typo * Fix nu! test macro to enter cwd correctly Nushell's current working directory is determined primarily by the PWD environment variable.
This commit is contained in:
parent
d4cd3f9578
commit
c7c427723b
@ -26,8 +26,8 @@ impl Outcome {
|
|||||||
|
|
||||||
pub fn pipeline(commands: &str) -> String {
|
pub fn pipeline(commands: &str) -> String {
|
||||||
commands
|
commands
|
||||||
|
.trim()
|
||||||
.lines()
|
.lines()
|
||||||
.skip(1)
|
|
||||||
.map(|line| line.trim())
|
.map(|line| line.trim())
|
||||||
.collect::<Vec<&str>>()
|
.collect::<Vec<&str>>()
|
||||||
.join(" ")
|
.join(" ")
|
||||||
|
@ -23,10 +23,8 @@ macro_rules! nu {
|
|||||||
|
|
||||||
// let commands = &*format!(
|
// let commands = &*format!(
|
||||||
// "
|
// "
|
||||||
// cd \"{}\"
|
|
||||||
// {}
|
// {}
|
||||||
// exit",
|
// exit",
|
||||||
// $crate::fs::in_directory($cwd),
|
|
||||||
// $crate::fs::DisplayPath::display_path(&$path)
|
// $crate::fs::DisplayPath::display_path(&$path)
|
||||||
// );
|
// );
|
||||||
|
|
||||||
@ -51,13 +49,16 @@ macro_rules! nu {
|
|||||||
Err(_) => panic!("Couldn't join paths for PATH var."),
|
Err(_) => panic!("Couldn't join paths for PATH var."),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let target_cwd = $crate::fs::in_directory(&$cwd);
|
||||||
|
|
||||||
let mut process = match Command::new($crate::fs::executable_path())
|
let mut process = match Command::new($crate::fs::executable_path())
|
||||||
|
.env("PWD", &target_cwd) // setting PWD is enough to set cwd
|
||||||
.env(NATIVE_PATH_ENV_VAR, paths_joined)
|
.env(NATIVE_PATH_ENV_VAR, paths_joined)
|
||||||
// .arg("--skip-plugins")
|
// .arg("--skip-plugins")
|
||||||
// .arg("--no-history")
|
// .arg("--no-history")
|
||||||
// .arg("--config-file")
|
// .arg("--config-file")
|
||||||
// .arg($crate::fs::DisplayPath::display_path(&$crate::fs::fixtures().join("playground/config/default.toml")))
|
// .arg($crate::fs::DisplayPath::display_path(&$crate::fs::fixtures().join("playground/config/default.toml")))
|
||||||
.arg(format!("-c 'cd {}; {}'", $crate::fs::in_directory($cwd), $crate::fs::DisplayPath::display_path(&path)))
|
.arg(format!("-c '{}'", $crate::fs::DisplayPath::display_path(&path)))
|
||||||
.stdout(Stdio::piped())
|
.stdout(Stdio::piped())
|
||||||
// .stdin(Stdio::piped())
|
// .stdin(Stdio::piped())
|
||||||
.stderr(Stdio::piped())
|
.stderr(Stdio::piped())
|
||||||
@ -109,10 +110,8 @@ macro_rules! nu_with_plugins {
|
|||||||
|
|
||||||
let commands = &*format!(
|
let commands = &*format!(
|
||||||
"
|
"
|
||||||
cd \"{}\"
|
|
||||||
{}
|
{}
|
||||||
exit",
|
exit",
|
||||||
$crate::fs::in_directory($cwd),
|
|
||||||
$crate::fs::DisplayPath::display_path(&$path)
|
$crate::fs::DisplayPath::display_path(&$path)
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -133,7 +132,10 @@ macro_rules! nu_with_plugins {
|
|||||||
Err(_) => panic!("Couldn't join paths for PATH var."),
|
Err(_) => panic!("Couldn't join paths for PATH var."),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let target_cwd = $crate::fs::in_directory(&$cwd);
|
||||||
|
|
||||||
let mut process = match Command::new($crate::fs::executable_path())
|
let mut process = match Command::new($crate::fs::executable_path())
|
||||||
|
.env("PWD", &target_cwd) // setting PWD is enough to set cwd
|
||||||
.env(NATIVE_PATH_ENV_VAR, paths_joined)
|
.env(NATIVE_PATH_ENV_VAR, paths_joined)
|
||||||
.stdout(Stdio::piped())
|
.stdout(Stdio::piped())
|
||||||
.stdin(Stdio::piped())
|
.stdin(Stdio::piped())
|
||||||
|
@ -9,7 +9,7 @@ use nu_protocol::{
|
|||||||
};
|
};
|
||||||
use std::{io::Write, path::PathBuf};
|
use std::{io::Write, path::PathBuf};
|
||||||
|
|
||||||
// This fill collect environment variables from std::env and adds them to a stack.
|
// This will collect environment variables from std::env and adds them to a stack.
|
||||||
//
|
//
|
||||||
// In order to ensure the values have spans, it first creates a dummy file, writes the collected
|
// In order to ensure the values have spans, it first creates a dummy file, writes the collected
|
||||||
// env vars into it (in a "NAME"="value" format, quite similar to the output of the Unix 'env'
|
// env vars into it (in a "NAME"="value" format, quite similar to the output of the Unix 'env'
|
||||||
|
Loading…
Reference in New Issue
Block a user