mirror of
https://github.com/nushell/nushell
synced 2024-11-10 15:14:14 +00:00
toolkit: use --features
instead of --dataframe
and refactor a bit (#9425)
related to - https://github.com/nushell/nushell/pull/9357 # Description with the new `extra` feature introduce in the `toolkit.nu` module in https://github.com/nushell/nushell/pull/9357, the `--dataframe` option does not make sense anymore... this PR changes that and replaces it with `--features: list<string>`. this has the benefit of simplifying the commands because we can just pass `--features ($features | str join ",")` to the `cargo` commands regardless of whether the `$features` list is empty of not 👌 i've also refactored a bit the module: - break the long `error make -u` lines - break the long `cargo clippy` command # User-Facing Changes devs can now choose which feature to test with the `toolkit` commands. # Tests + Formatting - 🟢 `toolkit fmt` - 🟢 `toolkit clippy` - ⚫ `toolkit test` - ⚫ `toolkit test stdlib` # After Submitting ``` $nothing ```
This commit is contained in:
parent
fa957a1a07
commit
6af9fe5e10
1 changed files with 43 additions and 27 deletions
66
toolkit.nu
66
toolkit.nu
|
@ -19,7 +19,9 @@ export def fmt [
|
|||
try {
|
||||
cargo fmt --all -- --check
|
||||
} catch {
|
||||
error make -u { msg: $"\nplease run ('toolkit fmt' | pretty-print-command) to fix formatting!" }
|
||||
error make --unspanned {
|
||||
msg: $"\nplease run ('toolkit fmt' | pretty-print-command) to fix formatting!"
|
||||
}
|
||||
}
|
||||
} else {
|
||||
cargo fmt --all
|
||||
|
@ -31,36 +33,56 @@ export def fmt [
|
|||
# > it is important to make `clippy` happy :relieved:
|
||||
export def clippy [
|
||||
--verbose: bool # print extra information about the command's progress
|
||||
--dataframe: bool # use the dataframe feature
|
||||
--features: list<string> # the list of features to run *Clippy* on
|
||||
--workspace: bool # run the *Clippy* command on the whole workspace (overrides `--features`)
|
||||
] {
|
||||
if $verbose {
|
||||
print $"running ('toolkit clippy' | pretty-print-command)"
|
||||
}
|
||||
|
||||
try {
|
||||
if $dataframe {
|
||||
cargo clippy --workspace --features=dataframe,extra -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect -A clippy::result_large_err
|
||||
} else {
|
||||
cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect -A clippy::result_large_err
|
||||
}
|
||||
if $workspace {(
|
||||
cargo clippy
|
||||
--workspace
|
||||
--
|
||||
-D warnings
|
||||
-D clippy::unwrap_used
|
||||
-A clippy::needless_collect
|
||||
-A clippy::result_large_err
|
||||
)} else {(
|
||||
cargo clippy
|
||||
--features ($features | str join ",")
|
||||
--
|
||||
-D warnings
|
||||
-D clippy::unwrap_used
|
||||
-A clippy::needless_collect
|
||||
-A clippy::result_large_err
|
||||
)}
|
||||
} catch {
|
||||
error make -u { msg: $"\nplease fix the above ('clippy' | pretty-print-command) errors before continuing!" }
|
||||
error make --unspanned {
|
||||
msg: $"\nplease fix the above ('clippy' | pretty-print-command) errors before continuing!"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# check that all the tests pass
|
||||
export def test [
|
||||
--fast: bool # use the "nextext" `cargo` subcommand to speed up the tests (see [`cargo-nextest`](https://nexte.st/) and [`nextest-rs/nextest`](https://github.com/nextest-rs/nextest))
|
||||
--dataframe: bool # use the dataframe feature
|
||||
--features: list<string> # the list of features to run the tests on
|
||||
--workspace: bool # run the *Clippy* command on the whole workspace (overrides `--features`)
|
||||
] {
|
||||
if ($fast and $dataframe) {
|
||||
cargo nextest run --all --features=dataframe,extra
|
||||
} else if ($fast) {
|
||||
if $fast {
|
||||
if $workspace {
|
||||
cargo nextest run --all
|
||||
} else if ($dataframe) {
|
||||
cargo test --workspace --features=dataframe,extra
|
||||
} else {
|
||||
cargo nextest run --features ($features | str join ",")
|
||||
}
|
||||
} else {
|
||||
if $workspace {
|
||||
cargo test --workspace
|
||||
} else {
|
||||
cargo test --features ($features | str join ",")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -208,7 +230,7 @@ def report [
|
|||
# now the whole `toolkit check pr` passes! :tada:
|
||||
export def "check pr" [
|
||||
--fast: bool # use the "nextext" `cargo` subcommand to speed up the tests (see [`cargo-nextest`](https://nexte.st/) and [`nextest-rs/nextest`](https://github.com/nextest-rs/nextest))
|
||||
--dataframe: bool # use the dataframe feature
|
||||
--features: list<string> # the list of features to check the current PR on
|
||||
] {
|
||||
let-env NU_TEST_LOCALE_OVERRIDE = 'en_US.utf8';
|
||||
try {
|
||||
|
@ -218,23 +240,17 @@ export def "check pr" [
|
|||
}
|
||||
|
||||
try {
|
||||
if $dataframe {
|
||||
clippy --dataframe --verbose
|
||||
} else {
|
||||
clippy --verbose
|
||||
}
|
||||
clippy --features $features --verbose
|
||||
} catch {
|
||||
return (report --fail-clippy)
|
||||
}
|
||||
|
||||
print $"running ('toolkit test' | pretty-print-command)"
|
||||
try {
|
||||
if $fast and $dataframe {
|
||||
test --fast --dataframe
|
||||
} else if $fast {
|
||||
test --fast
|
||||
if $fast {
|
||||
test --features $features --fast
|
||||
} else {
|
||||
test
|
||||
test --features $features
|
||||
}
|
||||
} catch {
|
||||
return (report --fail-test)
|
||||
|
|
Loading…
Reference in a new issue