ManageIQ / optimist

Optimist is a commandline option parser for Ruby that just gets out of your way.
https://manageiq.org/optimist/
MIT License
249 stars 36 forks source link

test_usage fails on Fedora Rawhide #111

Open ignatenkobrain opened 4 years ago

ignatenkobrain commented 4 years ago
Optimist::ParserEduateTest#test_usage [/home/brain/rpmbuild/BUILDROOT/rubygem-optimist-3.0.0-1.fc33.x86_64/usr/share/gems/gems/optimist-3.0.0/test/optimist/parser_educate_test.rb:25]:
Expected /^Usage: \w* usage string\n\nOptions:/ to match "Usage: -e usage string\n\nOptions:\n".

Anything you'd like to know?

Fryguy commented 4 years ago

@ignatenkobrain How is this test being executed? I am running the tests with bundle exec rake, which is the expected way to run the tests, and the value of the output is

Usage: rake_test_loader usage string

Options:

(Note the rake_test_loader in my output vs -e in yours.

Fryguy commented 4 years ago

Even bundle exec ruby -Ilib:test test/optimist/parser_educate_test.rb passes on my machine with the following output

Usage: parser_educate_test usage string

Options:
ignatenkobrain commented 4 years ago

basically it is executed in a ruby -Ilib:test test/optimist/parser_educate_test.rb way... But the main difference between build environment and your machine is that build environment does not have TTY, can that be related?

Fryguy commented 4 years ago

I'm not sure...it's more about what $0 is... the relevant portion of the code is:

https://github.com/ManageIQ/optimist/blob/master/lib/optimist.rb#L369-L370

which in your case is yielding -e. Do you know what $0 is in your case?

kbrock commented 4 years ago

The only code that I feel could affect this is:

https://github.com/ManageIQ/optimist/blob/master/lib/optimist.rb#L391-L403

it should default to 80 wide for non tty

Fryguy commented 4 years ago

Right, but the error is because the program name is -e instead of something else. I mean the simple fix on our side it to just change the test on our side from \w* to [\w-]*, but I'd like to understand the deeper reason as to why a -e is there at all, and if there's a change that can be made on the packaging side, perhaps that's preferable than changing the this test?

nanobowers commented 3 months ago

IMO there's not enough information here to debug this, would recommend closing.

Fryguy commented 3 months ago

Reviewing this I recall that Red Hat does some interesting stuff when building rpms around gems, where they can run tests from within the rpm BUILDROOT, and it's like a special chroot'ed environment. I wonder if that's what's going on here? @ignatenkobrain I realize this issue is 4 years old, but do you have any more details?