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

testsuite: Ruby 1.8 compatibility #49

Closed
barsnick opened this issue Feb 21, 2017 · 1 comment
Closed

testsuite: Ruby 1.8 compatibility #49

barsnick opened this issue Feb 21, 2017 · 1 comment

Comments

@barsnick
Copy link

I tried running the test suite with Ruby 1.8 - actually Ruby 1.8.6, I'm aware that 1.8.7 may have brought in some features. Anyway, I did see in ticket #6 that Ruby is supposed to be >= 1.9. There are mentions of an existing workaround for 1.8.7 in test_bindfs.rb though.

So I managed to make "make check" work with 1.8.

Since I can't attach patches (yeah, pull requests, I know...), I'll just quote these simple ones here.

This is for

./test_bindfs.rb:42: undefined method `realpath' for File:Class (NoMethodError)
FAIL: test_bindfs.rb
diff -ur bindfs-1.13.6/tests/test_bindfs.rb bindfs-1.13.6-rubyrealpath/tests/test_bindfs.rb
--- bindfs-1.13.6/tests/test_bindfs.rb  2017-01-29 18:12:37.000000000 +0100
+++ bindfs-1.13.6-rubyrealpath/tests/test_bindfs.rb     2017-02-21 13:53:55.000000000 +0100
@@ -22,6 +22,7 @@
 localsrc_path = ENV['srcdir'] || '.'

 require localsrc_path + '/common.rb'
+require 'pathname'

 include Errno

@@ -42,7 +43,7 @@
 $nobody_gid = nobody_gid = Etc.getpwnam('nobody').gid
 $nobody_group = nobody_group = Etc.getgrgid(nobody_gid).name

-$tests_dir = File.realpath('.')
+$tests_dir = Pathname.new('.').realpath.to_s


 testenv("") do

This is for

undefined method `escape' for Shellwords:Module
  ./common.rb:134:in `testenv'
  ./test_bindfs.rb:49

Slightly modified workaround taken from purcell/darcs-to-git#21.

diff -ur bindfs-1.13.6/tests/common.rb bindfs-1.13.6-rubyshellescape/tests/common.rb
--- bindfs-1.13.6/tests/common.rb       2017-01-29 18:12:37.000000000 +0100
+++ bindfs-1.13.6-rubyshellescape/tests/common.rb       2017-02-21 13:58:32.000000000 +0100
@@ -19,7 +19,16 @@
 #

 require 'fileutils'
-require 'shellwords'
+if RUBY_VERSION >= "1.9"
+  require 'shellwords'
+else
+  module Shellwords
+    def self.escape(str)
+      return "''" if str.empty?
+      str.gsub(/([^A-Za-z0-9_\-.,:\/@\n])/n, "\\\\\\1").gsub(/\n/, "'\n'")
+    end
+  end
+end
 include FileUtils

 # Set the default umask for all tests

I wouldn't be surprised if you didn't care. ;) Just in case anyone else stumbles across this.

@mpartel
Copy link
Owner

mpartel commented Mar 12, 2017

Fixed, and there is now a script that runs the test suite on VMs running older OSes, including CentOS 6 with Ruby 1.8.7.

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