ruby / mspec

RSpec-like test runner for the Ruby Spec Suite
https://github.com/ruby/spec
MIT License
59 stars 62 forks source link

"sh: END_OF_RUBYCODE: not found" "sh: 2>&1: not found" "sh: : cannot execute" on Solaris #11

Closed ngoto closed 9 years ago

ngoto commented 9 years ago

After d0406c98e1bfe9bc6c51a9fcba9d62a14b017fb1, the followinf errors occur.

./miniruby -I./lib -I. -I.ext/common  ./tool/runruby.rb --extout=.ext  -- --disa
ble-gems -r./sparc64-solaris2.10-fake ./spec/mspec/bin/mspec run -B ./spec/default.mspec 
ruby 2.3.0dev (2015-09-02) [sparc64-solaris2.10]
...................
(snip)
sh: END_OF_RUBYCODE: not found
sh:  2>&1: not found
(snip)
F...............................................................................
................................................................................
................................................................................
......................................................E.........................
................................................................................
................................................................................
...............................................................................F
...............................F....FF.............F............................
................................................................................
................................................................................
................................................................................
.................Broken Pipe
.....................................sh: : cannot execute
Fsh: : cannot execute
F...................sh: : cannot execute
sh: : cannot execute
sh: : cannot execute
sh: : cannot execute
sh: : cannot execute
sh: : cannot execute
sh: : cannot execute
sh: : cannot execute
sh: : cannot execute
sh: : cannot execute
sh: : cannot execute
sh: : cannot execute
sh: : cannot execute
sh: : cannot execute
sh: : cannot execute
sh: : cannot execute
sh: : cannot execute
sh: : cannot execute
F...............................................................................
(snip)
11)
Kernel#autoload when Object is frozen raises a RuntimeError before defining the 
constant FAILED
Expected "-e:5: syntax error, unexpected end-of-input\n"
to equal "RuntimeError - nil"

/XXXXX/spec/rubyspec/core/kernel/autoload_spec.rb:75:in `block (3 levels) in <top (required)>'
/XXXXX/spec/rubyspec/core/kernel/autoload_spec.rb:16:in `<top (required)>'
(snip)

The error messages "sh: END_OF_RUBYCODE: not found" and "sh: 2>&1: not found" are caused by /bin/sh in Solaris that may parse the double quote " in cat contents and the command-line is wrongly splitted by the shell.

I think using here document simply like below might solve the problem.

ruby - <<'HERE_DOCUMENT'
puts 0
HERE_DOCUMENT

I also thing that using temporary script file may be an alternative solution.

eregon commented 9 years ago

Yes, these should really be fixtures, like fixture(__FILE__, "autoload_frozen.rb")

eregon commented 9 years ago

The approach using STDIN to pass the code is problematic for cases of ruby_exe which expect to pass a file by STDIN.

ngoto commented 9 years ago

Thanks, but this only fixes "Kernel#autoload when Object is frozen raises a RuntimeError before defining the constant FAILED".

As you can see, there are many "sh: : cannot execute" which is caused by cat and double quote splitting of command line. Do you mean all of the specs should be rewritten to fixture?

eregon commented 9 years ago

I think most of them should, but I am also investigating a solution with putting the code in a temporary file, for ruby_exe. Seems it works well except for 4 examples of -s, which I can fix. I'll push the fix tomorrow.

ngoto commented 9 years ago

Executing mspec with "--verbose --debug" shows that the shell's error messages "sh: END_OF_RUBYCODE: not found" and "sh: 2>&1: not found" occurred in spec/rubyspec/command_line/rubyopt_spec.rb.

$ MSPECOPT="--verbose --debug" make test-rubyspec
./miniruby -I./lib -I. -I.ext/common  ./tool/runruby.rb --extout=.ext  -- --disable-gems -r./sparc64-solaris2.10-fake ./spec/mspec/bin/mspec run -B ./spec/default.mspec --verbose --debug
ruby 2.3.0dev (2015-09-02) [sparc64-solaris2.10]

/XXXXX/trunk-51741/spec/rubyspec/command_line/dash_a_spec.rb                                                .
(snip)
/XXXXX/trunk-51741/spec/rubyspec/command_line/error_message_spec.rb                                         .
/XXXXX/trunk-51741/spec/rubyspec/command_line/rubyopt_spec.rb                                               Exception `LoadError' at /XXXXX/trunk-51741/lib/rubygems.rb:1229 - cannot load such file -- rubygems/defaults/operating_system
Exception `LoadError' at /XXXXX/trunk-51741/lib/rubygems.rb:1238 - cannot load such file -- rubygems/defaults/ruby
sh: END_OF_RUBYCODE: not found
sh:  2>&1: not found
F
/XXXXX/trunk-51741/spec/rubyspec/language/BEGIN_spec.rb                                                     .
(snip)
/XXXXX/trunk-51741/spec/rubyspec/optional/capi/util_spec.rb                                                 .

1)
Processing RUBYOPT sets $DEBUG to true for '-d' FAILED
Expected ""
 to match /value of \$DEBUG is true/

(snip)

I'm sorry I misidentified the error. The failure of "Kernel#autoload when Object is frozen raises a RuntimeError before defining the constant" did not show shell's error message and it only showed child ruby's syntax error.

eregon commented 9 years ago

I think this last commit should fix it, as it puts the code in a temporary file. Please reopen if not.

eregon commented 9 years ago

It looks fine on RubyCI now, remaining errors seem unrelated to shell errors.

ngoto commented 9 years ago

Thnak you. I'm running "make test-rubyspec" on Solaris 10. I'll post about other failures as different issues.