From 1ed645c6c2899614b6d1823046d991ad4eb257e9 Mon Sep 17 00:00:00 2001 From: Antoine Stevan <44101798+amtoine@users.noreply.github.com> Date: Thu, 30 Mar 2023 19:25:42 +0200 Subject: [PATCH] feature: add the standard library tests to the PR template and the toolkit (#8629) Related to #8525. # Description With #8525, the tests for the standard library have been enabled in the CI. The only places where these tests are missing are - the PR template - the toolkit This PR adds - `cargo run -- crates/nu-utils/standard_library/tests.nu` to the PR template - the same command as `toolkit test stdlib` - the `test stdlib` command to `toolkit check pr` # User-Facing Changes ``` $nothing ``` # Tests + Formatting the new output of `toolkit check pr`, with the same color code: > - :green_circle: `toolkit fmt` > - :green_circle: `toolkit clippy` > - :green_circle: `toolkit test` > - :green_circle: `toolkit test stdlib` # After Submitting ``` $nothing ``` --- .github/pull_request_template.md | 1 + toolkit.nu | 27 +++++++++++++++++++++------ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 9ba7213405..b9f2987528 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -18,6 +18,7 @@ Make sure you've run and fixed any issues with these commands: - `cargo fmt --all -- --check` to check standard code formatting (`cargo fmt --all` applies these changes) - `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect` to check that you're using the standard code style - `cargo test --workspace` to check that all tests pass +- `cargo run -- crates/nu-utils/standard_library/tests.nu` to run the tests for the standard library > **Note** > from `nushell` you can also use the `toolkit` as follows diff --git a/toolkit.nu b/toolkit.nu index 7122d6a4c1..1139c2ff60 100644 --- a/toolkit.nu +++ b/toolkit.nu @@ -35,6 +35,11 @@ export def test [ } } +# run the tests for the standard library +export def "test stdlib" [] { + cargo run -- crates/nu-utils/standard_library/tests.nu +} + # print the pipe input inside backticks, dimmed and italic, as a pretty command def pretty-print-command [] { $"`(ansi default_dimmed)(ansi default_italic)($in)(ansi reset)`" @@ -53,15 +58,18 @@ def report [ --fail-fmt: bool --fail-clippy: bool --fail-test: bool + --fail-test-stdlib: bool --no-fail: bool ] { - [fmt clippy test] | wrap stage + [fmt clippy test "test stdlib"] + | wrap stage | merge ( - if $no_fail { [true true true] } - else if $fail_fmt { [false $nothing $nothing] } - else if $fail_clippy { [true false $nothing] } - else if $fail_test { [true true false] } - else { [$nothing $nothing $nothing] } + if $no_fail { [true true true true] } + else if $fail_fmt { [false $nothing $nothing $nothing] } + else if $fail_clippy { [true false $nothing $nothing] } + else if $fail_test { [true true false $nothing] } + else if $fail_test_stdlib { [true true true false] } + else { [$nothing $nothing $nothing $nothing] } | wrap success ) | upsert emoji {|it| @@ -194,5 +202,12 @@ export def "check pr" [ return (report --fail-test) } + print $"running ('toolkit test stdlib' | pretty-print-command)" + try { + test stdlib + } catch { + return (report --fail-test-stdlib) + } + report --no-fail }