summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'dev-java/jruby/files/user-test-fixes.patch')
-rw-r--r--dev-java/jruby/files/user-test-fixes.patch124
1 files changed, 124 insertions, 0 deletions
diff --git a/dev-java/jruby/files/user-test-fixes.patch b/dev-java/jruby/files/user-test-fixes.patch
new file mode 100644
index 000000000000..6688fa9aa01a
--- /dev/null
+++ b/dev-java/jruby/files/user-test-fixes.patch
@@ -0,0 +1,124 @@
+diff -Naur jruby-1.2.0.orig/test/externals/ruby_test/lib/test/helper.rb jruby-1.2.0/test/externals/ruby_test/lib/test/helper.rb
+--- jruby-1.2.0.orig/test/externals/ruby_test/lib/test/helper.rb 2009-03-16 15:16:02.000000000 +0000
++++ jruby-1.2.0/test/externals/ruby_test/lib/test/helper.rb 2009-04-18 00:34:02.198853097 +0100
+@@ -235,31 +235,34 @@
+ # Get the user of the current process.
+ #
+ def get_user
+- user = ENV['USERNAME'] || ENV['USER']
+ if WINDOWS
+- if user.nil?
+- buf = 0.chr * MAX_PATH
+- if GetUserName.call(buf, buf.length) == 0
+- raise "Unable to get user name"
+- end
+- user = buf.unpack("A*")
++ buf = 0.chr * MAX_PATH
++ if GetUserName.call(buf, buf.length) != 0
++ buf.unpack("A*")
++ elsif user = ENV['USERNAME'] || ENV['USER']
++ user
++ else
++ raise "Unable to get user name"
+ end
+ else
+- user ||= Etc.getpwuid(Process.uid).name
++ Etc.getpwuid(Process.uid).name
+ end
+- user
+ end
+
+- # Returns the home directory of the current process owner.
+- #
++ # Returns the home directory of the current process owner
++ # according to the HOME/USERPROFILE variable.
+ def get_home
+- home = ENV['HOME'] || ENV['USERPROFILE']
++ ENV['HOME'] || ENV['USERPROFILE'] || get_real_home
++ end
++
++ # Returns the home directory of the current process owner
++ # according to the system.
++ def get_real_home
+ if WINDOWS
+- home ||= "C:\\Documents and Settings\\" + get_user
++ "C:\\Documents and Settings\\" + get_user
+ else
+- home ||= Etc.getpwuid(Process.uid).dir
++ Etc.getpwuid(Process.uid).dir
+ end
+- home
+ end
+
+ # Returns the current umask of the process.
+diff -Naur jruby-1.2.0.orig/test/externals/ruby_test/test/core/File/class/tc_expand_path.rb jruby-1.2.0/test/externals/ruby_test/test/core/File/class/tc_expand_path.rb
+--- jruby-1.2.0.orig/test/externals/ruby_test/test/core/File/class/tc_expand_path.rb 2009-03-16 15:15:49.000000000 +0000
++++ jruby-1.2.0/test/externals/ruby_test/test/core/File/class/tc_expand_path.rb 2009-04-18 00:20:58.966617568 +0100
+@@ -12,6 +12,7 @@
+ def setup
+ @user = get_user
+ @home = get_home
++ @real_home = get_real_home
+ @pwd = Dir.pwd
+ ENV['HOME'] = ENV['USERPROFILE'] if WINDOWS
+ end
+@@ -88,17 +89,21 @@
+ end
+
+ def test_expand_path_with_tilde
+- assert_equal(@home, File.expand_path("~#{@user}"))
+- assert_equal(File.join(@home, 'bin'), File.expand_path("~#{@user}/bin"))
++ { "~" => @home, "~#{@user}" => @real_home }.each do |tilde,path|
++ assert_equal(path, File.expand_path(tilde))
++ assert_equal(File.join(path, 'bin'), File.expand_path("#{tilde}/bin"))
++ end
+ end
+
+ # Second argument ignored if tilde is present and it's at position 0.
+ def test_expand_path_with_tilde_and_dir
+- assert_equal(@home, File.expand_path("~#{@user}", '.'))
+- assert_equal(@home, File.expand_path("~#{@user}", '..'))
+- assert_equal(@home, File.expand_path("~#{@user}", '/tmp'))
+- assert_equal(@home, File.expand_path("~#{@user}", '../tmp'))
+- assert_equal(File.join(@home, 'bin'), File.expand_path("~#{@user}/bin", '/tmp'))
++ { "~" => @home, "~#{@user}" => @real_home }.each do |tilde,path|
++ assert_equal(path, File.expand_path(tilde, '.'))
++ assert_equal(path, File.expand_path(tilde, '..'))
++ assert_equal(path, File.expand_path(tilde, '/tmp'))
++ assert_equal(path, File.expand_path(tilde, '../tmp'))
++ assert_equal(File.join(path, 'bin'), File.expand_path("#{tilde}/bin", '/tmp'))
++ end
+ end
+
+ def test_expand_path_returns_tainted_string
+@@ -120,5 +126,6 @@
+ @pwd = nil
+ @user = nil
+ @home = nil
++ @real_home = nil
+ end
+ end
+diff -Naur jruby-1.2.0.orig/test/externals/ruby_test/test/core/ProcessGID/class/tc_rid.rb jruby-1.2.0/test/externals/ruby_test/test/core/ProcessGID/class/tc_rid.rb
+--- jruby-1.2.0.orig/test/externals/ruby_test/test/core/ProcessGID/class/tc_rid.rb 2009-03-16 15:16:00.000000000 +0000
++++ jruby-1.2.0/test/externals/ruby_test/test/core/ProcessGID/class/tc_rid.rb 2009-04-18 21:24:02.653686353 +0100
+@@ -12,7 +12,7 @@
+
+ def setup
+ unless WINDOWS
+- @gid = Etc.getpwnam(Etc.getlogin).gid
++ @gid = `id -g`.to_i
+ end
+ end
+
+diff -Naur jruby-1.2.0.orig/test/externals/ruby_test/test/core/ProcessUID/class/tc_rid.rb jruby-1.2.0/test/externals/ruby_test/test/core/ProcessUID/class/tc_rid.rb
+--- jruby-1.2.0.orig/test/externals/ruby_test/test/core/ProcessUID/class/tc_rid.rb 2009-03-16 15:15:50.000000000 +0000
++++ jruby-1.2.0/test/externals/ruby_test/test/core/ProcessUID/class/tc_rid.rb 2009-04-18 21:30:26.748686198 +0100
+@@ -12,7 +12,7 @@
+
+ def setup
+ unless WINDOWS
+- @uid = Etc.getpwnam(Etc.getlogin).uid
++ @uid = `id -u`.to_i
+ end
+ end
+