nushell/crates/nu-command/tests/commands
Björn Richter cb18dd5200
Add decimals to int when using into string --decimals (#6085)
* Add decimals to int when using `into string --decimals`

* Add tests for `into string` when converting int with `--decimals`

* Apply formatting

* Merge `into_str` test files

* Comment out unused code and add TODOs

* Use decimal separator depending on system locale

* Add test helper to run closure in different locale

* Add tests for int-to-string conversion using different locales

* Add utils function to get system locale

* Add panic message when locking mutex fails

* Catch and resume panic later to prevent Mutex poisoning when test fails

* Move test to `nu-test-support` to keep `nu-utils` free of `nu-*` dependencies

See https://github.com/nushell/nushell/pull/6085#issuecomment-1193131694

* Rename test support fn `with_fake_locale` to `with_locale_override`

* Move `get_system_locale()` to `locale` module

* Allow overriding locale with special env variable (when not in release)

* Use special env var to override locale during testing

* Allow callback to return a value in `with_locale_override()`

* Allow multiple options in `nu!` macro

* Allow to set locale as `nu!` macro option

* Use new `locale` option of `nu!` macro instead of `with_locale_override`

Using the `locale` options does not lock the `LOCALE_OVERRIDE_MUTEX`
mutex in `nu-test-support::locale_override` but instead calls the `nu`
command directly with the `NU_LOCALE_OVERRIDE` environment variable.
This allows for parallel test excecution.

* Fix: Add option identifier for `cwd` in usage of `nu!` macro

* Rely on `Display` trait for formatting `nu!` macro command

- Removed the `DisplayPath` trait
- Implement `Display` for `AbsolutePath`, `RelativePath` and
  `AbsoluteFile`

* Default to locale `en_US.UTF-8` for tests when using `nu!` macro

* Add doc comment to `nu!` macro

* Format code using `cargo fmt --all`

* Pass function directly instead of wrapping the call in a closure

https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure

* Pass function to `or_else()` instead of calling it inside `or()`

https://rust-lang.github.io/rust-clippy/master/index.html#or_fun_call

* Fix: Add option identifier for `cwd` in usage of `nu!` macro
2022-08-12 21:13:50 -05:00
..
date fix date format (#5619) 2022-05-23 09:59:34 -07:00
hash_ Deprecate hash base64, extend decode and add encode commands (#5863) 2022-06-26 00:35:23 +03:00
math expand durations to include month, year, decade (#6123) 2022-07-26 08:05:37 -05:00
move_ Add decimals to int when using into string --decimals (#6085) 2022-08-12 21:13:50 -05:00
network Clippy fix for Rust 1.63 (#6299) 2022-08-11 11:54:54 -05:00
path add -n for path expand, so it doesn't follow symlink (#6255) 2022-08-10 08:43:56 -05:00
query Revert query command to query db (#6200) 2022-07-31 15:36:14 -04:00
random Another batch of command tests (#4496) 2022-02-16 07:38:02 -05:00
skip Fix 'skip' support for binary streams (#5943) 2022-07-04 19:53:54 +12:00
str_ Add decimals to int when using into string --decimals (#6085) 2022-08-12 21:13:50 -05:00
take Move 'keep' to 'take' (#5123) 2022-04-08 08:49:28 +12:00
alias.rs Allow expanding aliases before keywords, improve hiding (#4858) 2022-03-18 11:35:50 +13:00
all.rs Suggest alternative when command not found (#6256) 2022-08-07 14:40:41 -04:00
any.rs Suggest alternative when command not found (#6256) 2022-08-07 14:40:41 -04:00
append.rs Strip trailing whitespace in files (#4575) 2022-02-21 08:38:15 -05:00
cal.rs Remove old nushell/merge engine-q 2022-02-07 14:54:06 -05:00
cd.rs Add decimals to int when using into string --decimals (#6085) 2022-08-12 21:13:50 -05:00
compact.rs Remove old nushell/merge engine-q 2022-02-07 14:54:06 -05:00
cp.rs Add decimals to int when using into string --decimals (#6085) 2022-08-12 21:13:50 -05:00
def.rs throw parser error when multiple short flags are defined without whitespace (#6000) 2022-07-10 20:32:52 +12:00
default.rs Remove old nushell/merge engine-q 2022-02-07 14:54:06 -05:00
do_.rs Better error handling using do (#5890) 2022-06-29 20:01:34 -05:00
drop.rs fixed a couple more tests (#4870) 2022-03-18 12:35:28 -05:00
each.rs Simplify group/window into their own commands (#4760) 2022-03-06 20:01:29 -05:00
echo.rs Require block params (#4505) 2022-02-17 06:40:24 -05:00
empty.rs Remove 'empty' block support reminders, for now. (#5214) 2022-04-30 22:32:30 -05:00
enter.rs Remove old nushell/merge engine-q 2022-02-07 14:54:06 -05:00
error_make.rs add unspanned flag to error make, add tests (#6017) 2022-07-12 06:03:50 -05:00
every.rs Another batch of command tests (#4496) 2022-02-16 07:38:02 -05:00
export_def.rs allow -h flags for export subcommands (#6189) 2022-08-02 10:26:16 -05:00
find.rs Use 'table' on scripts and -c commands (#4377) 2022-02-09 05:58:54 -05:00
first.rs Remove old nushell/merge engine-q 2022-02-07 14:54:06 -05:00
flatten.rs adjust flatten default behavior (#5606) 2022-05-21 08:32:51 -05:00
format.rs Make format support nested column and use variable (#5570) 2022-05-18 06:08:43 -05:00
g.rs Make g - switch to the last used shell (#6249) 2022-08-06 10:11:03 -05:00
get.rs Change miette theme based on ANSI config (#5588) 2022-05-19 13:59:14 -05:00
group_by.rs more test fixes (#4499) 2022-02-16 12:24:45 -06:00
headers.rs refactor: change column names from 'Column*' to 'column*' (#4556) 2022-02-19 19:26:47 -05:00
help.rs Clean up tests and unused documentation code (#5273) 2022-04-21 06:13:58 -05:00
histogram.rs add quantile column (#5583) 2022-05-18 20:47:26 -05:00
insert.rs Add insert/update to lists (#4873) 2022-03-19 10:12:54 +13:00
into_filesize.rs Remove old nushell/merge engine-q 2022-02-07 14:54:06 -05:00
into_int.rs Binary into int (#5941) 2022-07-04 06:31:50 +12:00
last.rs Use 'table' on scripts and -c commands (#4377) 2022-02-09 05:58:54 -05:00
length.rs Remove old nushell/merge engine-q 2022-02-07 14:54:06 -05:00
let_.rs Errors when let in, let env and similar commands are passed. (#5866) 2022-06-25 00:55:25 +03:00
lines.rs refactor: change column names from 'Column*' to 'column*' (#4556) 2022-02-19 19:26:47 -05:00
ls.rs Add decimals to int when using into string --decimals (#6085) 2022-08-12 21:13:50 -05:00
merge.rs use reverse iter on value search (#5553) 2022-05-16 06:29:40 -05:00
mkdir.rs Remove old nushell/merge engine-q 2022-02-07 14:54:06 -05:00
mod.rs Refactor shell listing related code (#6262) 2022-08-08 06:31:24 -05:00
n.rs Refactor shell switching related code (#6258) 2022-08-07 13:30:40 -05:00
nu_check.rs Use relative paths as file-relative when parsing a file (#6150) 2022-07-27 18:36:56 +03:00
open.rs make cd, cp, ls, mv, open and rm automatically strip ansi codes (#6220) 2022-08-04 06:59:20 -05:00
p.rs Refactor shell switching related code (#6258) 2022-08-07 13:30:40 -05:00
parse.rs replace the regex crate with the fancy-regex crate (#6227) 2022-08-04 14:51:02 -05:00
prepend.rs Use 'table' on scripts and -c commands (#4377) 2022-02-09 05:58:54 -05:00
print.rs add -e flag to print, to print the value to stderr (#5935) 2022-07-02 09:54:49 -05:00
range.rs Use 'table' on scripts and -c commands (#4377) 2022-02-09 05:58:54 -05:00
reduce.rs feat: apply the --numbered option to acc in reduce command. (#5575) 2022-05-18 09:49:34 -05:00
reject.rs make sure no duplicate records exists during eval and merge (#5633) 2022-05-25 19:10:31 -05:00
rename.rs add rename (#5534) 2022-05-13 06:47:11 -05:00
reverse.rs Remove old nushell/merge engine-q 2022-02-07 14:54:06 -05:00
rm.rs make cd, cp, ls, mv, open and rm automatically strip ansi codes (#6220) 2022-08-04 06:59:20 -05:00
roll.rs refactor: change column names from 'Column*' to 'column*' (#4556) 2022-02-19 19:26:47 -05:00
rotate.rs refactor: change column names from 'Column*' to 'column*' (#4556) 2022-02-19 19:26:47 -05:00
run_external.rs Fix unused import warning on Linux+Mac (#6281) 2022-08-10 00:28:03 -04:00
save.rs refactor all write_alls to ensure flushing (#5567) 2022-05-17 13:28:18 -05:00
select.rs fix select tests (#5577) 2022-05-18 06:20:26 -05:00
semicolon.rs Remove old nushell/merge engine-q 2022-02-07 14:54:06 -05:00
shells.rs Refactor shell listing related code (#6262) 2022-08-08 06:31:24 -05:00
sort_by.rs fixed a couple more tests (#4870) 2022-03-18 12:35:28 -05:00
source.rs Add decimals to int when using into string --decimals (#6085) 2022-08-12 21:13:50 -05:00
split_by.rs Remove old nushell/merge engine-q 2022-02-07 14:54:06 -05:00
split_column.rs refactor: change column names from 'Column*' to 'column*' (#4556) 2022-02-19 19:26:47 -05:00
split_row.rs Remove old nushell/merge engine-q 2022-02-07 14:54:06 -05:00
touch.rs Return error early if seconds part of timestamp is invalid (#6193) 2022-07-31 07:32:16 -05:00
transpose.rs Prevents duplicate fields in transpose -r (#5840) 2022-06-22 19:19:06 -05:00
uniq.rs Fix Value::Record compare logic, and pass uniq tests. (#5541) 2022-05-14 06:04:09 -05:00
update.rs Add insert/update to lists (#4873) 2022-03-19 10:12:54 +13:00
upsert.rs Add insert and update back (#4864) 2022-03-18 06:55:02 +13:00
use_.rs Add decimals to int when using into string --decimals (#6085) 2022-08-12 21:13:50 -05:00
where_.rs mute false import warning for nu-command test where_ (#5350) 2022-04-27 22:45:39 -07:00
which.rs Don't assume external ls (#4925) 2022-03-24 16:42:41 +13:00
with_env.rs fixed some more tests (#4607) 2022-02-22 11:32:29 -05:00
wrap.rs Use 'table' on scripts and -c commands (#4377) 2022-02-09 05:58:54 -05:00
zip.rs fix zip test (#5536) 2022-05-15 16:44:32 -05:00