davetron5000 / optparse-plus

Start your command line scripts off right in Ruby
http://davetron5000.github.com/optparse-plus
Apache License 2.0
521 stars 54 forks source link

Get error when running what is on the readme. #126

Closed daveallen closed 5 years ago

daveallen commented 5 years ago

I installed ruby 2.5.1 with ram and used a gemset.

Installed methadone and created a test app, ran bundle install then rake and I get this: "uninitialized constant Methadone (NameError)"

It is a module in integration_test_assertions.rb:1.

I had a friend try getting that to work and it errors the same for him.

jpc2 commented 5 years ago

I'm seeing the same on both Window and Debian - Ruby 2.5.1. To run bundle install I have to comment out the the two spec.metadata lines for source_code_uri and changelog_uri.

daveallen commented 5 years ago

I got it to work by moving the empty module declaration for "Methadone" in front of the 'require_relative "integration_test_assertions"' statement in this file: https://github.com/davetron5000/methadone/blob/master/lib/methadone/test/base_integration_test.rb

jpc2 commented 5 years ago

Fixed the problem in Debian.

Back to the same problems I had with Cucumber and Aruba a year or so ago. Windows just doesn't like people doing something. It is failing in the run_app method. Something to do with the open3.

Here is what it said:

Loaded suite C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/rake-10.5.0/lib/rake/rake_test_loader
Started
.
Finished in 0.000584 seconds.
-------------------------------------------------------------------------------
1 tests, 1 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
-------------------------------------------------------------------------------
1712.33 tests/s, 1712.33 assertions/s
Loaded suite C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/rake-10.5.0/lib/rake/rake_test_loader
Started
E
===============================================================================
Error: test_truth(TestSomething): Errno::ENOEXEC: Exec format error - bin/test --help
C:/tools/ruby25/lib/ruby/2.5.0/open3.rb:199:in `spawn'
C:/tools/ruby25/lib/ruby/2.5.0/open3.rb:199:in `popen_run'
C:/tools/ruby25/lib/ruby/2.5.0/open3.rb:95:in `popen3'
C:/tools/ruby25/lib/ruby/2.5.0/open3.rb:258:in `capture3'
C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/methadone-2.0.1/lib/methadone/test/base_integration_test.rb:26:in `run_app'
C:/Work/File_Compare/test/test/integration/test_cli.rb:5:in `test_truth'
     2: 
     3: class TestSomething < Methadone::BaseIntegrationTest
     4:   def test_truth
  => 5:     stdout,stderr,results = run_app("test","--help")
     6:     assert_banner(stdout, "test", takes_options: true, takes_arguments: false)
     7:     assert_option(stdout,"-h", "--help")
     8:     assert_option(stdout,"--version")
===============================================================================

Finished in 0.01326 seconds.
-------------------------------------------------------------------------------
1 tests, 0 assertions, 0 failures, 1 errors, 0 pendings, 0 omissions, 0 notifications
0% passed
-------------------------------------------------------------------------------
75.41 tests/s, 0.00 assertions/s

Looking at things a bit... found that if I add a test.bat file to the bin directory that has the same contents that 'gem install test' would add to the ruby/bin directory, the test passes. The test.bat file is basically a wrapper that sends the 'test' in the test/bin directory to ruby to be run. Here is the contents:

@ECHO OFF
IF NOT "%~f0" == "~f0" GOTO :WinNT
@"C:\tools\ruby25\bin\ruby.exe" "C:/tools/ruby25/lib/ruby/gems/2.5.0/bin/test" %1 %2 %3 %4 %5 %6 %7 %8 %9
GOTO :EOF
:WinNT
@"C:\tools\ruby25\bin\ruby.exe" "%~dpn0" %*

Much the same as I did for 'bundle exec'. #125

davetron5000 commented 5 years ago

The missing module issue was fixed in https://github.com/davetron5000/methadone/pull/124 and released as 2.0.1 - what version are you using?

Yes, methadone uses the open3 standard library to execute subprocesses. I have no way to try that on Windows and am not sure if it's intended to work on Windows or not.

jpc2 commented 5 years ago

I'm using 2.0.1. Uninstalled methadone and reinstalled - The error is back.

Moving the empty Methadone module to either before the 'require_relative "integration_test_assertions"' in 'base_integration_test.rb or to the top of integration_test_assertions.rb will work. The later seems better to me.

davetron5000 commented 5 years ago

OH, I see now. I'm not sure how #124 was a real fix. UGH. Let me look

davetron5000 commented 5 years ago

Fixed (I hope!) and released as 2.0.2

daveallen commented 5 years ago

It's working thanks!