remove nu/do --use-ir, add NU_USE_IR environment variable, tested at start and by do
This commit is contained in:
parent
1ce2096b72
commit
1cd8279ad5
|
@ -49,12 +49,6 @@ impl Command for Do {
|
|||
"catch errors as the closure runs, and return them",
|
||||
Some('c'),
|
||||
)
|
||||
// FIXME: for testing only
|
||||
.switch(
|
||||
"use-ir",
|
||||
"use the compiled IR instead of evaluating the expression",
|
||||
None,
|
||||
)
|
||||
.switch(
|
||||
"env",
|
||||
"keep the environment defined inside the command",
|
||||
|
@ -84,7 +78,6 @@ impl Command for Do {
|
|||
let ignore_program_errors = ignore_all_errors
|
||||
|| call.has_flag(engine_state, caller_stack, "ignore-program-errors")?;
|
||||
let capture_errors = call.has_flag(engine_state, caller_stack, "capture-errors")?;
|
||||
let use_ir = call.has_flag(engine_state, caller_stack, "use-ir")?;
|
||||
let has_env = call.has_flag(engine_state, caller_stack, "env")?;
|
||||
|
||||
let mut callee_stack = caller_stack.captures_to_stack_preserve_out_dest(block.captures);
|
||||
|
@ -94,9 +87,7 @@ impl Command for Do {
|
|||
let eval_block_with_early_return = get_eval_block_with_early_return(engine_state);
|
||||
|
||||
// Applies to all block evaluation once set true
|
||||
if use_ir {
|
||||
caller_stack.use_ir = true;
|
||||
}
|
||||
callee_stack.use_ir = caller_stack.has_env_var(engine_state, "NU_USE_IR");
|
||||
|
||||
let result = eval_block_with_early_return(engine_state, &mut callee_stack, block, input);
|
||||
|
||||
|
|
|
@ -297,12 +297,13 @@ pub fn nu_run_test(opts: NuOpts, commands: impl AsRef<str>, with_std: bool) -> O
|
|||
.stdout(Stdio::piped())
|
||||
.stderr(Stdio::piped());
|
||||
|
||||
// Use IR evaluator (or set $env.NU_TEST_USE_IR to always do this)
|
||||
if opts
|
||||
.use_ir
|
||||
.unwrap_or_else(|| std::env::var("NU_TEST_USE_IR").is_ok())
|
||||
{
|
||||
command.arg("--use-ir");
|
||||
// Explicitly set NU_USE_IR
|
||||
if let Some(use_ir) = opts.use_ir {
|
||||
if use_ir {
|
||||
command.env("NU_USE_IR", "1");
|
||||
} else {
|
||||
command.env_remove("NU_USE_IR");
|
||||
}
|
||||
}
|
||||
|
||||
// Uncomment to debug the command being run:
|
||||
|
@ -383,32 +384,24 @@ where
|
|||
executable_path = crate::fs::installed_nu_path();
|
||||
}
|
||||
|
||||
let mut nu = setup_command(&executable_path, &target_cwd);
|
||||
|
||||
nu.envs(envs);
|
||||
|
||||
nu.arg("--commands");
|
||||
nu.arg(command);
|
||||
// Use plain errors to help make error text matching more consistent
|
||||
nu.args(["--error-style", "plain"]);
|
||||
nu.arg("--config");
|
||||
nu.arg(temp_config_file);
|
||||
nu.arg("--env-config");
|
||||
nu.arg(temp_env_config_file);
|
||||
nu.arg("--plugin-config");
|
||||
nu.arg(temp_plugin_file);
|
||||
nu.arg("--plugins");
|
||||
nu.arg(plugins_arg);
|
||||
|
||||
// Test plugin tests with IR too, if asked to
|
||||
if std::env::var("NU_TEST_USE_IR").is_ok() {
|
||||
nu.arg("--use-ir");
|
||||
}
|
||||
|
||||
nu.stdout(Stdio::piped());
|
||||
nu.stderr(Stdio::piped());
|
||||
|
||||
let process = match nu.spawn() {
|
||||
let process = match setup_command(&executable_path, &target_cwd)
|
||||
.envs(envs)
|
||||
.arg("--commands")
|
||||
.arg(command)
|
||||
// Use plain errors to help make error text matching more consistent
|
||||
.args(["--error-style", "plain"])
|
||||
.arg("--config")
|
||||
.arg(temp_config_file)
|
||||
.arg("--env-config")
|
||||
.arg(temp_env_config_file)
|
||||
.arg("--plugin-config")
|
||||
.arg(temp_plugin_file)
|
||||
.arg("--plugins")
|
||||
.arg(plugins_arg)
|
||||
.stdout(Stdio::piped())
|
||||
.stderr(Stdio::piped())
|
||||
.spawn()
|
||||
{
|
||||
Ok(child) => child,
|
||||
Err(why) => panic!("Can't run test {}", why),
|
||||
};
|
||||
|
|
|
@ -107,7 +107,6 @@ pub(crate) fn parse_commandline_args(
|
|||
let error_style: Option<Value> =
|
||||
call.get_flag(engine_state, &mut stack, "error-style")?;
|
||||
let no_newline = call.get_named_arg("no-newline");
|
||||
let use_ir = call.has_flag(engine_state, &mut stack, "use-ir")?;
|
||||
|
||||
// ide flags
|
||||
let lsp = call.has_flag(engine_state, &mut stack, "lsp")?;
|
||||
|
@ -252,7 +251,6 @@ pub(crate) fn parse_commandline_args(
|
|||
table_mode,
|
||||
error_style,
|
||||
no_newline,
|
||||
use_ir,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -294,7 +292,6 @@ pub(crate) struct NushellCliArgs {
|
|||
pub(crate) ide_complete: Option<Value>,
|
||||
pub(crate) ide_check: Option<Value>,
|
||||
pub(crate) ide_ast: Option<Spanned<String>>,
|
||||
pub(crate) use_ir: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
|
@ -371,7 +368,6 @@ impl Command for Nu {
|
|||
"start with an alternate environment config file",
|
||||
None,
|
||||
)
|
||||
.switch("use-ir", "EXPERIMENTAL: use the IR evaluation engine on launch", None)
|
||||
.switch(
|
||||
"lsp",
|
||||
"start nu's language server protocol",
|
||||
|
|
|
@ -26,7 +26,7 @@ pub(crate) fn run_commands(
|
|||
let mut stack = Stack::new();
|
||||
let start_time = std::time::Instant::now();
|
||||
|
||||
if parsed_nu_cli_args.use_ir {
|
||||
if stack.has_env_var(engine_state, "NU_USE_IR") {
|
||||
stack.use_ir = true;
|
||||
}
|
||||
|
||||
|
@ -148,7 +148,7 @@ pub(crate) fn run_file(
|
|||
trace!("run_file");
|
||||
let mut stack = Stack::new();
|
||||
|
||||
if parsed_nu_cli_args.use_ir {
|
||||
if stack.has_env_var(engine_state, "NU_USE_IR") {
|
||||
stack.use_ir = true;
|
||||
}
|
||||
|
||||
|
@ -262,7 +262,7 @@ pub(crate) fn run_repl(
|
|||
let mut stack = Stack::new();
|
||||
let start_time = std::time::Instant::now();
|
||||
|
||||
if parsed_nu_cli_args.use_ir {
|
||||
if stack.has_env_var(engine_state, "NU_USE_IR") {
|
||||
stack.use_ir = true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user