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: e7bcde5a67bd
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 5301ae003f5f
Choose a head ref
  • 2 commits
  • 3 files changed
  • 2 contributors

Commits on Mar 31, 2017

  1. Copy the full SHA
    6e7ee6b View commit details

Commits on Apr 3, 2017

  1. Merge pull request #4554 from OttoGroupSolutionProvider/trace_point-n…

    …il-event-fix
    
    Kullmann: Fix TracePoint nil event. Add test
    enebo authored Apr 3, 2017
    Copy the full SHA
    5301ae0 View commit details
Original file line number Diff line number Diff line change
@@ -104,7 +104,7 @@ public synchronized void event(ThreadContext context, RubyEvent event, String fi
context.preTrace();

// FIXME: get return value
update(eventName, file, line, name, type, context.getErrorInfo(), context.nil, binding);
update( event.getName(), file, line, name, type, context.getErrorInfo(), context.nil, binding);

try {
block.yieldSpecific(context, TracePoint.this);
64 changes: 64 additions & 0 deletions core/src/test/java/org/jruby/ext/tracepoint/TracePointTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package org.jruby.ext.tracepoint;

import junit.framework.TestCase;
import org.apache.bsf.util.IOUtils;
import org.apache.bsf.util.StringUtils;
import org.jruby.Ruby;
import org.jruby.RubyArray;
import org.jruby.RubyClass;
import org.jruby.RubyInstanceConfig;
import org.jruby.exceptions.RaiseException;
import org.jruby.internal.runtime.methods.DynamicMethod;
import org.jruby.util.cli.Options;

import java.io.IOException;
import java.io.InputStream;


/**
* @author Andre Kullmann
*/
public class TracePointTest extends TestCase {


public void testEventIsNotNil() throws IOException {

boolean fullTraceEnabled = RubyInstanceConfig.FULL_TRACE_ENABLED;
boolean debugFulltrace = Options.DEBUG_FULLTRACE.load();
try {
RubyInstanceConfig config = new RubyInstanceConfig();

Options.DEBUG_FULLTRACE.force("true");
RubyInstanceConfig.FULL_TRACE_ENABLED = true;
config.setDebuggingFrozenStringLiteral(true);

Ruby ruby = Ruby.newInstance(config);

String fileName = "tracepoint_tests/event_test.rb";

InputStream in = getClass().getClassLoader().getResourceAsStream(fileName);
assertNotNull("File '" + fileName + "' not found.", in);
try {
try {
ruby.compileAndLoadFile(fileName, in, false);
} catch (RaiseException e) {
if ("trace_point.event is nil".equals(e.getMessage())) {
fail("The TracePoint event property is nil.");
} else {
throw e;
}
}
} finally {
in.close();
}

RubyArray events = (RubyArray) ruby.evalScriptlet("Events.events");
assertNotNull("Events.events array is nil.", events);
assertFalse("Events.events array is empty", events.isEmpty());

} finally {
Options.DEBUG_FULLTRACE.force( String.valueOf( debugFulltrace ) );
RubyInstanceConfig.FULL_TRACE_ENABLED = fullTraceEnabled;
}
}
}
13 changes: 13 additions & 0 deletions core/src/test/resources/tracepoint_tests/event_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

class Events
def self.events
@events ||= []
end
end

TracePoint.new(:call,:return,:c_call,:c_return) do |trace_point|
fail "trace_point.event is nil" unless trace_point.event
Events.events << trace_point.event
end.enable do
0.to_s
end