nushell/crates/nu-utils/standard_library/tests.nu
Máté FARKAS 10a42de64f
standard library: add log commands (#8448)
# Description

```nushell
log critical "this is a critical message"
log error "this is an error message"
log warning "this is a warning message"
log info "this is an info message"
log debug "this is a debug message"
```


![image](https://user-images.githubusercontent.com/282320/225071852-1ddf0e87-d12b-452d-9598-5122df7123ab.png)

# Tests + Formatting

Tests are written. To run automatically, #8443 needs to be merged before
or after this PR.

---------

Co-authored-by: Mate Farkas <Mate.Farkas@oneidentity.com>
2023-03-18 08:19:54 -05:00

22 lines
684 B
Plaintext

use std.nu *
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
log info $"Run tests in ($module_name) module"
let tests = (
nu -c $'use ($test_file) *; $nu.scope.commands | select name module_name | to nuon'
| from nuon
| where module_name == $module_name
| where ($it.name | str starts-with "test_")
| get name
)
for test_case in $tests {
log debug $"Run test ($module_name) ($test_case)"
nu -c $'use ($test_file) ($test_case); ($test_case)'
}
}
}