Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 9c88738a5c23
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: cd0c8c17452d
Choose a head ref
  • 5 commits
  • 7 files changed
  • 1 contributor

Commits on Jan 20, 2017

  1. Copy the full SHA
    0e2e1a7 View commit details
  2. Copy the full SHA
    cd0494a View commit details
  3. make sure $LOADED_FEATURES.clear behaves as expected

    since this special array uses an internal set for speed
    
    resolves #413
    kares committed Jan 20, 2017
    Copy the full SHA
    43cc895 View commit details
  4. Copy the full SHA
    ba35591 View commit details
  5. [test] avoid artificial failures due load tests influencing each other

    ... loading jruby/compiler eagerly seems to solve these weird issues
    kares committed Jan 20, 2017
    Copy the full SHA
    cd0c8c1 View commit details
11 changes: 5 additions & 6 deletions core/src/main/java/org/jruby/RubyClassPathVariable.java
Original file line number Diff line number Diff line change
@@ -61,23 +61,22 @@ public IRubyObject append(IRubyObject obj) {
public IRubyObject append(ThreadContext context, IRubyObject obj) {
IRubyObject[] paths;
if (obj.respondsTo("to_a")) {
paths = ((RubyArray) obj.callMethod(context, "to_a")).toJavaArray();
paths = ((RubyArray) obj.callMethod(context, "to_a")).toJavaArrayMaybeUnsafe();
} else {
paths = context.runtime.newArray(obj).toJavaArray();
paths = new IRubyObject[] { obj };
}

for (IRubyObject path: paths) {
try {
URL url = getURL(path.convertToString().toString());
if (url.getProtocol().equals("file")) {
path = RubyFile.expand_path19(context, null, new IRubyObject[]{ path });
path = RubyFile.expand_path(context, null, path);
url = getURL(path.convertToString().toString());
}
getRuntime().getJRubyClassLoader().addURL(url);
context.runtime.getJRubyClassLoader().addURL(url);
} catch (MalformedURLException mue) {
throw getRuntime().newArgumentError(mue.getLocalizedMessage());
throw context.runtime.newArgumentError(mue.getLocalizedMessage());
}

}
return this;
}
11 changes: 5 additions & 6 deletions core/src/main/java/org/jruby/RubyFile.java
Original file line number Diff line number Diff line change
@@ -817,15 +817,14 @@ public static IRubyObject extname(ThreadContext context, IRubyObject recv, IRuby
* @param args
* @return Resulting absolute path as a String
*/
public static IRubyObject expand_path(ThreadContext context, IRubyObject recv, IRubyObject[] args) {
return expand_path19(context, recv, args);
@JRubyMethod(name = "expand_path", required = 1, optional = 1, meta = true)
public static IRubyObject expand_path(ThreadContext context, IRubyObject recv, IRubyObject... args) {
return expandPathInternal(context, recv, args, true, false);
}

@JRubyMethod(name = "expand_path", required = 1, optional = 1, meta = true)
@Deprecated
public static IRubyObject expand_path19(ThreadContext context, IRubyObject recv, IRubyObject[] args) {
RubyString path = (RubyString) expandPathInternal(context, recv, args, true, false);

return path;
return expand_path(context, recv, args);
}


Original file line number Diff line number Diff line change
@@ -66,9 +66,10 @@ public synchronized RubyArray append(IRubyObject item) {
}

@Override
public synchronized void clear() {
super.clear();
public synchronized IRubyObject rb_clear() {
IRubyObject res = super.rb_clear();
set.clear();
return res;
}

public final void deleteString(ThreadContext context, String element) {
31 changes: 25 additions & 6 deletions test/jruby/test_load.rb
Original file line number Diff line number Diff line change
@@ -10,15 +10,13 @@ class TestLoad < Test::Unit::TestCase
include TestHelper

def setup
@prev_loaded_features = $LOADED_FEATURES.dup
@prev_load_path = $LOAD_PATH.dup
@_LOADED_FEATURES = $LOADED_FEATURES.dup
@_LOAD_PATH = $LOAD_PATH.dup
end

def teardown
$LOADED_FEATURES.clear
$LOADED_FEATURES.concat(@prev_loaded_features)
$LOAD_PATH.clear
$LOAD_PATH.concat(@prev_load_path)
$LOADED_FEATURES.replace(@_LOADED_FEATURES)
$LOAD_PATH.replace(@_LOAD_PATH)
end

def test_require
@@ -72,6 +70,25 @@ def test_load_with_empty_string_in_loadpath
end
end

def test_LOADED_FEATURES_clear
#_LOADED_FEATURES = $LOADED_FEATURES.dup
begin
require('test/jruby/foo.bar.rb')
some_feat = $LOADED_FEATURES.first
full_path = File.expand_path('test/jruby/foo.bar.rb')
assert $LOADED_FEATURES.include?(full_path)

$LOADED_FEATURES.clear
assert_equal 0, $LOADED_FEATURES.size
assert $LOADED_FEATURES.empty?

assert ! $LOADED_FEATURES.include?(full_path)
assert ! $LOADED_FEATURES.include?(some_feat)
ensure
#$LOADED_FEATURES.replace(_LOADED_FEATURES)
end
end

def test_require_bogus
assert_raises(LoadError) { require 'foo/' }
assert_raises(LoadError) { require '' }
@@ -228,6 +245,8 @@ def require(file)
res = File.expand_path($loading_behavior_result)

assert_equal File.expand_path(File.join('test', 'jruby', 'test_loading_behavior.rb')), res
ensure
Object.class_eval { alias require old_require; undef :old_require }
end

# JRUBY-3894
4 changes: 2 additions & 2 deletions test/jruby/test_load_compiled_ruby.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
require 'test/unit'
require 'jruby/jrubyc'
require 'fileutils'

class TestLoadCompiledRuby < Test::Unit::TestCase
FILENAME = 'test_load_compiled_ruby_script.rb'
COMPILED = 'test_load_compiled_ruby_script.class'
def test_load_compiled_ruby

def test_load_compiled_ruby; require 'jruby/jrubyc'
begin
File.open(FILENAME, 'w') do |f|
f.write('$test_load_compiled_ruby = true')
19 changes: 9 additions & 10 deletions test/jruby/test_load_compiled_ruby_class_from_classpath.rb
Original file line number Diff line number Diff line change
@@ -13,21 +13,19 @@ class TestLoadCompiledRubyClassFromClasspath < Test::Unit::TestCase
StarterClass = "#{StarterName}.class"
Manifest = "manifest.txt"

def self.startup
require 'rbconfig'
require 'fileutils'
# Necessary because of http://jira.codehaus.org/browse/JRUBY-1579
require 'jruby'
require 'jruby/compiler'
end
require 'rbconfig'; require 'fileutils'
require 'jruby'; require 'jruby/compiler'

if java.lang.System.getProperty("basedir") # FIXME: disabling this test under maven
def test_truth; end
def test_truth
warn "FIXME: disabled test #{__FILE__} under maven"
end
else

@@ENV_CLASSPATH = ENV["CLASSPATH"]

def setup
remove_test_artifacts
@original_classpath = ENV["CLASSPATH"]

# This line means we assume the test is running from the jruby root directory
@jruby_home = Dir.pwd
@@ -37,7 +35,7 @@ def setup

def teardown
remove_test_artifacts
ENV["CLASSPATH"] = @original_classpath
ENV["CLASSPATH"] = @@ENV_CLASSPATH
JRuby.runtime.instance_config.run_ruby_in_process = @in_process
end

@@ -92,6 +90,7 @@ def test_loading_compiled_ruby_class_from_jar
end

private

def remove_ruby_source_files
FileUtils.rm_rf [RubySource, RubyClass]
end
5 changes: 2 additions & 3 deletions test/jruby/test_load_gem_extensions.rb
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
require 'test/jruby/test_helper'
require 'jruby/path_helper'

class TestLoad < Test::Unit::TestCase
class TestLoadGemExtensions < Test::Unit::TestCase
include TestHelper

def setup
@@ -11,8 +11,7 @@ def setup
end

def teardown
$LOADED_FEATURES.clear
$LOADED_FEATURES.concat(@prev_loaded_features)
$LOADED_FEATURES.replace(@prev_loaded_features)
$LOAD_PATH.clear
$LOAD_PATH.concat(@prev_load_path)
end