mirror of
https://github.com/nushell/nushell.git
synced 2025-01-27 00:28:41 +01:00
7d2e8875e0
# Description Fixes #14401 where expressions passed to `timeit` will execute twice. This PR removes the expression support for `timeit`, as this behavior is almost exclusive to `timeit` and can hinder migration to the IR evaluator in the future. Additionally, `timeit` used to be able to take a `block` as an argument. Blocks should probably only be allowed for parser keywords, so this PR changes `timeit` to instead only take closures as an argument. This also fixes an issue where environment updates inside the `timeit` block would affect the parent scope and all commands later in the pipeline. ```nu > timeit { $env.FOO = 'bar' }; print $env.FOO bar ``` # User-Facing Changes `timeit` now only takes a closure as the first argument. # After Submitting Update examples in the book/docs if necessary.
15 lines
417 B
Rust
15 lines
417 B
Rust
use nu_test_support::nu;
|
|
|
|
#[test]
|
|
fn timeit_show_stdout() {
|
|
let actual = nu!("let t = timeit { nu --testbin cococo abcdefg }");
|
|
assert_eq!(actual.out, "abcdefg");
|
|
}
|
|
|
|
#[test]
|
|
fn timeit_show_stderr() {
|
|
let actual = nu!(" with-env {FOO: bar, FOO2: baz} { let t = timeit { nu --testbin echo_env_mixed out-err FOO FOO2 } }");
|
|
assert!(actual.out.contains("bar"));
|
|
assert!(actual.err.contains("baz"));
|
|
}
|