Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add minitest-reporters gem #44

Open
shorowit opened this issue Apr 13, 2021 · 3 comments
Open

Add minitest-reporters gem #44

shorowit opened this issue Apr 13, 2021 · 3 comments

Comments

@shorowit
Copy link

Would be nice to have this gem in the OS CLI:
https://github.com/minitest-reporters/minitest-reporters

When running unit tests via the CLI, it makes it easier to see failures/errors.

@shorowit
Copy link
Author

shorowit commented Apr 20, 2021

Hmm, I am confused. It turns out that minitest-reporters is embedded in the CLI:

$ openstudio gem_list | grep minitest-reporters
minitest-reporters (1.4.2) ':/ruby/2.5.0/gems/minitest-reporters-1.4.2'
$ 

However, I get errors when I try to use it via the CLI:

$ openstudio -e "require 'minitest/reporters';Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new"
Error executing argv: ["-e", "require 'minitest/reporters';Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new"]
Error: uninitialized constant Minitest::Reporters::SpecReporter in eval:355:in `const_missing'
eval:40:in `<main>'
:/openstudio_cli.rb:734:in `eval'
:/openstudio_cli.rb:734:in `block in execute'
:/openstudio_cli.rb:732:in `each'
:/openstudio_cli.rb:732:in `execute'
:/openstudio_cli.rb:1755:in `<main>'
eval:175:in `eval'
eval:175:in `require_embedded_absolute'
eval:160:in `block in require_embedded'
eval:154:in `each'
eval:154:in `require_embedded'
eval:113:in `require'
eval:3:in `<main>'
$ 

It works fine if I just use straight ruby:

$ ruby -e "require 'minitest/reporters';Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new"
$ 

@tijcolem @jmarrec

@jmarrec
Copy link
Collaborator

jmarrec commented Apr 26, 2021

@shorowit It seems it can't find the reporters that are embedded, but the workaround is to require it directly and it'll work. You might also need to add reporter.start if you can't get elapsed time when running with the CLI, see what I did on OS-res (at ruby 2.2.4 back then though...) https://github.com/NREL/OpenStudio-resources/blob/7de04f6ded9cf099a3eab1c8973c767e25500edf/test_helpers.rb#L66-L75

Anyways, for your specific example, add require 'minitest/reporters/spec_reporter', see this diff:

- $ openstudio -e "require 'minitest/reporters';Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new"
+ $ openstudio -e "require 'minitest/reporters'; require 'minitest/reporters/spec_reporter'; Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new"

The list of reporters file names can be found here: https://github.com/minitest-reporters/minitest-reporters/tree/master/lib/minitest/reporters

If that's enough, please close this issue.

@shorowit
Copy link
Author

Indeed that allows it to work inside the CLI, thanks Julien.

IMO it's still a (low priority) bug that the CLI behavior is different than straight ruby. I'm using the recommended usage and certainly spec_reporter should automatically load. But since we have a workaround here, I won't object to closing the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants