mirror of
https://github.com/nushell/nushell.git
synced 2025-08-18 18:58:24 +02:00
Remove the NU_DISABLE_IR
option (#14293)
# Description Removes the `NU_DISABLE_IR` option and some code related to evaluating blocks with the AST evaluator. Does not entirely remove the AST evaluator yet. We still have some dependencies on expression evaluation in a few minor places which will take a little bit of effort to fix. Also changes `debug profile` to always include instructions, because the output is a little confusing otherwise, and removes the different options for instructions/exprs. # User-Facing Changes - `NU_DISABLE_IR` no longer has any effect, and is removed. There is no way to use the AST evaluator. - `debug profile` no longer has `--exprs`, `--instructions` options. - `debug profile` lists `pc` and `instruction` columns by default now. # Tests + Formatting Eval tests fixed to only use IR. # After Submitting - [ ] release notes - [ ] finish removing AST evaluator, come up with solutions for the expression evaluation.
This commit is contained in:
@@ -31,71 +31,43 @@ enum ExpectedOut<'a> {
|
||||
use self::ExpectedOut::*;
|
||||
|
||||
fn test_eval(source: &str, expected_out: ExpectedOut) {
|
||||
Playground::setup("test_eval_ast", |ast_dirs, _playground| {
|
||||
Playground::setup("test_eval_ir", |ir_dirs, _playground| {
|
||||
let actual_ast = nu!(
|
||||
cwd: ast_dirs.test(),
|
||||
use_ir: false,
|
||||
source,
|
||||
);
|
||||
let actual_ir = nu!(
|
||||
cwd: ir_dirs.test(),
|
||||
use_ir: true,
|
||||
source,
|
||||
);
|
||||
Playground::setup("test_eval", |dirs, _playground| {
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(),
|
||||
source,
|
||||
);
|
||||
|
||||
match expected_out {
|
||||
Eq(eq) => {
|
||||
assert_eq!(actual_ast.out, eq);
|
||||
assert_eq!(actual_ir.out, eq);
|
||||
assert!(actual_ast.status.success());
|
||||
assert!(actual_ir.status.success());
|
||||
}
|
||||
Matches(regex) => {
|
||||
let compiled_regex = Regex::new(regex).expect("regex failed to compile");
|
||||
assert!(
|
||||
compiled_regex.is_match(&actual_ast.out),
|
||||
"AST eval out does not match: {}\n{}",
|
||||
regex,
|
||||
actual_ast.out
|
||||
);
|
||||
assert!(
|
||||
compiled_regex.is_match(&actual_ir.out),
|
||||
"IR eval out does not match: {}\n{}",
|
||||
regex,
|
||||
actual_ir.out,
|
||||
);
|
||||
assert!(actual_ast.status.success());
|
||||
assert!(actual_ir.status.success());
|
||||
}
|
||||
Error(regex) => {
|
||||
let compiled_regex = Regex::new(regex).expect("regex failed to compile");
|
||||
assert!(
|
||||
compiled_regex.is_match(&actual_ast.err),
|
||||
"AST eval err does not match: {}",
|
||||
regex
|
||||
);
|
||||
assert!(
|
||||
compiled_regex.is_match(&actual_ir.err),
|
||||
"IR eval err does not match: {}",
|
||||
regex
|
||||
);
|
||||
assert!(!actual_ast.status.success());
|
||||
assert!(!actual_ir.status.success());
|
||||
}
|
||||
FileEq(path, contents) => {
|
||||
let ast_contents = std::fs::read_to_string(ast_dirs.test().join(path))
|
||||
.expect("failed to read AST file");
|
||||
let ir_contents = std::fs::read_to_string(ir_dirs.test().join(path))
|
||||
.expect("failed to read IR file");
|
||||
assert_eq!(ast_contents.trim(), contents);
|
||||
assert_eq!(ir_contents.trim(), contents);
|
||||
assert!(actual_ast.status.success());
|
||||
assert!(actual_ir.status.success());
|
||||
}
|
||||
match expected_out {
|
||||
Eq(eq) => {
|
||||
assert_eq!(actual.out, eq);
|
||||
assert!(actual.status.success());
|
||||
}
|
||||
assert_eq!(actual_ast.out, actual_ir.out);
|
||||
})
|
||||
Matches(regex) => {
|
||||
let compiled_regex = Regex::new(regex).expect("regex failed to compile");
|
||||
assert!(
|
||||
compiled_regex.is_match(&actual.out),
|
||||
"eval out does not match: {}\n{}",
|
||||
regex,
|
||||
actual.out,
|
||||
);
|
||||
assert!(actual.status.success());
|
||||
}
|
||||
Error(regex) => {
|
||||
let compiled_regex = Regex::new(regex).expect("regex failed to compile");
|
||||
assert!(
|
||||
compiled_regex.is_match(&actual.err),
|
||||
"eval err does not match: {}",
|
||||
regex
|
||||
);
|
||||
assert!(!actual.status.success());
|
||||
}
|
||||
FileEq(path, contents) => {
|
||||
let read_contents =
|
||||
std::fs::read_to_string(dirs.test().join(path)).expect("failed to read file");
|
||||
assert_eq!(read_contents.trim(), contents);
|
||||
assert!(actual.status.success());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user