Samstag, 6. November 2010

Cygwin ain't Linux

Today I looked at my failing tests in open3_test.rb. One of them failed here:
stdin, stdout, stderr = popen3('cd this_folder_does_not_exist')
After some investigation I found out that popen3 in Ubuntu expects a "real" executeable, shell build ins like 'cd' cause "Error:ENOENT". This is one more difference between cygwin and Ubuntu. Wanna try?

Ubuntu
egon@egon:/home/egon> ruby -e '%x[cd]'
-e:1:in ``': No such file or directory - cd (Errno::ENOENT)
        from -e:1:in `
'


cygwin
$ ruby -e '%x[cd]'
$

As my test was just a learning test I looked for better ways to interact with the underlying OS. These sites helped me a lot
http://stackoverflow.com/questions/2232/calling-bash-commands-from-ruby
http://tech.natemurray.com/2007/03/ruby-shell-commands.html
Result: I changed my tests and now I use the classes Dir and File interact with the underlying OS

As a side result I noticed somthing weird with Test::Unit. I don't know whether this is a bug or a feature. I will find out later on, hence I added a ToDo into my WiKi. See http://slevinmcguigan.wikispaces.com/ToDo's

Keine Kommentare:

Kommentar veröffentlichen