mirror of
https://github.com/nushell/nushell.git
synced 2025-06-19 17:38:14 +02:00
add plugins param to test with active plugins
This commit is contained in:
parent
017daeed18
commit
6a759abcbd
@ -132,6 +132,7 @@ def show-pretty-test [indent: int = 4] {
|
|||||||
# * Modified file is removed
|
# * Modified file is removed
|
||||||
def run-test [
|
def run-test [
|
||||||
test: record
|
test: record
|
||||||
|
plugins: list<string>
|
||||||
] {
|
] {
|
||||||
let test_file_name = (random chars --length 10)
|
let test_file_name = (random chars --length 10)
|
||||||
let test_function_name = (random chars --length 10)
|
let test_function_name = (random chars --length 10)
|
||||||
@ -155,8 +156,9 @@ export def ($test_function_name) [] {
|
|||||||
| str join (char lsep)
|
| str join (char lsep)
|
||||||
| save $rendered_module_path
|
| save $rendered_module_path
|
||||||
|
|
||||||
|
let plugins = $plugins | to json -r
|
||||||
let result = (
|
let result = (
|
||||||
^$nu.current-exe --no-config-file -c $"use ($rendered_module_path) *; ($test_function_name)|to nuon"
|
^$nu.current-exe --no-config-file --plugins $plugins -c $"use ($rendered_module_path) *; ($test_function_name)|to nuon"
|
||||||
| complete
|
| complete
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -175,6 +177,7 @@ export def ($test_function_name) [] {
|
|||||||
def run-tests-for-module [
|
def run-tests-for-module [
|
||||||
module: record<file: path name: string before-each: string after-each: string before-all: string after-all: string test: list test-skip: list>
|
module: record<file: path name: string before-each: string after-each: string before-all: string after-all: string test: list test-skip: list>
|
||||||
threads: int
|
threads: int
|
||||||
|
plugins: list<string>
|
||||||
]: nothing -> table<file: path, name: string, test: string, result: string> {
|
]: nothing -> table<file: path, name: string, test: string, result: string> {
|
||||||
let global_context = if not ($module.before-all|is-empty) {
|
let global_context = if not ($module.before-all|is-empty) {
|
||||||
log info $"Running before-all for module ($module.name)"
|
log info $"Running before-all for module ($module.name)"
|
||||||
@ -183,7 +186,7 @@ def run-tests-for-module [
|
|||||||
before-each: 'let context = {}',
|
before-each: 'let context = {}',
|
||||||
after-each: '',
|
after-each: '',
|
||||||
test: $module.before-all
|
test: $module.before-all
|
||||||
}
|
} $plugins
|
||||||
| if $in.exit_code == 0 {
|
| if $in.exit_code == 0 {
|
||||||
$in.stdout
|
$in.stdout
|
||||||
} else {
|
} else {
|
||||||
@ -233,7 +236,7 @@ def run-tests-for-module [
|
|||||||
log debug $"Global context is ($global_context)"
|
log debug $"Global context is ($global_context)"
|
||||||
|
|
||||||
$test|insert result {|x|
|
$test|insert result {|x|
|
||||||
run-test $test
|
run-test $test $plugins
|
||||||
| if $in.exit_code == 0 {
|
| if $in.exit_code == 0 {
|
||||||
'pass'
|
'pass'
|
||||||
} else {
|
} else {
|
||||||
@ -253,7 +256,7 @@ def run-tests-for-module [
|
|||||||
before-each: $"let context = ($global_context)",
|
before-each: $"let context = ($global_context)",
|
||||||
after-each: '',
|
after-each: '',
|
||||||
test: $module.after-all
|
test: $module.after-all
|
||||||
}
|
} $plugins
|
||||||
}
|
}
|
||||||
return $tests
|
return $tests
|
||||||
}
|
}
|
||||||
@ -278,6 +281,7 @@ export def run-tests [
|
|||||||
--exclude-module: string, # Pattern to use to exclude test modules. Default: No modules are excluded
|
--exclude-module: string, # Pattern to use to exclude test modules. Default: No modules are excluded
|
||||||
--list, # list the selected tests without running them.
|
--list, # list the selected tests without running them.
|
||||||
--threads: int@"nu-complete threads", # Amount of threads to use for parallel execution. Default: All threads are utilized
|
--threads: int@"nu-complete threads", # Amount of threads to use for parallel execution. Default: All threads are utilized
|
||||||
|
--plugins: list<string>, # Plugins to load while running tests.
|
||||||
] {
|
] {
|
||||||
let available_threads = (sys cpu | length)
|
let available_threads = (sys cpu | length)
|
||||||
|
|
||||||
@ -356,7 +360,7 @@ export def run-tests [
|
|||||||
let results = (
|
let results = (
|
||||||
$modules
|
$modules
|
||||||
| par-each --threads $threads {|module|
|
| par-each --threads $threads {|module|
|
||||||
run-tests-for-module $module $threads
|
run-tests-for-module $module $threads ($plugins | default [])
|
||||||
}
|
}
|
||||||
| flatten
|
| flatten
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user