Skip to content

Commit

Permalink
Showing 9 changed files with 83 additions and 28 deletions.
18 changes: 9 additions & 9 deletions ci.hocon
Original file line number Diff line number Diff line change
@@ -24,18 +24,18 @@ common: {
}

gate_caps: {
capabilities: [linux, amd64, gate]
capabilities: [linux, amd64, gate, post-push]
}

jt: [ruby, "tool/jt.rb"]

builds = [
{name: "ruby-test-fast"} ${common} ${gate_caps} {run: [${jt} [test, fast]]},
{name: "ruby-test-specs-command-line"} ${common} ${gate_caps} {run: [${jt} [test, specs, ":command_line"]]},
{name: "ruby-test-specs-language"} ${common} ${gate_caps} {run: [${jt} [test, specs, ":language"]]},
{name: "ruby-test-specs-core"} ${common} ${gate_caps} {run: [${jt} [test, specs, ":core"]]},
{name: "ruby-test-specs-library"} ${common} ${gate_caps} {run: [${jt} [test, specs, ":library"]]},
{name: "ruby-test-specs-truffle"} ${common} ${gate_caps} {run: [${jt} [test, specs, ":truffle"]]},
{name: "ruby-test-integration"} ${common} ${gate_caps} {run: [${jt} [test, integration]]},
{name: "ruby-tarball"} ${common} ${gate_caps} {run: [${jt} [tarball]]}
{name: ruby-test-fast} ${common} ${gate_caps} {run: [${jt} [test, fast]]},
{name: ruby-test-specs-command-line} ${common} ${gate_caps} {run: [${jt} [test, specs, ":command_line"]]},
{name: ruby-test-specs-language} ${common} ${gate_caps} {run: [${jt} [test, specs, ":language"]]},
{name: ruby-test-specs-core} ${common} ${gate_caps} {run: [${jt} [test, specs, ":core"]]},
{name: ruby-test-specs-library} ${common} ${gate_caps} {run: [${jt} [test, specs, ":library"]]},
{name: ruby-test-specs-truffle} ${common} ${gate_caps} {run: [${jt} [test, specs, ":truffle"]]},
{name: ruby-test-integration} ${common} ${gate_caps} {run: [${jt} [test, integration]]},
{name: ruby-tarball} ${common} ${gate_caps} {run: [${jt} [tarball]]}
]
11 changes: 10 additions & 1 deletion core/src/main/java/org/jruby/Ruby.java
Original file line number Diff line number Diff line change
@@ -3127,7 +3127,16 @@ public JavaProxyClassFactory getJavaProxyClassFactory() {
public class CallTraceFuncHook extends EventHook {
private RubyProc traceFunc;
private EnumSet<RubyEvent> interest =
EnumSet.allOf(RubyEvent.class);
EnumSet.of(
RubyEvent.C_CALL,
RubyEvent.C_RETURN,
RubyEvent.CALL,
RubyEvent.CLASS,
RubyEvent.END,
RubyEvent.LINE,
RubyEvent.RAISE,
RubyEvent.RETURN
);

public void setTraceFunc(RubyProc traceFunc) {
this.traceFunc = traceFunc;
13 changes: 11 additions & 2 deletions core/src/main/java/org/jruby/runtime/encoding/EncodingService.java
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@
import org.jcodings.util.Hash.HashEntryIterator;
import org.jruby.Ruby;
import org.jruby.RubyEncoding;
import org.jruby.exceptions.RaiseException;
import org.jruby.platform.Platform;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.util.ByteList;
@@ -25,6 +26,7 @@
import org.jruby.RubyFixnum;
import org.jruby.RubyString;
import org.jruby.ext.nkf.RubyNKF;
import org.jruby.util.SafePropertyAccessor;
import org.jruby.util.encoding.ISO_8859_16;

public final class EncodingService {
@@ -542,8 +544,15 @@ public Encoding toEncoding(Ruby runtime) {
case EXTERNAL: return runtime.getDefaultExternalEncoding();
case INTERNAL: return runtime.getDefaultInternalEncoding();
case FILESYSTEM:
// This needs to do something different on Windows. See encoding.c,
// in the enc_set_filesystem_encoding function.
if (Platform.IS_WINDOWS) {
String fileEncoding = SafePropertyAccessor.getProperty("file.encoding", "UTF-8");
try {
return service.getEncodingFromString(fileEncoding);
} catch (RaiseException re) {
runtime.getWarnings().warning("could not load encoding for file.encoding of " + fileEncoding + ", using default external");
if (runtime.isDebug()) re.printStackTrace();
}
}
return runtime.getDefaultExternalEncoding();
default:
throw new RuntimeException("invalid SpecialEncoding: " + this);
23 changes: 23 additions & 0 deletions spec/ruby/core/io/puts_spec.rb
Original file line number Diff line number Diff line change
@@ -116,4 +116,27 @@ def @io.write(str)
it "raises IOError on closed stream" do
lambda { IOSpecs.closed_io.puts("stuff") }.should raise_error(IOError)
end

with_feature :encoding do
it "writes crlf when IO is opened with newline: :crlf" do
File.open(@name, 'w', newline: :crlf) do |file|
file.puts
end
File.read(@name).should == "\r\n"
end

it "writes cr when IO is opened with newline: :cr" do
File.open(@name, 'w', newline: :cr) do |file|
file.puts
end
File.read(@name).should == "\r"
end

it "writes lf when IO is opened with newline: :lf" do
File.open(@name, 'w', newline: :lf) do |file|
file.puts
end
File.read(@name).should == "\n"
end
end
end
2 changes: 2 additions & 0 deletions spec/truffle/tags/core/io/puts_tags.txt
Original file line number Diff line number Diff line change
@@ -2,3 +2,5 @@ fails:IO#puts writes just a newline when given just a newline
fails:IO#puts calls :to_ary before writing non-string objects, regardless of it being implemented in the receiver
fails:IO#puts calls :to_ary before writing non-string objects
fails:IO#puts returns general object info if :to_s does not return a string
fails:IO#puts writes crlf when IO is opened with newline: :crlf
fails:IO#puts writes cr when IO is opened with newline: :cr
26 changes: 16 additions & 10 deletions tool/jt.rb
Original file line number Diff line number Diff line change
@@ -45,12 +45,17 @@ def self.graal_locations
yield File.expand_path(from_branch) if from_branch

rel_java_bin = "bin/java" # "jre/bin/javao"
%w[dk re].each { |kind|
["", "../", "../../"].each { |prefix|
['', '../', '../../'].each do |prefix|
%w[dk re].each do |kind|
path = "#{prefix}graalvm-#{GRAALVM_VERSION}-#{kind}/#{rel_java_bin}"
yield File.expand_path(path, JRUBY_DIR)
}
}
end
end

['', '../', '../../'].each do |prefix|
path = Dir["#{prefix}graal/jvmci/jdk1.8.*/product/#{rel_java_bin}"].sort.last
yield File.expand_path(path, JRUBY_DIR) if path
end
end

def self.find_graal
@@ -471,14 +476,15 @@ def test(*args)
when nil
test_tck
test_specs('run')
# test_mri # TODO (pitr-ch 29-Mar-2016): temporarily disabled
test_integration({'HAS_REDIS' => 'true'}, 'all')
# test_mri # TODO (pitr-ch 29-Mar-2016): temporarily disabled since it uses refinements
test_integration
test_gems env: { 'HAS_REDIS' => 'true' }
test_compiler
test_cexts if ENV['SULONG_DIR']
when 'compiler' then test_compiler(*rest)
when 'cexts' then test_cexts(*rest)
when 'integration' then test_integration({}, *rest)
when 'gems' then test_gems({}, *rest)
when 'integration' then test_integration(*rest)
when 'gems' then test_gems(*rest)
when 'specs' then test_specs('run', *rest)
when 'tck' then
args = []
@@ -549,7 +555,7 @@ def test_cexts(*args)
end
private :test_cexts

def test_integration(env, *args)
def test_integration(*args, env: {})
env_vars = env
jruby_opts = []

@@ -567,7 +573,7 @@ def test_integration(env, *args)
end
private :test_integration

def test_gems(env, *args)
def test_gems(*args, env: {})
env_vars = env
jruby_opts = []

Original file line number Diff line number Diff line change
@@ -900,6 +900,7 @@ public void initializeAfterBasicMethodsAdded() {
// Get some references to things defined in the Ruby core

eagainWaitReadable = (DynamicObject) Layouts.MODULE.getFields(ioClass).getConstant("EAGAINWaitReadable").getValue();
assert Layouts.CLASS.isClass(eagainWaitReadable);
}

private void initializeRubiniusFFI() {
Original file line number Diff line number Diff line change
@@ -708,6 +708,16 @@ public DynamicObject systemCallError(String message, Node currentNode) {
context.getCallStack().getBacktrace(currentNode));
}

// IO::EAGAINWaitReadable

@TruffleBoundary
public DynamicObject eAGAINWaitReadable(Node currentNode) {
return ExceptionOperations.createRubyException(
context.getCoreLibrary().getEagainWaitReadable(),
coreStrings().RESOURCE_TEMP_UNAVAIL.createInstance(),
context.getCallStack().getBacktrace(currentNode));
}

// SystemExit

@TruffleBoundary
Original file line number Diff line number Diff line change
@@ -70,9 +70,7 @@
import org.jruby.util.ByteList;
import org.jruby.util.Dir;
import org.jruby.util.unsafe.UnsafeHolder;

import java.nio.ByteBuffer;

import static org.jruby.truffle.core.string.StringOperations.rope;

public abstract class IOPrimitiveNodes {
@@ -265,10 +263,7 @@ public Object readIfAvailable(DynamicObject file, int numberOfBytes) {
PointerPrimitiveNodes.NULL_POINTER, PointerPrimitiveNodes.NULL_POINTER, timeoutObject));

if (res == 0) {
throw new RaiseException(
Layouts.CLASS.getInstanceFactory(coreLibrary().getEagainWaitReadable()).newInstance(
coreStrings().RESOURCE_TEMP_UNAVAIL.createInstance(),
Errno.EAGAIN.intValue()));
throw new RaiseException(coreExceptions().eAGAINWaitReadable(this));
}

final byte[] bytes = new byte[numberOfBytes];

0 comments on commit c676bdd

Please sign in to comment.