1
Fork 0
mirror of https://github.com/RGBCube/nu_scripts synced 2025-07-31 14:17:45 +00:00

add path replace-extension to stdlib-candidate (#1002)

Adds `path replace-extension` as requested in https://github.com/nushell/nushell/issues/14144

Also sets up testing for candidates. In order to do this, I made
some changes:

1. ported `nu-std/testing.nu` under `stdlib-candidate` folder, and
making some changes.
2. run candidate tests in `toolkit check pr` command, to make sure the
test is run in CI.
3. including `stdlib-candidate` to `NU_LIB_DIRS` when running lint, so
the tests can pass linter.

Changes in stdlib-candidate/testing.nu:

1. remove `std/log` usage
2. including `stdlib-candidate` path in `run-test` command
This commit is contained in:
Wind 2025-01-04 12:57:13 +08:00 committed by GitHub
parent 66e4845b60
commit 2dadab779b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 445 additions and 3 deletions

View file

@ -32,6 +32,13 @@ export def "check pr" [
{ test }
] | par-each { |task| $files | do $task } # TODO: buffer output
}
test-stdlib-candidate
}
export def test-stdlib-candidate [] {
use stdlib-candidate/testing.nu
testing run-tests --allow-no-tests --path stdlib-candidate
}
# View subcommands.
@ -70,13 +77,15 @@ def "with files" [
export def "lint ide-check" []: path -> int {
let file = $in
let stub = $env.STUB_IDE_CHECK? | default false | into bool
const current_path = (path self)
let candidate_path = $current_path | path dirname | path join "stdlib-candidate"
let diagnostics = if $stub {
do { nu --no-config-file --commands $"use '($file)'" }
do { nu -I $candidate_path --no-config-file --commands $"use '($file)'" }
| complete
| [[severity message]; [$in.exit_code $in.stderr]]
| where severity != 0
} else {
nu --ide-check 10 $file
nu -I $candidate_path --ide-check 10 $file
| $"[($in)]"
| from nuon
| where type == diagnostic