2023-03-18 13:19:54 +00:00
|
|
|
use std.nu *
|
|
|
|
|
2023-03-16 18:23:29 +00:00
|
|
|
def main [] {
|
|
|
|
for test_file in (ls ($env.FILE_PWD | path join "test_*.nu") -f | get name) {
|
|
|
|
let $module_name = ($test_file | path parse).stem
|
|
|
|
|
2023-03-18 13:19:54 +00:00
|
|
|
log info $"Run tests in ($module_name) module"
|
2023-03-16 18:23:29 +00:00
|
|
|
let tests = (
|
2023-03-18 13:19:54 +00:00
|
|
|
nu -c $'use ($test_file) *; $nu.scope.commands | select name module_name | to nuon'
|
2023-03-16 18:23:29 +00:00
|
|
|
| from nuon
|
|
|
|
| where module_name == $module_name
|
|
|
|
| where ($it.name | str starts-with "test_")
|
|
|
|
| get name
|
|
|
|
)
|
|
|
|
|
|
|
|
for test_case in $tests {
|
2023-03-18 13:19:54 +00:00
|
|
|
log debug $"Run test ($module_name) ($test_case)"
|
2023-03-16 18:23:29 +00:00
|
|
|
nu -c $'use ($test_file) ($test_case); ($test_case)'
|
add `dirs` command to std lib (#8368)
# Description
Prototype replacement for `enter`, `n`, `p`, `exit` built-ins
implemented as scripts in standard library.
MVP-level capabilities (rough hack), for feedback please. Not intended
to merge and ship as is.
_(Description of your pull request goes here. **Provide examples and/or
screenshots** if your changes affect the user experience.)_
# User-Facing Changes
New command in standard library
```nushell
〉use ~/src/rust/nushell/crates/nu-utils/standard_library/dirs.nu
---------------------------------------------- /home/bobhy ----------------------------------------------
〉help dirs
module dirs.nu -- maintain list of remembered directories + navigate them
todo:
* expand relative to absolute paths (or relative to some prefix?)
* what if user does `cd` by hand?
Module: dirs
Exported commands:
add (dirs add), drop, next (dirs next), prev (dirs prev), show (dirs show)
This module exports environment.
---------------------------------------------- /home/bobhy ----------------------------------------------
〉dirs add ~/src/rust/nushell /etc ~/.cargo
-------------------------------------- /home/bobhy/src/rust/nushell --------------------------------------
〉dirs next 2
------------------------------------------- /home/bobhy/.cargo -------------------------------------------
〉dirs show
╭───┬─────────┬────────────────────╮
│ # │ current │ path │
├───┼─────────┼────────────────────┤
│ 0 │ │ /home/bobhy │
│ 1 │ │ ~/src/rust/nushell │
│ 2 │ │ /etc │
│ 3 │ ==> │ ~/.cargo │
╰───┴─────────┴────────────────────╯
------------------------------------------- /home/bobhy/.cargo -------------------------------------------
〉dirs drop
---------------------------------------------- /home/bobhy ----------------------------------------------
〉dirs show
╭───┬─────────┬────────────────────╮
│ # │ current │ path │
├───┼─────────┼────────────────────┤
│ 0 │ ==> │ /home/bobhy │
│ 1 │ │ ~/src/rust/nushell │
│ 2 │ │ /etc │
╰───┴─────────┴────────────────────╯
---------------------------------------------- /home/bobhy ----------------------------------------------
〉
```
# Tests + Formatting
Haven't even looked at stdlib `tests.nu` yet.
Other todos:
* address module todos.
* integrate into std lib, rather than as standalone module. Somehow
arrange for `use .../standard_library/std.nu` to load this module
without having to put all the source in `std.nu`?
* Maybe command should be `std dirs ...`?
* what else do `enter` and `exit` do that this should do? Then deprecate
those commands.
Don't forget to add tests that cover your changes.
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
# After Submitting
If your PR had any user-facing changes, update [the
documentation](https://github.com/nushell/nushell.github.io) after the
PR is merged, if necessary. This will help us keep the docs up to date.
2023-03-11 22:31:09 +00:00
|
|
|
}
|
|
|
|
}
|
2023-02-27 23:52:47 +00:00
|
|
|
}
|