Skip to content

std lib: extend test runner capabilities#8499

Merged
sholderbach merged 5 commits intonushell:mainfrom
presidento:test-executor
Mar 20, 2023
Merged

std lib: extend test runner capabilities#8499
sholderbach merged 5 commits intonushell:mainfrom
presidento:test-executor

Conversation

@presidento
Copy link
Copy Markdown
Contributor

I am implementing a nu plugin, and want to unit test that it works well.

Basic usage (unchanged)

image

Select the folder to run tests within (subfolders included)

image

Select module to run tests within

image

Select test command to run

image

Complex usage

image

- run tests within a given folder
- select test module to run tests within
- select test command to run
@fdncred fdncred added the A:std-library Defining and improving the standard library written in Nu label Mar 17, 2023
@amtoine
Copy link
Copy Markdown
Member

amtoine commented Mar 17, 2023

the tests of the existing library are broken, let me fix them and i'll come back to this PR right after the changes have been applied 😉

@amtoine
Copy link
Copy Markdown
Member

amtoine commented Mar 17, 2023

@amtoine
Copy link
Copy Markdown
Member

amtoine commented Mar 17, 2023

in the meantime, to help the developer trying to run the new tests runner, i think a --list option to list all the modules and their respective available commands would be very nice 😮

and also allowing to pass multiple modules and commands maybe?
not sure how easy that would be though 🤔

@presidento
Copy link
Copy Markdown
Contributor Author

I was thinking about --dry-run or --dry. I think it describes better what it does. And as I remember, other thest suites uses something similar. Do you prefer --list instead?

At first step I do not want implement support for multiple modules & commands. I can be useful, but until somebody really needs it for me it seems to me L'art pour L'art work. (Also can be workarounded easily with chained commands.)

@amtoine
Copy link
Copy Markdown
Member

amtoine commented Mar 17, 2023

I was thinking about --dry-run or --dry. I think it describes better what it does. And as I remember, other thest suites uses something similar. Do you prefer --list instead?

i would say --list is more nushelly 😋
and to me, it represents more what it does, i.e. listing available options 👍

so i'd personnally push --list forward.

At first step I do not want implement support for multiple modules & commands. I can be useful, but until somebody really needs it for me it seems to me L'art pour L'art work. (Also can be workarounded easily with chained commands.)

yeah you got a point, never mind about that one 😉

something like this, right? 😏

def "multi-test" [] {
    let tests = $in

    let runner = (
        git rev-parse --show-toplevel
        | str trim
        | path join "crates" "nu-utils" "standard_library" "tests.nu"
    )

    $tests
    | transpose module command
    | flatten
    | each {|test|
        nu $runner --module $test.module --command $test.command
    }
}

{foo: [f1 f2 f3], bar: [b1 b4]} | multi-test

@presidento
Copy link
Copy Markdown
Contributor Author

That can be an example. The other one is just nu tests.nu --module test_a; nu tests.nu --module test_b. I think it is rarely needed. The typical use case is to run just a given command for TDD, or run the tests for my currently developed module.

I added --list option.

Copy link
Copy Markdown
Member

@amtoine amtoine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the --list option and the extended documentation 👌

@presidento
Copy link
Copy Markdown
Contributor Author

Conflict with main branch is resolved.

@presidento
Copy link
Copy Markdown
Contributor Author

It seems that there is an unrelated fail in Ubuntu 20.04 checks.

@presidento
Copy link
Copy Markdown
Contributor Author

Master is merged to get rid of CI errors.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 20, 2023

Codecov Report

Merging #8499 (2912b24) into main (ecc153c) will not change coverage.
The diff coverage is n/a.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #8499   +/-   ##
=======================================
  Coverage   68.51%   68.51%           
=======================================
  Files         624      624           
  Lines      100562   100562           
=======================================
  Hits        68903    68903           
  Misses      31659    31659           

Copy link
Copy Markdown
Member

@amtoine amtoine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me 👌

@sholderbach
Copy link
Copy Markdown
Member

Then let's give this a shot! Thanks!

@sholderbach sholderbach merged commit 77d3376 into nushell:main Mar 20, 2023
amtoine added a commit to amtoine/nushell that referenced this pull request Mar 23, 2023
…d-throw-true-error

This commit merges the PR that introduces the conflict into the current
feature branch: nushell#8499

i've kept the four new options to the runner and made them work with the
structured paradigm of the runner in nushell#8525.
@presidento presidento deleted the test-executor branch April 6, 2023 09:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A:std-library Defining and improving the standard library written in Nu

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants