rtfeldman/node-test-runner

Trim console output

andrewMacmurray opened this issue ยท 10 comments

(Based on this discussion https://discourse.elm-lang.org/t/elm-test-output/6084)

Something I've run into as the project I'm working on gets larger is the console output's file list can grow very large

elm-test 0.19.1
---------------

Running 80 tests. To reproduce these results, run: elm-test --fuzz 100 --seed 231172734506082 
/Users/andrewmacmurray/oprah/application/frontend/src/app/elm/Account.elm 
/Users/andrewmacmurray/oprah/application/frontend/src/app/elm/Account/AccessLevel.elm 
/Users/andrewmacmurray/oprah/application/frontend/src/app/elm/Account/Admin.elm 
/Users/andrewmacmurray/oprah/application/frontend/src/app/elm/Account/AllowedModule.elm 
/Users/andrewmacmurray/oprah/application/frontend/src/app/elm/Account/Partner.elm
...400-500 lines

TEST RUN PASSED

Duration: 526 ms
Passed:   80
Failed:   0 

For my particular case I don't really benefit from seeing all the file paths - but other may find this useful.

For me it would be really nice to see the output like:

elm-test 0.19.1
---------------

Running 80 tests. To reproduce these results, run: elm-test --fuzz 100 --seed 231172734506082 

TEST RUN PASSED

Duration: 526 ms
Passed:   80
Failed:   0 

One idea could be to pass an additional flag, I'm not wild about these names but maybe something like:

  • --trim
  • --trim-output
  • --hide-paths
elm test --report=console --trim

Or if it was on by default maybe there could be a --verbose flag

Another option could be have a different reporter, something like:

elm test --report=compact

Any thoughts? Very happy to make an PR if we arrive at a conclusion for this ๐Ÿ˜„

Are the 400-500 lines needed if you wanted to reproduce the test result?

I wonder if this couldn't be alleviated if relative paths were used? (We could even output the cwd if we wanted to)

elm-test 0.19.1
---------------

Running 80 tests. To reproduce these results, run: 

cd /Users/andrewmacmurray/oprah/application/frontend/src/app/elm
elm-test --fuzz 100 --seed 231172734506082 Account.elm Account/AccessLevel.elm Account/Admin.elm Account/AllowedModule.elm Account/Partner.elm
...

TEST RUN PASSED

Duration: 526 ms
Passed:   80
Failed:   0 

@gampleman that would definitely cut it down, problem is in the example I have there's ~300 files that appear in that list that would still produce a lot of noise

@harrysarson I'm not sure if you need the paths to reproduce the results, I'm not super familiar with the internals of the test runner yet but will take a look

TBH the reproduction command could really be just the arguments passed to elm-test with the addition of the --seed flag. The idea with printing the files is to make sure you run the same tests, but that won't survive changes to the files themselves, so I don't really see the point.

That sounds very sensible, I'm happy to put an MR together to make that change

Hello @andrewMacmurray , I took a stab at trimming the console output as suggested by @gampleman.
I hope that's ok.

Thanks @marc136! I added some comments to the PR :) @andrewMacmurray feel free to chip into the discussion at #432 --- it would be super useful to hear your feedback.

@marc136 that's awesome, thanks for thiis

I also noticed while running tests earlier, that on compilation failure also all the tests files are printed.

I do not see a big value to have the message
Compilation failed while attempting to build <...many many lines of test files...>
on compilation failure, and would prefer the error messages like this:

$ elm-test
[...]
Compilation failed while attempting to run `elm make` on <cwd>
$ elm-test tests/Group/* test/One.elm
[...]
Compilation failed while attempting to build tests/Group/* tests/One.elm

This would require a similar change in lib/Compile.js as was done in 557a2eb to print the testFileGlobs instead of the testFilePaths.

Any thoughts?

Fixed!